File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,18 @@ def __init__(self):
34
34
self .agent_data = dict ()
35
35
self .now_capture_time = int (time .time ())
36
36
self .hostname = socket .gethostname ()
37
- self .ip = socket .gethostbyname (self .hostname )
37
+ # ------------------------ b1gw00d ------------------------------
38
+ # fix: b1gw00d --> https://github.com/toddlerya/NebulaSolarDash/issues/8
39
+ try :
40
+ csock = socket .socket (socket .AF_INET ,socket .SOCK_DGRAM )
41
+ csock .connect (('8.8.8.8' ,80 ))
42
+ (addr ,port )= csock .getsockname ()
43
+ csock .close ()
44
+ self .ip = addr
45
+ except socket .error :
46
+ self .ip = '127.0.0.1'
47
+ # ------------------------ b1gw00d ------------------------------
48
+ # self.ip = socket.gethostbyname(self.hostname)
38
49
self .agent_data ['hostname' ] = self .hostname
39
50
self .agent_data ['ip' ] = self .ip
40
51
self .agent_data ['capturetime' ] = self .now_capture_time
You can’t perform that action at this time.
0 commit comments