solved requested changes

enhance error handling for TLS connections and improve attack detection
This commit is contained in:
Noor 2025-01-02 15:00:20 +00:00
parent 9e9036280d
commit 3bdae474b1
Signed by: noormohammedb
GPG Key ID: 7680BB1B83C6A443

@ -93,13 +93,9 @@ impl NodeServer {
let conn = if let Err(e) = conn { let conn = if let Err(e) = conn {
println!("Error accepting TLS connection: {e}"); println!("Error accepting TLS connection: {e}");
let attack_error_messages = [ let attack_error_messages = ["handshake", "certificate", "quote"];
"HandshakeFailure",
"peer sent no certificates", // "NoCertificatesPresented",
"Not found quote extension",
];
let err_str = e.to_string(); let err_str = e.to_string().to_lowercase();
if attack_error_messages.iter().any(|att_er_str| err_str.contains(att_er_str)) { if attack_error_messages.iter().any(|att_er_str| err_str.contains(att_er_str)) {
state.increase_net_attacks().await; state.increase_net_attacks().await;
} }
@ -204,6 +200,7 @@ impl Update for NodeServer {
yield Ok(update.update); yield Ok(update.update);
} }
// TODO: check if disconnect client if too many connections are active // TODO: check if disconnect client if too many connections are active
// Its tested and working
if tx.receiver_count() > 9 { if tx.receiver_count() > 9 {
error_status = Status::internal("Already have too many clients. Connect to another server."); error_status = Status::internal("Already have too many clients. Connect to another server.");
break; break;