UrDHT / PyUrDHT

Python reference implementation
11 stars 3 forks source link

so... autosense public ip in python3 snippet #65

Closed mmcd closed 9 years ago

mmcd commented 9 years ago

import socket

google = "73.194.219.106" addrPort = "8000" wsPort = "8001"

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect((google,80)) ip = s.getsockname()[0] s.close()

addr = "http://" + ip + ":" + addrPort + "/" wsAddr = "ws:/" + ip + ":" + wsPort + "/"

print("addr: " + addr) print("wsAddr: " + wsAddr)

BrendanBenshoof commented 9 years ago

we have already solved this via the bootstrap. And this code does not give us an IP if you are behind NAT.

The current default config utilizes it.