Found an unexpected bug, the "Gov-Client-Local-IPs" header is populated with the loopback address ("127.x") on Linux, and not the local IP address.
This is because Python's socket.getbyhostname() returns the value in /etc/hosts, which usually has the loopback address.
On Win and Mac OS the behaviour seems to be correct, but I haven't tested for myself.
After a bit of searching, I found a solution like this (which doesn't add extra dep's):
def get_ip_address():
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
s.connect(("192.168.1.1", 80))
return s.getsockname()[0]
Unfortunately I don't know how to get the gateway IP, so the code above uses my default (the example used 8.8.8.8, but I don't want to open connections externally if it's not needed).
Found an unexpected bug, the "Gov-Client-Local-IPs" header is populated with the loopback address ("127.x") on Linux, and not the local IP address. This is because Python's socket.getbyhostname() returns the value in /etc/hosts, which usually has the loopback address.
On Win and Mac OS the behaviour seems to be correct, but I haven't tested for myself.
After a bit of searching, I found a solution like this (which doesn't add extra dep's):
Unfortunately I don't know how to get the gateway IP, so the code above uses my default (the example used 8.8.8.8, but I don't want to open connections externally if it's not needed).