mirror of
https://github.com/EasyTier/EasyTier.git
synced 2024-11-16 03:32:43 +08:00
fix crash bugs (#64)
This commit is contained in:
parent
6595c2837e
commit
70dee329d1
|
@ -135,6 +135,20 @@ impl PeerConn {
|
||||||
*need_retry = true;
|
*need_retry = true;
|
||||||
|
|
||||||
let rsp = rsp?;
|
let rsp = rsp?;
|
||||||
|
let Some(peer_mgr_hdr) = rsp.peer_manager_header() else {
|
||||||
|
return Err(Error::WaitRespError(format!(
|
||||||
|
"unexpected packet: {:?}, cannot decode peer manager hdr",
|
||||||
|
rsp
|
||||||
|
)));
|
||||||
|
};
|
||||||
|
|
||||||
|
if peer_mgr_hdr.packet_type != PacketType::HandShake as u8 {
|
||||||
|
return Err(Error::WaitRespError(format!(
|
||||||
|
"unexpected packet type: {:?}",
|
||||||
|
peer_mgr_hdr.packet_type
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
let rsp = HandshakeRequest::decode(rsp.payload()).map_err(|e| {
|
let rsp = HandshakeRequest::decode(rsp.payload()).map_err(|e| {
|
||||||
Error::WaitRespError(format!("decode handshake response error: {:?}", e))
|
Error::WaitRespError(format!("decode handshake response error: {:?}", e))
|
||||||
})?;
|
})?;
|
||||||
|
|
|
@ -302,16 +302,20 @@ Endpoint = {listenr_addr} # should be the public ip of the vpn server
|
||||||
async fn list_clients(&self) -> Vec<String> {
|
async fn list_clients(&self) -> Vec<String> {
|
||||||
self.inner
|
self.inner
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.and_then(|w| {
|
||||||
.wg_peer_ip_table
|
Some(
|
||||||
.iter()
|
w.wg_peer_ip_table
|
||||||
.map(|x| {
|
.iter()
|
||||||
x.value()
|
.map(|x| {
|
||||||
.endpoint_addr
|
x.value()
|
||||||
.as_ref()
|
.endpoint_addr
|
||||||
.map(|x| x.to_string())
|
.as_ref()
|
||||||
.unwrap_or_default()
|
.map(|x| x.to_string())
|
||||||
|
.unwrap_or_default()
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
)
|
||||||
})
|
})
|
||||||
.collect()
|
.unwrap_or_default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user