mirror of
https://github.com/rustdesk/rustdesk-server.git
synced 2025-07-04 00:35:35 +00: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,
|
db: super::SledAsync,
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
|
||||||
static ref PUBLIC_IP: Arc<RwLock<String>> = Default::default();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const DEFAULT_PORT: &'static str = "21116";
|
pub const DEFAULT_PORT: &'static str = "21116";
|
||||||
|
|
||||||
impl PeerMap {
|
impl PeerMap {
|
||||||
@ -223,12 +219,6 @@ impl RendezvousServer {
|
|||||||
}
|
}
|
||||||
Ok((stream, addr)) = listener.accept() => {
|
Ok((stream, addr)) = listener.accept() => {
|
||||||
log::debug!("Tcp connection from {:?}", addr);
|
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 (a, mut b) = Framed::new(stream, BytesCodec::new()).split();
|
||||||
let tcp_punch = rs.tcp_punch.clone();
|
let tcp_punch = rs.tcp_punch.clone();
|
||||||
let mut rs = rs.clone();
|
let mut rs = rs.clone();
|
||||||
@ -604,7 +594,7 @@ impl RendezvousServer {
|
|||||||
};
|
};
|
||||||
msg_out.set_fetch_local_addr(FetchLocalAddr {
|
msg_out.set_fetch_local_addr(FetchLocalAddr {
|
||||||
socket_addr,
|
socket_addr,
|
||||||
relay_server: check_relay_server(&self.relay_servers[i]),
|
relay_server: self.relay_servers[i].clone(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -621,7 +611,7 @@ impl RendezvousServer {
|
|||||||
msg_out.set_punch_hole(PunchHole {
|
msg_out.set_punch_hole(PunchHole {
|
||||||
socket_addr,
|
socket_addr,
|
||||||
nat_type: ph.nat_type,
|
nat_type: ph.nat_type,
|
||||||
relay_server: check_relay_server(&self.relay_servers[i]),
|
relay_server: self.relay_servers[i].clone(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -709,10 +699,3 @@ pub fn test_if_valid_server(host: &str, name: &str) -> ResultType<SocketAddr> {
|
|||||||
}
|
}
|
||||||
res
|
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…
x
Reference in New Issue
Block a user