diff --git a/clients/client-core/src/client/received_buffer.rs b/clients/client-core/src/client/received_buffer.rs index db67cc6592..3c2540f0d6 100644 --- a/clients/client-core/src/client/received_buffer.rs +++ b/clients/client-core/src/client/received_buffer.rs @@ -207,7 +207,7 @@ impl ReceivedMessagesBuffer { // TODO: perhaps having to say it doesn't have a surb an indication the type should be changed? Some(ReconstructedMessage { message: reply_msg, - reply_SURB: None, + reply_surb: None, }) } } diff --git a/clients/native/examples/go-examples/websocket/binarysend.go b/clients/native/examples/go-examples/websocket/binarysend.go index bc9d1cafa9..f16b41f5ba 100644 --- a/clients/native/examples/go-examples/websocket/binarysend.go +++ b/clients/native/examples/go-examples/websocket/binarysend.go @@ -43,7 +43,6 @@ func makeSendRequest(recipient []byte, message []byte, withReplySurb bool) []byt out = append(out, messageLen...) out = append(out, message...) - fmt.Println("first send req: ", out[:10]) return out } diff --git a/clients/native/examples/go-examples/websocket/textsend.go b/clients/native/examples/go-examples/websocket/textsend.go index 900ac407f1..376b3df1ca 100644 --- a/clients/native/examples/go-examples/websocket/textsend.go +++ b/clients/native/examples/go-examples/websocket/textsend.go @@ -103,13 +103,13 @@ func sendWithReply() { } // use the received surb to send an anonymous reply! - replySURB := receivedMessageJson["replySURB"] + replySurb := receivedMessageJson["replySurb"] replyMessage := "hello from reply SURB!" reply, err := json.Marshal(map[string]interface{}{ "type": "reply", "message": replyMessage, - "replySURB": replySURB, + "replySurb": replySurb, }) if err != nil { panic(err) diff --git a/clients/native/examples/python-examples/websocket/textsend.py b/clients/native/examples/python-examples/websocket/textsend.py index 51ef03adb0..35ba8f9852 100644 --- a/clients/native/examples/python-examples/websocket/textsend.py +++ b/clients/native/examples/python-examples/websocket/textsend.py @@ -55,13 +55,13 @@ async def send_text_with_reply(): print("received '{}' from the mix network".format(received_message)) # use the received surb to send an anonymous reply! - reply_surb = received_message["replySURB"] + reply_surb = received_message["replySurb"] reply_message = "hello from reply SURB!" reply = json.dumps({ "type": "reply", "message": reply_message, - "replySURB": reply_surb + "replySurb": reply_surb }) print("sending '{}' (using reply SURB!) over the mix network...".format(reply_message)) diff --git a/clients/native/examples/websocket_binarysend.rs b/clients/native/examples/websocket_binarysend.rs index 7f0830edb4..2a2726dd03 100644 --- a/clients/native/examples/websocket_binarysend.rs +++ b/clients/native/examples/websocket_binarysend.rs @@ -57,7 +57,7 @@ async fn send_file_with_reply() { let reply_message = b"hello from reply SURB! - thanks for sending me the file!".to_vec(); let reply_request = ClientRequest::Reply { message: reply_message.clone(), - reply_surb: received.reply_SURB.unwrap(), + reply_surb: received.reply_surb.unwrap(), }; println!( diff --git a/clients/native/examples/websocket_textsend.rs b/clients/native/examples/websocket_textsend.rs index 52ecc02640..7aa5bc5bec 100644 --- a/clients/native/examples/websocket_textsend.rs +++ b/clients/native/examples/websocket_textsend.rs @@ -54,7 +54,7 @@ async fn send_text_with_reply() { let reply_request = json!({ "type": "reply", "message": reply_message, - "replySURB": response["replySURB"] + "replySurb": response["replySurb"] }); println!( diff --git a/clients/native/websocket-requests/src/responses.rs b/clients/native/websocket-requests/src/responses.rs index e3ccfc209f..235ddf9189 100644 --- a/clients/native/websocket-requests/src/responses.rs +++ b/clients/native/websocket-requests/src/responses.rs @@ -50,7 +50,7 @@ impl ServerResponse { // RECEIVED_RESPONSE_TAG || with_reply || (surb_len || surb) || msg_len || msg fn serialize_received(reconstructed_message: ReconstructedMessage) -> Vec { let message_len_bytes = (reconstructed_message.message.len() as u64).to_be_bytes(); - if let Some(reply_surb) = reconstructed_message.reply_SURB { + if let Some(reply_surb) = reconstructed_message.reply_surb { let reply_surb_bytes = reply_surb.to_bytes(); let surb_len_bytes = (reply_surb_bytes.len() as u64).to_be_bytes(); @@ -141,7 +141,7 @@ impl ServerResponse { Ok(ServerResponse::Received(ReconstructedMessage { message: message.to_vec(), - reply_SURB: Some(reply_surb), + reply_surb: Some(reply_surb), })) } else { let message_len = @@ -160,7 +160,7 @@ impl ServerResponse { Ok(ServerResponse::Received(ReconstructedMessage { message: message.to_vec(), - reply_SURB: None, + reply_surb: None, })) } } @@ -341,7 +341,7 @@ mod tests { let received_with_surb = ServerResponse::Received(ReconstructedMessage { message: b"foomp".to_vec(), - reply_SURB: Some(ReplySURB::from_base58_string(reply_surb_string).unwrap()), + reply_surb: Some(ReplySURB::from_base58_string(reply_surb_string).unwrap()), }); let bytes = received_with_surb.serialize(); let recovered = ServerResponse::deserialize(&bytes).unwrap(); @@ -349,7 +349,7 @@ mod tests { ServerResponse::Received(reconstructed) => { assert_eq!(reconstructed.message, b"foomp".to_vec()); assert_eq!( - reconstructed.reply_SURB.unwrap().to_base58_string(), + reconstructed.reply_surb.unwrap().to_base58_string(), reply_surb_string ) } @@ -358,14 +358,14 @@ mod tests { let received_without_surb = ServerResponse::Received(ReconstructedMessage { message: b"foomp".to_vec(), - reply_SURB: None, + reply_surb: None, }); let bytes = received_without_surb.serialize(); let recovered = ServerResponse::deserialize(&bytes).unwrap(); match recovered { ServerResponse::Received(reconstructed) => { assert_eq!(reconstructed.message, b"foomp".to_vec()); - assert!(reconstructed.reply_SURB.is_none()) + assert!(reconstructed.reply_surb.is_none()) } _ => unreachable!(), } diff --git a/clients/native/websocket-requests/src/text.rs b/clients/native/websocket-requests/src/text.rs index 0a33c29ac5..806c58edd1 100644 --- a/clients/native/websocket-requests/src/text.rs +++ b/clients/native/websocket-requests/src/text.rs @@ -23,7 +23,6 @@ use std::convert::{TryFrom, TryInto}; // local text equivalent of `ClientRequest` for easier serialization + deserialization with serde // TODO: figure out if there's an easy way to avoid defining it -#[allow(non_snake_case)] #[derive(Serialize, Deserialize, Debug)] #[serde(tag = "type", rename_all = "camelCase")] pub(super) enum ClientRequestText { @@ -37,7 +36,7 @@ pub(super) enum ClientRequestText { #[serde(rename_all = "camelCase")] Reply { message: String, - reply_SURB: String, + reply_surb: String, }, } @@ -73,10 +72,10 @@ impl TryInto for ClientRequestText { ClientRequestText::SelfAddress => Ok(ClientRequest::SelfAddress), ClientRequestText::Reply { message, - reply_SURB, + reply_surb, } => { let message_bytes = message.into_bytes(); - let reply_surb = ReplySURB::from_base58_string(reply_SURB).map_err(|err| { + let reply_surb = ReplySURB::from_base58_string(reply_surb).map_err(|err| { Self::Error::new(ErrorKind::MalformedRequest, err.to_string()) })?; @@ -92,14 +91,13 @@ impl TryInto for ClientRequestText { // local text equivalent of `ServerResponse` for easier serialization + deserialization with serde // TODO: figure out if there's an easy way to avoid defining it -#[allow(non_snake_case)] #[derive(Serialize, Deserialize, Debug)] #[serde(tag = "type", rename_all = "camelCase")] pub(super) enum ServerResponseText { #[serde(rename_all = "camelCase")] Received { message: String, - reply_SURB: Option, + reply_surb: Option, }, SelfAddress { address: String, @@ -137,8 +135,8 @@ impl From for ServerResponseText { // TODO: ask DH what is more appropriate, lossy utf8 conversion or returning error and then // pure binary later message: String::from_utf8_lossy(&reconstructed.message).into_owned(), - reply_SURB: reconstructed - .reply_SURB + reply_surb: reconstructed + .reply_surb .map(|reply_surb| reply_surb.to_base58_string()), } } diff --git a/clients/socks5/src/socks/mixnet_responses.rs b/clients/socks5/src/socks/mixnet_responses.rs index 34b754ec55..647aac8f37 100644 --- a/clients/socks5/src/socks/mixnet_responses.rs +++ b/clients/socks5/src/socks/mixnet_responses.rs @@ -40,7 +40,7 @@ impl MixnetResponseListener { async fn on_message(&self, reconstructed_message: ReconstructedMessage) { let raw_message = reconstructed_message.message; - if reconstructed_message.reply_SURB.is_some() { + if reconstructed_message.reply_surb.is_some() { warn!("this message had a surb - we didn't do anything with it"); } diff --git a/common/nymsphinx/src/receiver.rs b/common/nymsphinx/src/receiver.rs index 371f951358..8481af1837 100644 --- a/common/nymsphinx/src/receiver.rs +++ b/common/nymsphinx/src/receiver.rs @@ -21,14 +21,13 @@ use nymsphinx_chunking::reconstruction::MessageReconstructor; use nymsphinx_params::{PacketEncryptionAlgorithm, PacketHkdfAlgorithm, DEFAULT_NUM_MIX_HOPS}; // TODO: should this live in this file? -#[allow(non_snake_case)] #[derive(Debug)] pub struct ReconstructedMessage { /// The actual plaintext message that was received. pub message: Vec, /// Optional ReplySURB to allow for an anonymous reply to the sender. - pub reply_SURB: Option, + pub reply_surb: Option, } #[derive(Debug)] @@ -157,9 +156,8 @@ impl MessageReceiver { fragment: Fragment, ) -> Result)>, MessageRecoveryError> { if let Some((mut message, used_sets)) = self.reconstructor.insert_new_fragment(fragment) { - #[allow(non_snake_case)] // Split message into plaintext and reply-SURB - let reply_SURB = match self.recover_reply_surb_from_message(&mut message) { + let reply_surb = match self.recover_reply_surb_from_message(&mut message) { Ok(reply_surb) => reply_surb, Err(_) => { return Err(MessageRecoveryError::MalformedReconstructedMessage( @@ -178,7 +176,7 @@ impl MessageReceiver { Ok(Some(( ReconstructedMessage { message, - reply_SURB, + reply_surb, }, used_sets, )))