diff options
author | Teddy <[email protected]> | 2013-08-23 08:30:32 +0800 |
---|---|---|
committer | Teddy <[email protected]> | 2013-08-23 08:30:32 +0800 |
commit | d622bf0bd855f4d2f0600a52aba1faa015f91ac6 (patch) | |
tree | bc5bf42db50b55be4d6f58894eb8863c423fa50f /server | |
parent | b6e5eac9702e8fb1c47aebddd613933706a0a36a (diff) |
...
Diffstat (limited to 'server')
-rw-r--r-- | server/piztor_server.py | 12 | ||||
-rw-r--r-- | server/ptp.rst | 6 |
2 files changed, 12 insertions, 6 deletions
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 |