diff --git a/rust/connlib/clients/shared/src/eventloop.rs b/rust/connlib/clients/shared/src/eventloop.rs index 1cf3ffc6e..3bd54780d 100644 --- a/rust/connlib/clients/shared/src/eventloop.rs +++ b/rust/connlib/clients/shared/src/eventloop.rs @@ -123,9 +123,7 @@ where .send(PHOENIX_TOPIC, EgressMessages::ReuseConnection(connection)); } } - firezone_tunnel::Event::SendPacket { .. } - | firezone_tunnel::Event::StopPeer { .. } - | firezone_tunnel::Event::DeviceConfigUpdated => { + firezone_tunnel::Event::SendPacket { .. } | firezone_tunnel::Event::StopPeer { .. } => { unreachable!("Handled internally") } } diff --git a/rust/connlib/tunnel/src/client.rs b/rust/connlib/tunnel/src/client.rs index 72ac4e94f..a8afd2003 100644 --- a/rust/connlib/tunnel/src/client.rs +++ b/rust/connlib/tunnel/src/client.rs @@ -167,10 +167,21 @@ where Ok(()) } - pub(crate) fn update_interface(&mut self) -> connlib_shared::Result<()> { - let dns_mapping = self.role_state.dns_mapping(); - let config = - self.role_state.interface_config.as_ref().expect("Developer error: we should always call update_interface after the interface config is set"); + /// Sets the interface configuration and starts background tasks. + #[tracing::instrument(level = "trace", skip(self))] + pub fn set_interface(&mut self, config: &InterfaceConfig) -> connlib_shared::Result<()> { + self.role_state.interface_config = Some(config.clone()); + let effective_dns_servers = effective_dns_servers( + config.upstream_dns.clone(), + self.callbacks() + .get_system_default_resolvers() + .ok() + .flatten() + .unwrap_or_default(), + ); + + let dns_mapping = sentinel_dns_mapping(&effective_dns_servers); + self.role_state.set_dns_mapping(dns_mapping.clone()); self.device.initialize( config, @@ -190,24 +201,6 @@ where Ok(()) } - /// Sets the interface configuration and starts background tasks. - #[tracing::instrument(level = "trace", skip(self))] - pub fn set_interface(&mut self, config: &InterfaceConfig) -> connlib_shared::Result<()> { - self.role_state.interface_config = Some(config.clone()); - let effective_dns_servers = effective_dns_servers( - config.upstream_dns.clone(), - self.callbacks() - .get_system_default_resolvers() - .ok() - .flatten() - .unwrap_or_default(), - ); - - let dns_mapping = sentinel_dns_mapping(&effective_dns_servers); - self.role_state.set_dns_mapping(dns_mapping); - self.update_interface() - } - /// Clean up a connection to a resource. // FIXME: this cleanup connection is wrong! pub fn cleanup_connection(&mut self, id: ResourceId) { diff --git a/rust/connlib/tunnel/src/lib.rs b/rust/connlib/tunnel/src/lib.rs index 235ef10af..1b1b71b88 100644 --- a/rust/connlib/tunnel/src/lib.rs +++ b/rust/connlib/tunnel/src/lib.rs @@ -77,10 +77,6 @@ where self.device.write(packet)?; cx.waker().wake_by_ref(); } - Poll::Ready(Event::DeviceConfigUpdated) => { - self.update_interface()?; - cx.waker().wake_by_ref() - } Poll::Ready(other) => return Poll::Ready(Ok(other)), _ => (), } @@ -423,5 +419,4 @@ pub enum Event { }, SendPacket(IpPacket<'static>), StopPeer(TId), - DeviceConfigUpdated, }