diff --git a/crates/shadowsocks/src/net/tcp.rs b/crates/shadowsocks/src/net/tcp.rs index 09fce110db27..d2d5b8e59745 100644 --- a/crates/shadowsocks/src/net/tcp.rs +++ b/crates/shadowsocks/src/net/tcp.rs @@ -135,6 +135,14 @@ impl TcpListener { pub async fn bind_with_opts(addr: &SocketAddr, accept_opts: AcceptOpts) -> io::Result { let socket = create_inbound_tcp_socket(addr, &accept_opts).await?; + if accept_opts.tcp.send_buffer_size > Some(0) { + socket.set_send_buffer_size(accept_opts.tcp.send_buffer_size.unwrap())?; + } + + if accept_opts.tcp.recv_buffer_size > Some(0) { + socket.set_recv_buffer_size(accept_opts.tcp.recv_buffer_size.unwrap())?; + } + // On platforms with Berkeley-derived sockets, this allows to quickly // rebind a socket, without needing to wait for the OS to clean up the // previous one.