From d2c150c11ed9522469ecc5fca44b42ef0d81b154 Mon Sep 17 00:00:00 2001 From: Teddy Date: Sun, 25 Aug 2013 09:52:41 +0800 Subject: ptp revised --- server/piztor/exc.py | 5 ++++- server/piztor/model.py | 1 + server/ptp.rst | 24 ++++++++++++------------ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/server/piztor/exc.py b/server/piztor/exc.py index 5daf420..2c53dbf 100644 --- a/server/piztor/exc.py +++ b/server/piztor/exc.py @@ -1,6 +1,9 @@ class PiztorError(Exception): pass +class DBCurruptedError(PiztorError): + pass + class ConnectionError(PiztorError): pass @@ -10,5 +13,5 @@ class ReqReadError(ConnectionError): class BadReqError(ConnectionError): pass -class InvalidTokenError(ConnectionError): +class BadTokenError(ConnectionError): pass diff --git a/server/piztor/model.py b/server/piztor/model.py index d869c32..70ca431 100644 --- a/server/piztor/model.py +++ b/server/piztor/model.py @@ -3,6 +3,7 @@ from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import relationship, backref Base = declarative_base() + _SALT_LEN = 16 _TOKEN_LEN = 16 diff --git a/server/ptp.rst b/server/ptp.rst index 4092399..e835bd7 100644 --- a/server/ptp.rst +++ b/server/ptp.rst @@ -33,9 +33,9 @@ Piztor Transmission Protocol v0.1 :: - +--1b---+-----4b-----+---1b----+ - | 0x00 | USER_TOKEN | STATUS | - +-uchar-+-----int----+--uchar--+ + +--1b---+---1b---+---4b----+----16b-----+ + | 0x00 | STATUS | USER_ID | USER_TOKEN | + +-uchar-+--uchar-+---int---+----raw-----+ ``STATUS`` : @@ -48,9 +48,9 @@ Piztor Transmission Protocol v0.1 :: - +--1b---+------4b------+-----8b-----+------8b-----+ - | 0x02 | SENDER_TOKEN | LATITUDE | LONGITUDE | - +-uchar-+------int-----+---double---+---double----+ + +--1b---+-----16b------+-----8b-----+------8b-----+ + | 0x02 | USER_TOKEN | LATITUDE | LONGITUDE | + +-uchar-+------raw-----+---double---+---double----+ - Response @@ -71,17 +71,17 @@ Piztor Transmission Protocol v0.1 :: - +--1b---+-----4b-------+------4b-----+ - | 0x03 | SENDER_TOKEN | GROUP_ID | - +-uchar-+-----int------+-----int-----+ + +--1b---+-----16b------+------4b-----+ + | 0x03 | USER_TOKEN | GROUP_ID | + +-uchar-+-----raw------+-----int-----+ - Response :: - +--1b---+-----4b----+------20b-------+-----+ - | 0x03 | ENTRY_CNT | LOCATION_ENTRY | ... | - +-uchar-+---int-----+----------------+-----+ + +--1b---+---1b---+-----4b----+------20b-------+-----+ + | 0x03 | STATUS | ENTRY_CNT | LOCATION_ENTRY | ... | + +-uchar-+-uchar--+----int----+----------------+-----+ ``LOCATION_ENTRY`` : -- cgit v1.2.3