mirror of
https://github.com/rustdesk/rustdesk-server.git
synced 2024-11-27 23:29:00 +08:00
this way can not get right extern ip
This commit is contained in:
parent
723e43f5d0
commit
d039bed577
@ -66,10 +66,6 @@ struct PeerMap {
|
||||
db: super::SledAsync,
|
||||
}
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref PUBLIC_IP: Arc<RwLock<String>> = Default::default();
|
||||
}
|
||||
|
||||
pub const DEFAULT_PORT: &'static str = "21116";
|
||||
|
||||
impl PeerMap {
|
||||
@ -223,12 +219,6 @@ impl RendezvousServer {
|
||||
}
|
||||
Ok((stream, addr)) = listener.accept() => {
|
||||
log::debug!("Tcp connection from {:?}", addr);
|
||||
if let Ok(local_addr) = stream.local_addr() {
|
||||
if PUBLIC_IP.write().unwrap().is_empty() {
|
||||
log::info!("Public ip is {}", local_addr.ip().to_string());
|
||||
}
|
||||
*PUBLIC_IP.write().unwrap() = local_addr.ip().to_string();
|
||||
}
|
||||
let (a, mut b) = Framed::new(stream, BytesCodec::new()).split();
|
||||
let tcp_punch = rs.tcp_punch.clone();
|
||||
let mut rs = rs.clone();
|
||||
@ -604,7 +594,7 @@ impl RendezvousServer {
|
||||
};
|
||||
msg_out.set_fetch_local_addr(FetchLocalAddr {
|
||||
socket_addr,
|
||||
relay_server: check_relay_server(&self.relay_servers[i]),
|
||||
relay_server: self.relay_servers[i].clone(),
|
||||
..Default::default()
|
||||
});
|
||||
} else {
|
||||
@ -621,7 +611,7 @@ impl RendezvousServer {
|
||||
msg_out.set_punch_hole(PunchHole {
|
||||
socket_addr,
|
||||
nat_type: ph.nat_type,
|
||||
relay_server: check_relay_server(&self.relay_servers[i]),
|
||||
relay_server: self.relay_servers[i].clone(),
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
@ -709,10 +699,3 @@ pub fn test_if_valid_server(host: &str, name: &str) -> ResultType<SocketAddr> {
|
||||
}
|
||||
res
|
||||
}
|
||||
|
||||
fn check_relay_server(addr: &str) -> String {
|
||||
if addr.contains("0.0.0.0") {
|
||||
return addr.replace("0.0.0.0", &PUBLIC_IP.read().unwrap());
|
||||
}
|
||||
addr.to_owned()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user