Skip to content
Snippets Groups Projects

Resolve "WS2Pv1 does not resist network problems when negotiating a connection"

3 files
+ 23
5
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -231,11 +231,16 @@ impl WS2PModuleDatas {
@@ -231,11 +231,16 @@ impl WS2PModuleDatas {
self.connect_to_without_checking_quotas(&endpoint);
self.connect_to_without_checking_quotas(&endpoint);
}
}
}
}
fn close_connection(&mut self, ws2p_full_id: &NodeFullId, reason: WS2PCloseConnectionReason) {
pub fn close_connection(
 
&mut self,
 
ws2p_full_id: &NodeFullId,
 
reason: WS2PCloseConnectionReason,
 
) {
match reason {
match reason {
WS2PCloseConnectionReason::NegociationTimeout => {}
WS2PCloseConnectionReason::NegociationTimeout => {}
WS2PCloseConnectionReason::AuthMessInvalidSig
WS2PCloseConnectionReason::AuthMessInvalidSig
| WS2PCloseConnectionReason::Timeout
| WS2PCloseConnectionReason::Timeout
 
| WS2PCloseConnectionReason::WsError
| WS2PCloseConnectionReason::Unknow => {
| WS2PCloseConnectionReason::Unknow => {
self.ws2p_endpoints
self.ws2p_endpoints
.get_mut(ws2p_full_id)
.get_mut(ws2p_full_id)
@@ -285,12 +290,16 @@ impl WS2PModuleDatas {
@@ -285,12 +290,16 @@ impl WS2PModuleDatas {
.expect("Endpoint don't exist !")
.expect("Endpoint don't exist !")
.1 = WS2PConnectionState::ConnectMessOk;
.1 = WS2PConnectionState::ConnectMessOk;
debug!("Send: {:#?}", response);
debug!("Send: {:#?}", response);
self.websockets
if self
 
.websockets
.get_mut(&ws2p_full_id)
.get_mut(&ws2p_full_id)
.unwrap_or_else(|| panic!("Fatal error : no websocket for {} !", ws2p_full_id))
.unwrap_or_else(|| panic!("Fatal error : no websocket for {} !", ws2p_full_id))
.0
.0
.send(Message::text(response))
.send(Message::text(response))
.expect("WS2P: Fail to send OK Message !");
.is_err()
 
{
 
return WS2PSignal::WSError(ws2p_full_id);
 
}
}
}
WS2PConnectionMessagePayload::ValidAckMessage(r, new_con_state) => {
WS2PConnectionMessagePayload::ValidAckMessage(r, new_con_state) => {
self.ws2p_endpoints
self.ws2p_endpoints
@@ -299,14 +308,18 @@ impl WS2PModuleDatas {
@@ -299,14 +308,18 @@ impl WS2PModuleDatas {
.1 = new_con_state;
.1 = new_con_state;
if let WS2PConnectionState::AckMessOk = self.ws2p_endpoints[&ws2p_full_id].1 {
if let WS2PConnectionState::AckMessOk = self.ws2p_endpoints[&ws2p_full_id].1 {
trace!("Send: {:#?}", r);
trace!("Send: {:#?}", r);
self.websockets
if self
 
.websockets
.get_mut(&ws2p_full_id)
.get_mut(&ws2p_full_id)
.unwrap_or_else(|| {
.unwrap_or_else(|| {
panic!("Fatal error : no websocket for {} !", ws2p_full_id)
panic!("Fatal error : no websocket for {} !", ws2p_full_id)
})
})
.0
.0
.send(Message::text(r))
.send(Message::text(r))
.expect("WS2P: Fail to send Message in websocket !");
.is_err()
 
{
 
return WS2PSignal::WSError(ws2p_full_id);
 
}
}
}
}
}
WS2PConnectionMessagePayload::ValidOk(new_con_state) => {
WS2PConnectionMessagePayload::ValidOk(new_con_state) => {
Loading