Skip to content

Commit

Permalink
Merge pull request #11 from marcbrevoort-cyberhive/patch-1
Browse files Browse the repository at this point in the history
Fix some timeout issues
  • Loading branch information
sile authored Feb 23, 2024
2 parents 3e95efa + 84394de commit 071f04b
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/client/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ where
relay_addr: Option<SocketAddr>,
) -> Self {
let mut timeout_queue = TimeoutQueue::new();
timeout_queue.push(TimeoutEntry::Refresh, lifetime * 10 / 9);
timeout_queue.push(TimeoutEntry::Refresh, lifetime * 9 / 10);
ClientCore {
stun_channel,
channel_data_transporter,
Expand Down Expand Up @@ -121,7 +121,7 @@ where

self.lifetime = track_assert_some!(lifetime, ErrorKind::Other; response);
self.timeout_queue
.push(TimeoutEntry::Refresh, self.lifetime * 10 / 9);
.push(TimeoutEntry::Refresh, self.lifetime * 9 / 10);
}
}
Ok(())
Expand Down Expand Up @@ -156,7 +156,7 @@ where
self.permissions.insert(peer.ip(), None);
self.timeout_queue.push(
TimeoutEntry::Permission { peer },
Duration::from_secs(PERMISSION_LIFETIME_SECONDS * 10 / 9),
Duration::from_secs(PERMISSION_LIFETIME_SECONDS * 9 / 10),
);
}
}
Expand Down Expand Up @@ -194,7 +194,7 @@ where
self.channels.insert(peer, ChannelState::Created { number });
self.timeout_queue.push(
TimeoutEntry::Channel { peer },
Duration::from_secs(CHANNEL_LIFETIME_SECONDS * 10 / 9),
Duration::from_secs(CHANNEL_LIFETIME_SECONDS * 9 / 10),
);
}
}
Expand Down Expand Up @@ -226,7 +226,7 @@ where
self.permissions.insert(peer.ip(), None);
self.timeout_queue.push(
TimeoutEntry::Permission { peer },
Duration::from_secs(PERMISSION_LIFETIME_SECONDS * 10 / 9),
Duration::from_secs(PERMISSION_LIFETIME_SECONDS * 9 / 10),
);
}
}
Expand All @@ -236,7 +236,7 @@ where
self.channels.insert(peer, state);
self.timeout_queue.push(
TimeoutEntry::Channel { peer },
Duration::from_secs(CHANNEL_LIFETIME_SECONDS * 10 / 9),
Duration::from_secs(CHANNEL_LIFETIME_SECONDS * 9 / 10),
);
}
}
Expand Down Expand Up @@ -290,8 +290,7 @@ where
}

fn create_permission_inner(&mut self, peer: SocketAddr) -> Result<()> {
track_assert!(!self.permissions.contains_key(&peer.ip()), ErrorKind::InvalidInput; peer);

// If a permission already exists on the TURN server, it will just be refreshed.
let mut request = Request::new(rfc5766::methods::CREATE_PERMISSION);
request.add_attribute(rfc5766::attributes::XorPeerAddress::new(peer).into());
track!(self.auth_params.add_auth_attributes(&mut request))?;
Expand Down

0 comments on commit 071f04b

Please sign in to comment.