Modified NAS slightly

I was having trouble with the base64 encoded data, so I replaced it with
something that should definitely work.
I also reduced the size of the auth token so there won't be any possible
overflows. Since it's random data it can easily be adjusted in the
future if for some reason it's too small.
This commit is contained in:
polaris
2014-04-18 09:19:57 -04:00
parent 0c19e2683d
commit 9c8824ff0c
2 changed files with 9 additions and 5 deletions

View File

@@ -1,10 +1,12 @@
import sqlite3
import hashlib
import itertools
import other.utils as utils
import time
import logging
import other.utils as utils
import gamespy.gs_utility as gs_utils
# Logger settings
logger_output_to_console = True
logger_output_to_file = True
@@ -382,7 +384,9 @@ class GamespyDatabase(object):
return r["data"]
def generate_authtoken(self, userid, data):
size = 128
# Since the auth token passed back to the game will be random, we can make it small enough that there
# should never be a crash due to the size of the token.
size = 16
authtoken = "NDS" + utils.generate_random_str(size)
q = "SELECT authtoken FROM nas_logins WHERE authtoken = ?"
@@ -412,7 +416,7 @@ class GamespyDatabase(object):
c.execute(q, [authtoken, data, userid])
c.close()
self.conn.commit();
self.conn.commit()
return authtoken

View File

@@ -75,9 +75,9 @@ class NintendoNasHTTPServerHandler(BaseHTTPServer.BaseHTTPRequestHandler):
logger.log(logging.DEBUG, ret)
for k, v in ret.iteritems():
ret[k] = self.base64_enc(v)
ret[k] = gs_utils.base64_encode(v)
self.wfile.write(urllib.urlencode(ret).replace("%2A", "*"))
self.wfile.write(urllib.urlencode(ret))
#elif self.path == "/pr":
# TODO