Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify if current IP address is obtained in outside network #11

Open
mschatten opened this issue Mar 30, 2021 · 0 comments
Open

Verify if current IP address is obtained in outside network #11

mschatten opened this issue Mar 30, 2021 · 0 comments

Comments

@mschatten
Copy link
Member

This function works with local computers. Will it work if agents (possibly in docker-like containers) are distributed on various servers?

APi/channel.py

Lines 153 to 166 in e1208c0

def get_ip( self ):
'''Get the current IP address of the agent'''
# TODO: Verify this works with outside network
# addresses!
s = socket.socket( socket.AF_INET, socket.SOCK_DGRAM )
try:
# doesn't even have to be reachable
s.connect( ( '10.255.255.255', 1 ) )
IP = s.getsockname()[ 0 ]
except Exception:
IP = '127.0.0.1'
finally:
s.close()
return IP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant