diff --git a/rust/connlib/tunnel/src/client.rs b/rust/connlib/tunnel/src/client.rs index c806eb315..a91801096 100644 --- a/rust/connlib/tunnel/src/client.rs +++ b/rust/connlib/tunnel/src/client.rs @@ -642,19 +642,19 @@ impl IpProvider { } } - pub fn get_ip_for(&mut self, ip: &IpAddr) -> Option { - let ip = match ip { + pub fn get_proxy_ip_for(&mut self, ip: &IpAddr) -> Option { + let proxy_ip = match ip { IpAddr::V4(_) => self.ipv4.next().map(Into::into), IpAddr::V6(_) => self.ipv6.next().map(Into::into), }; - if ip.is_none() { + if proxy_ip.is_none() { // TODO: we might want to make the iterator cyclic or another strategy to prevent ip exhaustion // this might happen in ipv4 if tokens are too long lived. tracing::error!("IP exhaustion: Please reset your client"); } - ip + proxy_ip } } diff --git a/rust/connlib/tunnel/src/peer.rs b/rust/connlib/tunnel/src/peer.rs index 68ca23ffa..5d713d434 100644 --- a/rust/connlib/tunnel/src/peer.rs +++ b/rust/connlib/tunnel/src/peer.rs @@ -199,18 +199,18 @@ pub struct PacketTransformClient { impl PacketTransformClient { pub fn get_or_assign_translation( &self, - external_ip: &IpAddr, + ip: &IpAddr, ip_provider: &mut IpProvider, ) -> Option { let mut translations = self.translations.write(); - if let Some(internal_ip) = translations.get_by_right(external_ip) { - return Some(*internal_ip); + if let Some(proxy_ip) = translations.get_by_right(ip) { + return Some(*proxy_ip); } - let internal_ip = ip_provider.get_ip_for(external_ip)?; + let proxy_ip = ip_provider.get_proxy_ip_for(ip)?; - translations.insert(internal_ip, *external_ip); - Some(internal_ip) + translations.insert(proxy_ip, *ip); + Some(proxy_ip) } }