Pass Clippy and ignore shutdown error
The client might close the connection before the server noticed. So we simply ignore the error thrown by the shutdown operation.
This commit is contained in:
parent
2c2509a178
commit
4352050b04
@ -41,7 +41,7 @@ impl Server {
|
|||||||
let default = proxy.default.clone().unwrap_or_else(|| "ban".to_string());
|
let default = proxy.default.clone().unwrap_or_else(|| "ban".to_string());
|
||||||
let upstream = config.upstream.clone();
|
let upstream = config.upstream.clone();
|
||||||
let mut upstream_set: HashSet<String> = HashSet::new();
|
let mut upstream_set: HashSet<String> = HashSet::new();
|
||||||
for (key, _) in &upstream {
|
for key in upstream.keys() {
|
||||||
if key.eq("ban") || key.eq("echo") {
|
if key.eq("ban") || key.eq("echo") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -200,7 +200,7 @@ where
|
|||||||
{
|
{
|
||||||
match io::copy(reader, writer).await {
|
match io::copy(reader, writer).await {
|
||||||
Ok(u64) => {
|
Ok(u64) => {
|
||||||
writer.shutdown().await?;
|
let _ = writer.shutdown().await;
|
||||||
Ok(u64)
|
Ok(u64)
|
||||||
}
|
}
|
||||||
Err(_) => Ok(0),
|
Err(_) => Ok(0),
|
||||||
|
@ -7,52 +7,43 @@ use tls_parser::{
|
|||||||
pub fn get_sni(buf: &[u8]) -> Vec<String> {
|
pub fn get_sni(buf: &[u8]) -> Vec<String> {
|
||||||
let mut snis: Vec<String> = Vec::new();
|
let mut snis: Vec<String> = Vec::new();
|
||||||
match parse_tls_raw_record(buf) {
|
match parse_tls_raw_record(buf) {
|
||||||
Ok((_, ref r)) => {
|
Ok((_, ref r)) => match parse_tls_record_with_header(r.data, &r.hdr) {
|
||||||
match parse_tls_record_with_header(r.data, &r.hdr) {
|
Ok((_, ref msg_list)) => {
|
||||||
Ok((_, ref msg_list)) => {
|
for msg in msg_list {
|
||||||
for msg in msg_list {
|
if let TlsMessage::Handshake(TlsMessageHandshake::ClientHello(ref content)) =
|
||||||
match *msg {
|
*msg
|
||||||
TlsMessage::Handshake(ref m) => match *m {
|
{
|
||||||
TlsMessageHandshake::ClientHello(ref content) => {
|
debug!("TLS ClientHello version: {}", content.version);
|
||||||
debug!("TLS ClientHello version: {}", content.version);
|
let ext = parse_tls_extensions(content.ext.unwrap_or(b""));
|
||||||
let ext = parse_tls_extensions(content.ext.unwrap_or(b""));
|
match ext {
|
||||||
match ext {
|
Ok((_, ref extensions)) => {
|
||||||
Ok((_, ref extensions)) => {
|
for ext in extensions {
|
||||||
for ext in extensions {
|
if let tls_parser::TlsExtension::SNI(ref v) = *ext {
|
||||||
match *ext {
|
for &(t, sni) in v {
|
||||||
tls_parser::TlsExtension::SNI(ref v) => {
|
match String::from_utf8(sni.to_vec()) {
|
||||||
for &(t, sni) in v {
|
Ok(s) => {
|
||||||
match String::from_utf8(sni.to_vec()) {
|
debug!("TLS SNI: {} {}", t, s);
|
||||||
Ok(s) => {
|
snis.push(s);
|
||||||
debug!("TLS SNI: {} {}", t, s);
|
}
|
||||||
snis.push(s);
|
Err(e) => {
|
||||||
}
|
warn!("Failed to parse SNI: {} {}", t, e);
|
||||||
Err(e) => {
|
|
||||||
warn!("Failed to parse SNI: {} {}", t, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
|
||||||
warn!("TLS extensions error: {}", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
}
|
||||||
},
|
Err(e) => {
|
||||||
_ => {}
|
warn!("TLS extensions error: {}", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
|
||||||
warn!("Failed to parse TLS: {}", err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
Err(err) => {
|
||||||
|
warn!("Failed to parse TLS: {}", err);
|
||||||
|
}
|
||||||
|
},
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!("Failed to parse TLS: {}", err);
|
warn!("Failed to parse TLS: {}", err);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user