Skip to content

Commit

Permalink
back to old ip system
Browse files Browse the repository at this point in the history
  • Loading branch information
AndersSpringborg committed Jan 27, 2021
1 parent 1bb114a commit d598863
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions steinloss/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,16 @@ def shutdown(self):
loop.close()

def get_local_ip(self):
hostname = socket.gethostname()
local_ip = socket.gethostbyname(hostname)
return local_ip
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
# doesn't even have to be reachable
s.connect(('8.8.8.8', 1))
ip = s.getsockname()[0]
except Exception:
ip = '127.0.0.1'
finally:
s.close()
return ip


class EchoServerProtocol(asyncio.DatagramProtocol):
Expand Down

0 comments on commit d598863

Please sign in to comment.