Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the behavior of silent dropping replay packets #556

Merged
merged 1 commit into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions crates/shadowsocks/src/relay/tcprelay/aead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use std::{
use byte_string::ByteStr;
use bytes::{BufMut, Bytes, BytesMut};
use futures::ready;
use log::trace;
use log::{trace, warn};
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};

use crate::{
Expand Down Expand Up @@ -223,12 +223,7 @@ impl DecryptedReader {
let salt = self.salt.take().unwrap();

if context.check_nonce_and_set(&salt) {
use std::io::Error;

trace!("detected repeated AEAD salt {:?}", ByteStr::new(&salt));

let err = Error::new(ErrorKind::Other, "detected repeated salt");
return Err(err).into();
warn!("detected repeated AEAD salt {:?}", ByteStr::new(&salt));
}
}

Expand Down
9 changes: 2 additions & 7 deletions crates/shadowsocks/src/relay/tcprelay/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::{
use byte_string::ByteStr;
use bytes::{BufMut, Bytes, BytesMut};
use futures::ready;
use log::trace;
use log::{trace, warn};
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};

use crate::{
Expand Down Expand Up @@ -113,12 +113,7 @@ impl DecryptedReader {

let iv = &self.buffer[..iv_len];
if context.check_nonce_and_set(&iv) {
use std::io::Error;

trace!("detected repeated stream iv {:?}", ByteStr::new(&iv));

let err = Error::new(ErrorKind::Other, "detected repeated iv");
return Err(err).into();
warn!("detected repeated stream iv {:?}", ByteStr::new(&iv));
}

trace!("got stream iv {:?}", ByteStr::new(iv));
Expand Down
8 changes: 3 additions & 5 deletions crates/shadowsocks/src/relay/udprelay/crypto_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use std::io::{self, Cursor, ErrorKind};

use byte_string::ByteStr;
use bytes::{BufMut, BytesMut};
use log::{debug, trace};
use log::{trace, warn};

use crate::{
context::Context,
Expand Down Expand Up @@ -182,8 +182,7 @@ async fn decrypt_payload_stream(

let (iv, data) = payload.split_at_mut(iv_len);
if context.check_nonce_and_set(iv) {
debug!("detected repeated iv {:?}", ByteStr::new(iv));
return Err(io::Error::new(io::ErrorKind::Other, "detected repeated iv"));
warn!("detected repeated iv {:?}", ByteStr::new(iv));
}

trace!("UDP packet got stream IV {:?}", ByteStr::new(iv));
Expand Down Expand Up @@ -215,8 +214,7 @@ async fn decrypt_payload_aead(

let (salt, data) = payload.split_at_mut(salt_len);
if context.check_nonce_and_set(salt) {
debug!("detected repeated salt {:?}", ByteStr::new(salt));
return Err(io::Error::new(io::ErrorKind::Other, "detected repeated salt"));
warn!("detected repeated salt {:?}", ByteStr::new(salt));
}

trace!("UDP packet got AEAD salt {:?}", ByteStr::new(salt));
Expand Down