Don't forward data to port 0

Also made the loop in qr more pythonic.
This commit is contained in:
polaris
2014-05-28 19:11:15 -04:00
parent 0a0e37cc11
commit a5ee7e9b31
2 changed files with 5 additions and 3 deletions

View File

@@ -269,8 +269,7 @@ class GameSpyQRServer(object):
if found_console == False:
# Couldn't detect game, try to get it from the database
# Try a 3 times before giving up
retry = 0
while retry < 3:
for i in range(0, 3):
try:
profile = self.db.get_profile_from_profileid(self.sessions[session_id].playerid)
@@ -279,7 +278,6 @@ class GameSpyQRServer(object):
break
except:
retry += 1
time.sleep(0.5)

View File

@@ -401,6 +401,10 @@ class Session(LineReceiver):
self.log(logging.DEBUG, "%s %s" % (ip, server['publicip']))
if server['publicip'] == ip and server['publicport'] == str(self.forward_client[1]):
if self.forward_client[1] == 0 and 'localport' in server:
# No public port returned from client, try contacting on the local port.
self.forward_client[1] = int(server['localport'])
# Send command to server to get it to connect to natneg
cookie = int(utils.generate_random_hex_str(8), 16) # Quick and lazy way to get a random 32bit integer. Replace with something else later