mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 18:18:55 +00:00
connlib: refactor names (#3104)
Applying suggestions for #3096 since it was merged before I could fix
This commit is contained in:
@@ -642,19 +642,19 @@ impl IpProvider {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_ip_for(&mut self, ip: &IpAddr) -> Option<IpAddr> {
|
||||
let ip = match ip {
|
||||
pub fn get_proxy_ip_for(&mut self, ip: &IpAddr) -> Option<IpAddr> {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<IpAddr> {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user