Commit 2fe0ea46 authored by Éloïs's avatar Éloïs

[ref] change EXTENDED feature by variable size of feature field

parent e493ddcb
......@@ -156,18 +156,20 @@ _*the `null` value is essential, it allows the user to synchronize his node with
| data name | size in bytes | data type |
|:----------------:|--------------:|----------:|
| api_size | 1 | u8 |
| host_size | 1 | u8 |
| path_size | 1 | u8 |
| api_name | 1/api_size | specific |
| api_version | 2 | u16 |
| network_features | 2/+ | specific |
| api_features | 2/+ | specific |
| ip_v4 | 4 | [u8; 4] |
| ip_v6 | 16 | [u16; 8] |
| host | host_size | utf8 |
| port | 2 | u16 |
| path | path_size | utf8 |
| api_size | 1 | u8 |
| host_size | 1 | u8 |
| path_size | 1 | u8 |
| api_name | 1/api_size | specific |
| api_version | 2 | u16 |
| nf_size | 1 | u8 |
| network_features | nf_size | specific |
| af_size | 1 | u8 |
| api_features | af_size | specific |
| ip_v4 | 4 | [u8; 4] |
| ip_v6 | 16 | [u16; 8] |
| host | host_size | utf8 |
| port | 2 | u16 |
| path | path_size | utf8 |
#### api_code interpretation
......@@ -188,14 +190,12 @@ The 16 bits represent booleans to define the presence or absence of 16 network f
Network features :
| bit | feature |
|:-------------------:|----------|
| 0000_0000 0000_0001 | ip_v4 |
| 0000_0000 0000_0010 | ip_v6 |
| 0000_0000 0000_0100 | S |
| 0000_0000 0000_1000 | TOR |
| ... | ... |
| 1000_0000 0000_0000 | EXTENDED |
| bit | feature |
|:---------:|----------|
| 0000_0001 | ip_v4 |
| 0000_0010 | ip_v6 |
| 0000_0100 | S |
| 0000_1000 | TOR |
The first two features are a bit special because they must be read to parse the endpoint, indicating if the ipv4 and ipv6 fields are present or not.
......@@ -203,21 +203,17 @@ S := This feature indicates that the endpoint should be contacted with an SSL/TL
TOR := This feature indicates that the endpoint must be contacted via the tor network (hidden service).
EXTENDED := Indicates that the `network_features` field contains 2 additional bytes to store 16 more features.
#### api_features
The interpretation of this field depends on the API because it represents API-specific features. Here is the interpretation for the WS2P API :
WS2PFeatures type definition :
| bit | feature |
|:-------------------:|-----------|
| 0000_0000 0000_0001 | DEFLATE |
| 0000_0000 0000_0010 | LOW |
| 0000_0000 0000_0100 | RBF |
| ... | ... |
| 1000_0000 0000_0000 | EXTENDED |
| bit | feature |
|:----- ---:|-----------|
| 0000_0001 | DEFLATE |
| 0000_0010 | LOW |
| 0000_0100 | RBF |
DEFLATE := Supports permessage-deflate extension
......@@ -225,9 +221,7 @@ LOW := Accept low speed connection requests
RBF := Accept rust binary format
EXTENDED := Indicates that the `api_features` field contains 2 additional bytes to store 16 more features.
WS2P v2 uses only 3 of 16 features. The 13 free bits can be used for future versions of WS2P.
WS2P v2 uses only 3 of 8 features. The 5 free bits can be used for future versions of WS2P.
### Endpoint utf8 format
......@@ -254,7 +248,8 @@ Same endpoint in binary format :
| api_name | 1/api_size | specific | 0x01 |
| api_version | 2 | u16 | 0x0002 |
| network_features | 2 | specific | 0x0004 |
| api_features | 2 | specific | 0x0007 |
| af_size | 1 | u8 | 0x01 |
| api_features | 1 | specific | 0x07 |
| ip_v4 | 4 | [u8; 4] | None |
| ip_v6 | 16 | [u16; 8] | None |
| host | host_size | utf8 | "g1.durs.ifee.fr" encoded in utf8 |
......@@ -368,8 +363,10 @@ for each connection attempt, the process is as follows:
| data name | size in bytes | data type |
|:-------------:|---------------|--------------|
| challenge | 32 | [u8; 32] |
| api_features | 2/+ | WS2PFeatures |
| flags_queries | 1/+ | WS2PFlags |
| af_size | 1 | u8 |
| api_features | af_size | WS2PFeatures |
| flags_size | 1 | u8 |
| flags_queries | flags_size | WS2PFlags |
| peer_card | ? | Peer card |
| chunk_id* | 4 | u32 |
| chunk_hash* | 32 | [u8; 32] |
......@@ -394,8 +391,6 @@ chunk_hash := Last block hash of the chunk.
| 0000_0001 | SYNC |
| 0000_0010 | ASK_SYNC_CHUNK |
| 0000_0100 | RES_SYNC_CHUNK |
| ... | ... |
| 1000_0000 | EXTENDED |
SYNC := Boolean indicating whether the connection corresponds to a synchronization request or not. In case of a synchronization request, the connection will necessarily be accepted but temporary. Whereas in the normal case the connection may or may not be accepted according to classic ws2p rules, but it will be permanent.
......@@ -403,8 +398,6 @@ ASK_SYNC_CHUNK := So that the synchronization is not too slow, the nodes to whic
RES_SYNC_CHUNK := A WS2P Public node that asks to synchronize sends its PeerCard to the network, which can then contact it spontaneously to send chunk, the node in synchronization will accept in priority this type of connections.
EXTENDED := Indicates that the field contain one additional byte to store 8 more features.
### ACK message
| data name | size in bytes | data type |
......@@ -418,7 +411,8 @@ challenge_sig := Signature of the challenge given by the other node.
| data name | size in bytes | data type |
|:-------------:|---------------|-----------------|
| flags | 1/+ | WS2PSecretFlags |
| flags_size | 1 | u8 |
| flags | flags_size | WS2PSecretFlags |
| member_proof | 64 | [u8; 64] |
| member_pubkey | 32 | [u8; 32] |
......@@ -429,8 +423,6 @@ challenge_sig := Signature of the challenge given by the other node.
| 0000_0001 | LOW_FLOW_DEMAND |
| 0000_0010 | MEMBER_PUBKEY |
| 0000_0100 | MEMBER_PROOF |
| ... | ... |
| 1000_0000 | EXTENDED |
LOW_FLOW_DEMAND := The sender node of this message indicates that it's behind a low speed connection and therefore care must be taken to transmit low volumes of data to it.
......@@ -439,8 +431,6 @@ MEMBER_PUBKEY: Indicates whether or not the member_pubkey field is present in th
MEMBER_PROOF := Indicates that the message contains proof that the sender node is a member. If this boolean is false, then the member_proof field must not be present.
If this boolean is true, the "member_proof" must contain a signature must sign the following datas :
EXTENDED := Indicates that the field contain one additional byte to store 8 more features.
| data name | size in bytes | data type |
|:--------------:|---------------|-----------|
| flags | 2 | b16 |
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment