Update protocol for #16

This commit is contained in:
Louis Royer 2020-03-19 14:04:33 +01:00
parent ab7af56138
commit d1ae5960a6

View File

@ -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: [<FILENAME>]
```
#### Discover response
Contains:
```
4 bytes: [(bytes 8-11): FILENAME SIZE]
y bytes: [<FILENAME>]
? 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