From d1ae5960a68c21b01b298a1658505a3824f2735c Mon Sep 17 00:00:00 2001 From: Louis Date: Thu, 19 Mar 2020 14:04:33 +0100 Subject: [PATCH] Update protocol for #16 --- doc/protocol.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/doc/protocol.md b/doc/protocol.md index b21a615..a2cf4d5 100644 --- a/doc/protocol.md +++ b/doc/protocol.md @@ -17,17 +17,22 @@ x bytes: [(bytes 8-?): PAYLOAD] - `LIST` (0x00) - `LOAD` (0x01) - `HASH` (0x02) + - `DISCOVER` (0x03) + - `REGISTER` (0x04) + - `UNREGISTER` (0x05) - RESPONSES (msb is 1): - `LIST` (0x80) - `LOAD` (0x81) - `HASH` (0x82) + - `DISCOVER` (0x83) - `VERSION ERROR` (0xC0) - `PROTOCOL ERROR` (0xC1) - `INTERNAL ERROR` (0xC2) - `EMPTY DIRECTORY` (0xC3) - `NOT FOUND` (0xC4) - `EMPTY FILE` (0xC5) + - `NOT A TRACKER` (0xC6) ### List Payload size for list request is always zero. @@ -97,6 +102,47 @@ A algo hash bloc contains: ``` +### Tracker specific messages +#### Register +Used by a server to register itself on a tracker. +Payload contains `0x01` if working on udp, `0x02` if working on tcp, `0x03` if working on both. +Server may want to do a free `DISCOVER` to check if they have been registered. + +#### Unregister +Used by a server to unregister itself from a tracker. +Payload contains `0x01` if unregister from udp, `0x02` if unregister from tcp, `0x03` if unregister on both. +No error is raised if the server was not registered. +Server may want to do a free `DISCOVER` to check if they have been unregistered. + +#### Discover request +If payload size is null, lists all servers registered. +If payload contains a filename, list all servers having this file in their list. + +``` +? bytes: [] + +``` + +#### Discover response +Contains: +``` +4 bytes: [(bytes 8-11): FILENAME SIZE] +y bytes: [] +? bytes [multiple server blocks] +``` + +Server block is composed with: + +``` +2 bytes: [port] +1 byte: [protocols (udp: 0x01, tcp: 0x02, tcp+udp: 0x03)] +? bytes: hostname +\n +``` + +#### Not a Tracker +This error is raised when receiving a DISCOVER, a REGISTER, or an UNREGISTER request, +but this application is not a tracker. ### Other response code (errors) #### Version error