mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-10 21:55:11 +01:00
Correct addr
This commit is contained in:
parent
67b3abc248
commit
6388778cfb
@ -180,7 +180,7 @@ class Peer:
|
||||
|
||||
# Lookup which country this guy is from
|
||||
try:
|
||||
self.country = srv.ip2c.lookup(self.public_ip)
|
||||
self.country = srv.ip2c.lookup( self.addr_to_ip_dot_format(addr) )
|
||||
except ValueError, e:
|
||||
self.country = None
|
||||
if self.country == None:
|
||||
@ -200,6 +200,11 @@ class Peer:
|
||||
port = addr[1]
|
||||
return "%08x" % (ip), port
|
||||
|
||||
def addr_to_ip_dot_format(self, addr):
|
||||
ip = struct.unpack("@L", socket.inet_pton(socket.AF_INET, addr[0]))[0]
|
||||
port = addr[1]
|
||||
return "%d.%d.%d.%d" % ((ip & 0xff000000) >> 24, (ip & 0x00ff0000) >> 16, (ip & 0x0000ff00) >> 8, ip & 0xff)
|
||||
|
||||
def handle_packet(self, pkt):
|
||||
if pkt.type == CONNECT_TO_BROKER:
|
||||
self.key = pkt.get_key()
|
||||
|
Loading…
Reference in New Issue
Block a user