From d622bf0bd855f4d2f0600a52aba1faa015f91ac6 Mon Sep 17 00:00:00 2001 From: Teddy Date: Fri, 23 Aug 2013 08:30:32 +0800 Subject: ... --- server/piztor_server.py | 12 +++++++++--- server/ptp.rst | 6 +++--- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'server') diff --git a/server/piztor_server.py b/server/piztor_server.py index 924e268..a19989a 100644 --- a/server/piztor_server.py +++ b/server/piztor_server.py @@ -51,7 +51,7 @@ class UserManager(DataManager): Base.metadata.create_all(engine) self.active_sessions = dict() - def authentication_handle(self, opt_type, data): + def authentication_handle(self, opt_type, data, srv): print "Parsing User Data" pos = -1 for i in xrange(0, len(data)): @@ -69,11 +69,17 @@ class UserManager(DataManager): print "Trying to login with following info:" print (username, password) + session = Session() + q = session.query(User).filter(User.username == username) + entry = q.first() + if entry.password != password: # Auth failed + return struct.pack("!BL" + return struct.pack("!BL", 0, 1234) class MesgManager(DataManager): - def mesg_sending_handle(self, opt_type, data): + def mesg_sending_handle(self, opt_type, data, srv): print "Parsing Mesg Data" try: if len(data) < 8: @@ -86,7 +92,7 @@ class MesgManager(DataManager): raise ReqInvalidError() class LocationManager(DataManager): - def location_update_handle(self, opt_type, data): + def location_update_handle(self, opt_type, data, srv): print "Parsing Loc Data" try: if len(data) < 8: diff --git a/server/ptp.rst b/server/ptp.rst index a061878..741e41e 100644 --- a/server/ptp.rst +++ b/server/ptp.rst @@ -33,9 +33,9 @@ Piztor Transmission Protocol v0.1 :: - +--1b---+-----4b-----+----1b----+ - | 0x00 | USER_TOKEN | RESERVED | - +-uchar-+-----int----+---uchar--+ + +--1b---+-----4b-----+---1b---+ + | 0x00 | USER_TOKEN | STATUS | + +-uchar-+-----int----+--uchar-+ - Message Sending -- cgit v1.2.3-70-g09d2