Compare commits

...

3 Commits

Author SHA1 Message Date
3be12f7807 solved requested changes
enhance error handling for TLS connections and improve attack detection
2025-01-06 16:36:11 +00:00
e86ee534ed handle TLS attack
included net attack count on non supported tls connection
counted as attack for tls without client cert and missing quote on tls client cert
2025-01-06 16:36:11 +00:00
ad9c445fe5
saving node information while heartbeating 2025-01-02 17:09:39 +00:00
2 changed files with 8 additions and 2 deletions

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

@ -55,7 +55,9 @@ pub async fn heartbeat(
state.remove_inactive_nodes().await;
let connected_ips = state.get_connected_ips().await;
println!("Connected nodes ({}): {:?}", connected_ips.len(), connected_ips);
let _ = tx.send((state.get_my_ip().await, state.get_my_info().await).into());
let my_node_info = state.get_my_info().await;
my_node_info.save();
let _ = tx.send((state.get_my_ip().await, my_node_info).into());
if connected_ips.len() < NUM_CONNECTIONS {
if let Some(node_ip) = state.get_random_disconnected_ip().await {
println!("Dialing random node {}", node_ip);