From fbc5f3c649e8af06db9f3043574e4c19695172ed Mon Sep 17 00:00:00 2001 From: librelois <elois@ifee.fr> Date: Sat, 8 Sep 2018 18:51:57 +0200 Subject: [PATCH] [ref] ws2pv2: FLAGS Msg : rename and change fields order --- rfc/0006_ws2p_v2.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/rfc/0006_ws2p_v2.md b/rfc/0006_ws2p_v2.md index 04c37fd..314053d 100644 --- a/rfc/0006_ws2p_v2.md +++ b/rfc/0006_ws2p_v2.md @@ -40,7 +40,7 @@ We are also taking advantage of these changes to address minor issues : * [List of accepted v1 messages](#list-of-accepted-v1-messages) * [CONNECT Message](#connect-message) * [ACK Message](#ack-message) - * [FLAGS Message](#flags-message) + * [SECRET FLAGS Message](#secret-flags-message) * [OK Message](#ok-message) * [Rules for accepting an incoming connection](#rules-for-accepting-an-incoming-connection) * [WS2Pv2 Messages](#ws2pv2-messages) @@ -438,16 +438,20 @@ In case of equality, the order in which the endpoints will be contacted will dep After sorting all WS2P endpoints according to the criteria described in the previous section, Duniter tries to connect to the other nodes. -for each connection attempt, the process is as follows: +for each connection attempt, the process is as follows for initiator : 1. Opening a websocket pointing to the remote endpoint. If the websocket has been successfully opened before the timeout*, send a CONNECT message. Otherwise, log the error and close the websocket. 2. Wait to receive a CONNECT message from the remote node, checking the validity. If the CONNECT message is valid, then sending an ACK message. Otherwise, log the error and close the websocket. -3. Wait to receive an ACK message from the remote node, checking the validity. If the ACK message is valid, then sending a FLAGS message. Otherwise, log the error and close the websocket. -4. Wait to receive a FLAGS message from the remote node, checking the validity. If the FLAGS message is valid, then sending an OK message. Otherwise, log the error and close the websocket. -5. Wait to receive an OK message from the remote node, checking the validity. If the OK message is valid, then consider the ws2p connection completely established. Otherwise, log the error and close the websocket. +3. Wait to receive an ACK message from the remote node, checking the validity. If the ACK message is valid, then sending a SECRET_FLAGS/OK message. Otherwise, log the error and close the websocket. +4. Wait to receive a SECRET_FLAGS/OK message from the remote node, checking the validity. If the message is valid, then sending a SECRET_FLAGS/OK message. Otherwise, log the error and close the websocket. If the receiving message is OK and sending OK message too, skip step 4 and consider the ws2p connection completely established. +5. Wait to receive an OK message from the remote node, checking the validity. If the OK message is valid, then sending an OK message and consider the ws2p connection completely established. Otherwise, log the error and close the websocket. *timeout : 15 seconds for connection to a conventional endpoint. 30 seconds for connection to a hidden tor service. +For the remote node, only the first step change : + +1. Sudden receipt of a CONNECT message. If the CONNECT message is valid, then sending my own CONNECT message and an ACK message at the same time. Otherwise, log the error and close the websocket. + WARNING: independently of all these rules, each implementation must integrate its own anti-spam protections. Any connection can be rejected if the situation requires it (attack by denial of service for example). ### CONNECT message @@ -502,14 +506,14 @@ Each node must sign the challenge of the other to prove that it's in possession challenge := The challenge given by the other node in their CONNECt message. The message is already signed at the container level, so there is no need to repeat the signature in the ACK message payload. On the other hand, the challenge to be signed must be in the payload. -### FLAGS message +### SECRET FLAGS message | data name | size in bytes | data type | |:-------------:|---------------|-----------------| | flags_size | 1 | u8 | | flags | flags_size | WS2PSecretFlags | -| member_proof | ? | SigBox | | member_pubkey | ? | PubkeyBox | +| member_proof | ? | SigBox | #### WS2PSecretFlags type definition -- GitLab