diff --git a/rust/connlib/snownet/src/node.rs b/rust/connlib/snownet/src/node.rs index e21a2c545..d46affc49 100644 --- a/rust/connlib/snownet/src/node.rs +++ b/rust/connlib/snownet/src/node.rs @@ -1660,7 +1660,11 @@ enum ConnectionState { } impl ConnectionState { - fn poll_timeout(&self) -> Option<(Instant, &'static str)> { + fn poll_timeout(&self, agent: &IceAgent) -> Option<(Instant, &'static str)> { + if agent.state() != IceConnectionState::Connected { + return None; + } + match self { ConnectionState::Connected { last_incoming, @@ -1690,6 +1694,10 @@ impl ConnectionState { return; } + if agent.state() != IceConnectionState::Connected { + return; + } + let peer_socket = *peer_socket; self.transition_to_idle(cid, peer_socket, agent); @@ -1886,7 +1894,7 @@ where self.disconnect_timeout() .map(|instant| (instant, "disconnect timeout")), ) - .chain(self.state.poll_timeout()) + .chain(self.state.poll_timeout(&self.agent)) .min_by_key(|(instant, _)| *instant) } diff --git a/rust/connlib/tunnel/proptest-regressions/tests.txt b/rust/connlib/tunnel/proptest-regressions/tests.txt index 45559acf1..1f49096b7 100644 --- a/rust/connlib/tunnel/proptest-regressions/tests.txt +++ b/rust/connlib/tunnel/proptest-regressions/tests.txt @@ -188,3 +188,4 @@ cc d10aa7e820d45043912bf5bf48405d5487a3d9e4a1476d21e4189f964ba8e968 cc a18f8702ecec7ce39aea445251697b7884cd2d38734a07d1e5400bb45f90f03b cc 4a61f62e36ecaa6fdb937a7ba599c6f6a83c364db009b4ba5912bbab1f75f8ff cc 1e1bbfd953f0662e602c94082c63ba50bec19aab95711a9de262ab3e4b146ef1 +cc 000ae850850a75c30a36de2216c8f7ddec2c281f8beaf4f2797822b59895ecd1