mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
fix(snownet): only idle when we are fully connected (#9987)
Now that we are capable of migrating a connection to another relay with #9979, our test suite exposed an edge-case: If we are in the middle of migrating a connection, it could be that the idle timer triggers because we have not seen any application traffic in the last 20s. Moving to idle mode drastically reduces the number of STUN bindings we send and if this happens whilst we are still checking candidates, the nomination doesn't happen in time for our boringtun handshake to succeed. Thus, we add a condition to our idle timer to not trigger unless ICE has completed and reports us as `connected`.
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -188,3 +188,4 @@ cc d10aa7e820d45043912bf5bf48405d5487a3d9e4a1476d21e4189f964ba8e968
|
||||
cc a18f8702ecec7ce39aea445251697b7884cd2d38734a07d1e5400bb45f90f03b
|
||||
cc 4a61f62e36ecaa6fdb937a7ba599c6f6a83c364db009b4ba5912bbab1f75f8ff
|
||||
cc 1e1bbfd953f0662e602c94082c63ba50bec19aab95711a9de262ab3e4b146ef1
|
||||
cc 000ae850850a75c30a36de2216c8f7ddec2c281f8beaf4f2797822b59895ecd1
|
||||
|
||||
Reference in New Issue
Block a user