mirror of
https://github.com/telemt/telemt.git
synced 2026-04-19 11:34:10 +03:00
Configured middle_proxy_nat_ip for ME Gate on strartup
This commit is contained in:
@@ -638,9 +638,9 @@ impl MePool {
|
||||
}
|
||||
}
|
||||
|
||||
/// Translate the local ME address into the address material sent to the proxy.
|
||||
pub fn translate_our_addr(&self, addr: SocketAddr) -> SocketAddr {
|
||||
let ip = self.translate_ip_for_nat(addr.ip());
|
||||
SocketAddr::new(ip, addr.port())
|
||||
self.translate_our_addr_with_reflection(addr, None)
|
||||
}
|
||||
|
||||
pub fn registry(&self) -> &Arc<ConnRegistry> {
|
||||
|
||||
@@ -159,7 +159,13 @@ impl MePool {
|
||||
addr: std::net::SocketAddr,
|
||||
reflected: Option<std::net::SocketAddr>,
|
||||
) -> std::net::SocketAddr {
|
||||
let ip = if let Some(r) = reflected {
|
||||
let ip = if let Some(nat_ip) = self.nat_ip_cfg {
|
||||
match (addr.ip(), nat_ip) {
|
||||
(IpAddr::V4(_), IpAddr::V4(dst)) => IpAddr::V4(dst),
|
||||
(IpAddr::V6(_), IpAddr::V6(dst)) => IpAddr::V6(dst),
|
||||
_ => addr.ip(),
|
||||
}
|
||||
} else if let Some(r) = reflected {
|
||||
// Use reflected IP (not port) only when local address is non-public.
|
||||
if is_bogon(addr.ip()) || addr.ip().is_loopback() || addr.ip().is_unspecified() {
|
||||
r.ip()
|
||||
|
||||
Reference in New Issue
Block a user