Skip to content
Snippets Groups Projects
Commit 2fe0ea46 authored by Éloïs's avatar Éloïs
Browse files

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

parent e493ddcb
No related branches found
No related tags found
1 merge request!8WIP: WS2P v2
...@@ -161,8 +161,10 @@ _*the `null` value is essential, it allows the user to synchronize his node with ...@@ -161,8 +161,10 @@ _*the `null` value is essential, it allows the user to synchronize his node with
| path_size | 1 | u8 | | path_size | 1 | u8 |
| api_name | 1/api_size | specific | | api_name | 1/api_size | specific |
| api_version | 2 | u16 | | api_version | 2 | u16 |
| network_features | 2/+ | specific | | nf_size | 1 | u8 |
| api_features | 2/+ | specific | | network_features | nf_size | specific |
| af_size | 1 | u8 |
| api_features | af_size | specific |
| ip_v4 | 4 | [u8; 4] | | ip_v4 | 4 | [u8; 4] |
| ip_v6 | 16 | [u16; 8] | | ip_v6 | 16 | [u16; 8] |
| host | host_size | utf8 | | host | host_size | utf8 |
...@@ -189,13 +191,11 @@ The 16 bits represent booleans to define the presence or absence of 16 network f ...@@ -189,13 +191,11 @@ The 16 bits represent booleans to define the presence or absence of 16 network f
Network features : Network features :
| bit | feature | | bit | feature |
|:-------------------:|----------| |:---------:|----------|
| 0000_0000 0000_0001 | ip_v4 | | 0000_0001 | ip_v4 |
| 0000_0000 0000_0010 | ip_v6 | | 0000_0010 | ip_v6 |
| 0000_0000 0000_0100 | S | | 0000_0100 | S |
| 0000_0000 0000_1000 | TOR | | 0000_1000 | TOR |
| ... | ... |
| 1000_0000 0000_0000 | EXTENDED |
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. 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,8 +203,6 @@ S := This feature indicates that the endpoint should be contacted with an SSL/TL ...@@ -203,8 +203,6 @@ 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). 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 #### 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 : The interpretation of this field depends on the API because it represents API-specific features. Here is the interpretation for the WS2P API :
...@@ -212,12 +210,10 @@ The interpretation of this field depends on the API because it represents API-sp ...@@ -212,12 +210,10 @@ The interpretation of this field depends on the API because it represents API-sp
WS2PFeatures type definition : WS2PFeatures type definition :
| bit | feature | | bit | feature |
|:-------------------:|-----------| |:----- ---:|-----------|
| 0000_0000 0000_0001 | DEFLATE | | 0000_0001 | DEFLATE |
| 0000_0000 0000_0010 | LOW | | 0000_0010 | LOW |
| 0000_0000 0000_0100 | RBF | | 0000_0100 | RBF |
| ... | ... |
| 1000_0000 0000_0000 | EXTENDED |
DEFLATE := Supports permessage-deflate extension DEFLATE := Supports permessage-deflate extension
...@@ -225,9 +221,7 @@ LOW := Accept low speed connection requests ...@@ -225,9 +221,7 @@ LOW := Accept low speed connection requests
RBF := Accept rust binary format 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 8 features. The 5 free bits can be used for future versions of WS2P.
WS2P v2 uses only 3 of 16 features. The 13 free bits can be used for future versions of WS2P.
### Endpoint utf8 format ### Endpoint utf8 format
...@@ -254,7 +248,8 @@ Same endpoint in binary format : ...@@ -254,7 +248,8 @@ Same endpoint in binary format :
| api_name | 1/api_size | specific | 0x01 | | api_name | 1/api_size | specific | 0x01 |
| api_version | 2 | u16 | 0x0002 | | api_version | 2 | u16 | 0x0002 |
| network_features | 2 | specific | 0x0004 | | 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_v4 | 4 | [u8; 4] | None |
| ip_v6 | 16 | [u16; 8] | None | | ip_v6 | 16 | [u16; 8] | None |
| host | host_size | utf8 | "g1.durs.ifee.fr" encoded in utf8 | | host | host_size | utf8 | "g1.durs.ifee.fr" encoded in utf8 |
...@@ -368,8 +363,10 @@ for each connection attempt, the process is as follows: ...@@ -368,8 +363,10 @@ for each connection attempt, the process is as follows:
| data name | size in bytes | data type | | data name | size in bytes | data type |
|:-------------:|---------------|--------------| |:-------------:|---------------|--------------|
| challenge | 32 | [u8; 32] | | challenge | 32 | [u8; 32] |
| api_features | 2/+ | WS2PFeatures | | af_size | 1 | u8 |
| flags_queries | 1/+ | WS2PFlags | | api_features | af_size | WS2PFeatures |
| flags_size | 1 | u8 |
| flags_queries | flags_size | WS2PFlags |
| peer_card | ? | Peer card | | peer_card | ? | Peer card |
| chunk_id* | 4 | u32 | | chunk_id* | 4 | u32 |
| chunk_hash* | 32 | [u8; 32] | | chunk_hash* | 32 | [u8; 32] |
...@@ -394,8 +391,6 @@ chunk_hash := Last block hash of the chunk. ...@@ -394,8 +391,6 @@ chunk_hash := Last block hash of the chunk.
| 0000_0001 | SYNC | | 0000_0001 | SYNC |
| 0000_0010 | ASK_SYNC_CHUNK | | 0000_0010 | ASK_SYNC_CHUNK |
| 0000_0100 | RES_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. 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 ...@@ -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. 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 ### ACK message
| data name | size in bytes | data type | | data name | size in bytes | data type |
...@@ -418,7 +411,8 @@ challenge_sig := Signature of the challenge given by the other node. ...@@ -418,7 +411,8 @@ challenge_sig := Signature of the challenge given by the other node.
| data name | size in bytes | data type | | data name | size in bytes | data type |
|:-------------:|---------------|-----------------| |:-------------:|---------------|-----------------|
| flags | 1/+ | WS2PSecretFlags | | flags_size | 1 | u8 |
| flags | flags_size | WS2PSecretFlags |
| member_proof | 64 | [u8; 64] | | member_proof | 64 | [u8; 64] |
| member_pubkey | 32 | [u8; 32] | | member_pubkey | 32 | [u8; 32] |
...@@ -429,8 +423,6 @@ challenge_sig := Signature of the challenge given by the other node. ...@@ -429,8 +423,6 @@ challenge_sig := Signature of the challenge given by the other node.
| 0000_0001 | LOW_FLOW_DEMAND | | 0000_0001 | LOW_FLOW_DEMAND |
| 0000_0010 | MEMBER_PUBKEY | | 0000_0010 | MEMBER_PUBKEY |
| 0000_0100 | MEMBER_PROOF | | 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. 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 ...@@ -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. 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 : 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 | | data name | size in bytes | data type |
|:--------------:|---------------|-----------| |:--------------:|---------------|-----------|
| flags | 2 | b16 | | flags | 2 | b16 |
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment