mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-11-25 00:05:24 +00:00
fixed length too short bug
This commit is contained in:
+17
-17
@@ -137,27 +137,27 @@ impl TcpRelayLocal {
|
||||
(header_buf.slice_to(header_len), addr)
|
||||
};
|
||||
|
||||
let mut remote_stream = TcpStream::connect(server_addr.ip.to_string().as_slice(),
|
||||
server_addr.port).unwrap_or_else(|err| {
|
||||
match err.kind {
|
||||
ConnectionAborted | ConnectionReset | ConnectionRefused | ConnectionFailed => {
|
||||
send_error_reply(&mut stream, SOCKS5_REPLY_HOST_UNREACHABLE);
|
||||
},
|
||||
_ => {
|
||||
send_error_reply(&mut stream, SOCKS5_REPLY_NETWORK_UNREACHABLE);
|
||||
}
|
||||
}
|
||||
panic!("Failed to connect remote server: {}", err);
|
||||
});
|
||||
|
||||
let mut cipher = cipher::with_name(encrypt_method.as_slice(),
|
||||
password.as_slice().as_bytes())
|
||||
.expect("Unsupported cipher");
|
||||
|
||||
match cmd {
|
||||
SOCKS5_CMD_TCP_CONNECT => {
|
||||
info!("CONNECT {}", addr);
|
||||
|
||||
let mut remote_stream = TcpStream::connect(server_addr.ip.to_string().as_slice(),
|
||||
server_addr.port).unwrap_or_else(|err| {
|
||||
match err.kind {
|
||||
ConnectionAborted | ConnectionReset | ConnectionRefused | ConnectionFailed => {
|
||||
send_error_reply(&mut stream, SOCKS5_REPLY_HOST_UNREACHABLE);
|
||||
},
|
||||
_ => {
|
||||
send_error_reply(&mut stream, SOCKS5_REPLY_NETWORK_UNREACHABLE);
|
||||
}
|
||||
}
|
||||
panic!("Failed to connect remote server: {}", err);
|
||||
});
|
||||
|
||||
let mut cipher = cipher::with_name(encrypt_method.as_slice(),
|
||||
password.as_slice().as_bytes())
|
||||
.expect("Unsupported cipher");
|
||||
|
||||
{
|
||||
let reply_header = [SOCKS5_VERSION, SOCKS5_REPLY_SUCCEEDED, 0x00];
|
||||
stream.write(reply_header)
|
||||
|
||||
@@ -185,7 +185,7 @@ fn handle_request(mut socket: UdpSocket,
|
||||
(data.slice_to(header_len), addr)
|
||||
};
|
||||
|
||||
info!("UDP ASSOCIATE {}", from_addr);
|
||||
info!("UDP ASSOCIATE {}", addr);
|
||||
debug!("UDP associate {} <-> {}", addr, from_addr);
|
||||
|
||||
client_map.lock().put(addr, from_addr);
|
||||
|
||||
@@ -59,11 +59,6 @@ impl UdpRelayServer {
|
||||
loop {
|
||||
match socket.recv_from(buf) {
|
||||
Ok((len, src)) => {
|
||||
if len < 4 {
|
||||
error!("UDP request is too short");
|
||||
continue;
|
||||
}
|
||||
|
||||
let data = buf.slice_to(len).to_vec();
|
||||
let client_map = client_map_arc.clone();
|
||||
let remote_map = remote_map_arc.clone();
|
||||
|
||||
Reference in New Issue
Block a user