summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/piztor/prober.py14
-rw-r--r--server/piztor/ptp.rst51
-rw-r--r--server/piztor/server.py6
3 files changed, 59 insertions, 12 deletions
diff --git a/server/piztor/prober.py b/server/piztor/prober.py
index ec6afa8..9cfde24 100644
--- a/server/piztor/prober.py
+++ b/server/piztor/prober.py
@@ -25,8 +25,8 @@ class _SectionSize:
LOCATION_ENTRY = USER_ID + LATITUDE + LONGITUDE
PADDING = 1
-host = "localhost"
-port = 2222
+host = "69.85.86.42" #"localhost"
+port = 2223
def gen_auth(username, password):
length = _SectionSize.LENGTH + \
@@ -177,6 +177,9 @@ def request_user_info(token, username, uid):
logger.error("Request user info: incorrect packet length")
idx = 6
+ comp_id = None
+ sec_id = None
+ sex = None
while idx < pl:
info_key, = unpack("!B", resp[idx:idx + 1])
idx += 1
@@ -210,9 +213,10 @@ for i in xrange(10):
update_location(token, username, random(), random())
comp_id, sec_id, sex = request_user_info(token, username, uid)
- request_location(token, username, comp_id * 256 + sec_id)
- request_location(token, username, comp_id * 256 + 0xff)
+ if comp_id:
+ request_location(token, username, comp_id * 256 + sec_id)
+ request_location(token, username, comp_id * 256 + 0xff)
- logout(token, username)
+ logout(token, username)
sleep(10)
diff --git a/server/piztor/ptp.rst b/server/piztor/ptp.rst
index 492a44f..a5523a8 100644
--- a/server/piztor/ptp.rst
+++ b/server/piztor/ptp.rst
@@ -1,4 +1,4 @@
-Piztor Transmission Protocol v0.4a
+Piztor Transmission Protocol v1.0
----------------------------------
- General
@@ -91,9 +91,17 @@ Piztor Transmission Protocol v0.4a
::
- +--1b---+------?b------+------4b-----+
+ +--1b---+------?b------+------2b-----+
| 0x02 | AUTH_HEAD | GROUP_ID |
- +-uchar-+--------------+-----int-----+
+ +-uchar-+--------------+-------------+
+
+ ``GROUP_ID``:
+
+ ::
+
+ +---1b----+---1b---+
+ | COMP_ID | SEC_ID |
+ +--uchar--+-uchar--+
- Response
@@ -139,7 +147,7 @@ Piztor Transmission Protocol v0.4a
``INFO_KEY`` :
- :``0x00``: gid (value is a 4-byte ``long int``)
+ :``0x00``: gid (value is a 2-byte ``GROUP_ID``)
:``0x01``: sex (value is a 1-byte ``boolean``: ``0x01`` for male, ``0x00`` for female)
- User Logout
@@ -160,3 +168,38 @@ Piztor Transmission Protocol v0.4a
| 0x04 | STATUS |
+------+--------+
+- Push Tunnel
+
+ - Request
+
+ ::
+
+ +--1b--+-----?b------+
+ | 0x05 | AUTH_HEAD |
+ +------+-------------+
+
+ - Response
+
+ ::
+
+ +--1b--+---1b---+
+ | 0x05 | STATUS |
+ +------+--------+
+
+- Push Text Message
+
+ - Request
+
+ ::
+
+ +--1b--+----?b----+
+ | 0x10 | MESSAGE |
+ +------+--string--+
+
+ - Response
+
+ ::
+
+ +--1b--+
+ | 0x10 |
+ +------+
diff --git a/server/piztor/server.py b/server/piztor/server.py
index 08a2981..3f1f2cb 100644
--- a/server/piztor/server.py
+++ b/server/piztor/server.py
@@ -32,7 +32,7 @@ class _SectionSize:
STATUS = 1
USER_ID = 4
USER_TOKEN = 32
- GROUP_ID = 4
+ GROUP_ID = 2
ENTRY_CNT = 4
LATITUDE = 8
LONGITUDE = 8
@@ -232,7 +232,7 @@ class LocationInfoHandler(RequestHandler):
username, tail = RequestHandler.trunc_padding(tr_data[32:])
if username is None:
raise struct.error
- a, b, comp_id, sec_id = struct.unpack("!BBBB", tail)
+ comp_id, sec_id = struct.unpack("!BB", tail)
except struct.error:
raise BadReqError("Location request: Malformed request body")
@@ -268,7 +268,7 @@ class LocationInfoHandler(RequestHandler):
return reply
def pack_gid(user):
- return struct.pack("!BBBB", 0, 0, user.comp_id, user.sec_id)
+ return struct.pack("!BB", user.comp_id, user.sec_id)
def pack_sex(user):
return struct.pack("!B", 0x01 if user.sex else 0x00)