diff --git a/src/cgw_connection_processor.rs b/src/cgw_connection_processor.rs index 90feab9..e728148 100644 --- a/src/cgw_connection_processor.rs +++ b/src/cgw_connection_processor.rs @@ -107,7 +107,24 @@ impl CGWConnectionProcessor { client_cn: MacAddress, allow_mismatch: bool, ) -> Result<()> { - let ws_stream = tokio_tungstenite::accept_async(tls_stream).await?; + let ws_stream = tokio::select! { + _val = tokio_tungstenite::accept_async(tls_stream) => { + match _val { + Ok(s) => s, + Err(e) => { + error!("Failed to accept TLS stream from: {}! Reason: {}. Closing connection", + self.addr, e); + return Err(Error::ConnectionProcessor("Failed to accept TLS stream!")); + } + } + } + // TODO: configurable duration (upon server creation) + _val = sleep(Duration::from_millis(15000)) => { + error!("Failed to accept TLS stream from: {}! Closing connection", self.addr); + return Err(Error::ConnectionProcessor("Failed to accept TLS stream for too long")); + } + + }; let (sink, mut stream) = ws_stream.split(); diff --git a/src/cgw_ucentral_switch_parser.rs b/src/cgw_ucentral_switch_parser.rs index ece37cf..0c7d70a 100644 --- a/src/cgw_ucentral_switch_parser.rs +++ b/src/cgw_ucentral_switch_parser.rs @@ -5,10 +5,10 @@ use std::{collections::HashMap, str::FromStr}; use crate::cgw_errors::{Error, Result}; use crate::cgw_ucentral_parser::{ - CGWUCentralEvent, CGWUCentralEventLog, CGWUCentralEventState, CGWUCentralEventStateClients, - CGWUCentralEventStateClientsData, CGWUCentralEventStateClientsType, - CGWUCentralEventStateLLDPData, CGWUCentralEventStateLinks, CGWUCentralEventStatePort, - CGWUCentralEventType, CGWUCentralJRPCMessage, CGWUCentralEventReply + CGWUCentralEvent, CGWUCentralEventLog, CGWUCentralEventReply, CGWUCentralEventState, + CGWUCentralEventStateClients, CGWUCentralEventStateClientsData, + CGWUCentralEventStateClientsType, CGWUCentralEventStateLLDPData, CGWUCentralEventStateLinks, + CGWUCentralEventStatePort, CGWUCentralEventType, CGWUCentralJRPCMessage, }; fn parse_lldp_data(