Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Admiral H. Curtiss
2014-05-15 17:35:27 +02:00
2 changed files with 42 additions and 25 deletions

View File

@@ -99,7 +99,7 @@ class GameSpyNatNegServer(object):
self.session_list[gameid][session_id][client]['serveraddr'] = serveraddr
logger.log(logging.DEBUG, "Found server from local ip/port: %s" % serveraddr)
publicport = 0
publicport = self.session_list[gameid][session_id][client]['addr'][1]
if self.session_list[gameid][session_id][client]['serveraddr'] != None:
publicport = int(self.session_list[gameid][session_id][client]['serveraddr']['publicport'])
@@ -122,7 +122,7 @@ class GameSpyNatNegServer(object):
self.session_list[gameid][session_id][client_id]['serveraddr'] = serveraddr
logger.log(logging.DEBUG, "Found server 2 from local ip/port: %s" % serveraddr)
publicport = 0
publicport = self.session_list[gameid][session_id][client_id]['addr'][1]
if self.session_list[gameid][session_id][client_id]['serveraddr'] != None:
publicport = int(self.session_list[gameid][session_id][client_id]['serveraddr']['publicport'])

View File

@@ -72,12 +72,15 @@ class NintendoNasHTTPServerHandler(BaseHTTPServer.BaseHTTPRequestHandler):
self.wfile.write(self.dict_to_str(ret))
elif action == "SVCLOC" or action == "svcloc": # Get service based on service id number
if post["svc"] == "9000": # DLC host = 9000
if post["svc"] == "9000" or post["svc"] == "9001": # DLC host = 9000
ret["returncd"] = "007"
ret["statusdata"] = "Y"
ret["svchost"] = "dls1.nintendowifi.net"
ret["svchost"] = self.headers['host'] # in case the client's DNS isn't redirecting dls1.nintendowifi.net
authtoken = self.server.db.generate_authtoken(post["userid"], post)
ret["token"] = authtoken
if post["svc"] == 9000:
ret["token"] = authtoken
else:
ret["servicetoken"] = authtoken
logger.log(logging.DEBUG, "svcloc response to %s", self.client_address)
logger.log(logging.DEBUG, ret)
@@ -115,10 +118,20 @@ class NintendoNasHTTPServerHandler(BaseHTTPServer.BaseHTTPRequestHandler):
if os.path.exists(dlcpath):
count = len(os.listdir(dlcpath))
# the above counts the file list as a file too, subtract that again if it exists
if os.path.isfile(dlcpath + "/_list.txt"):
count -= 1
attr1 = None
if "attr1" in post:
attr1 = post["attr1"]
attr2 = None
if "attr2" in post:
attr2 = post["attr2"]
attr3 = None
if "attr3" in post:
attr3 = post["attr3"]
list = open(dlcpath + "/_list.txt", "rb").read()
list = self.filter_list(list, attr1, attr2, attr3)
count = list.count("\r\n")
ret = "%d" % count
@@ -192,27 +205,31 @@ class NintendoNasHTTPServerHandler(BaseHTTPServer.BaseHTTPRequestHandler):
# Filter the list based on the attribute fields
output = ""
for line in data.split('\n'):
for line in data.splitlines():
s = line.split('\t')
data = {}
data['filename'] = s[0]
data['desc'] = s[1]
data['attr1'] = s[2]
data['attr2'] = s[3]
data['attr3'] = s[4]
data['filesize'] = s[5]
if len(s) == 6:
data = {}
data['filename'] = s[0]
data['desc'] = s[1]
data['attr1'] = s[2]
data['attr2'] = s[3]
data['attr3'] = s[4]
data['filesize'] = s[5]
matched = True
if attr1 != None and data['attr1'] != attr1:
matched = False
if attr2 != None and data['attr2'] != attr2:
matched = False
if attr3 != None and data['attr3'] != attr3:
matched = False
matched = True
if attr1 != None:
if data['attr1'] != attr1:
matched = False
if attr2 != None:
if data['attr2'] != attr2:
matched = False
if attr3 != None:
if data['attr3'] != attr3:
matched = False
if matched == True:
output += line + '\r\n'
if matched == True:
output += line + '\r\n'
return output