mirror of
https://github.com/arampoire/onetun.git
synced 2025-12-01 03:00:25 -05:00
End-to-end UDP implementation
Port re-use still needs to be implemented to prevent exhaustion over time, and flooding.
This commit is contained in:
parent
282d4f48eb
commit
d975efefaf
3 changed files with 106 additions and 36 deletions
|
|
@ -175,7 +175,7 @@ impl UdpPortPool {
|
|||
}
|
||||
}
|
||||
|
||||
/// Requests a free port from the pool. An error is returned if none is available (exhaused max capacity).
|
||||
/// Requests a free port from the pool. An error is returned if none is available (exhausted max capacity).
|
||||
pub async fn next(&self, peer_addr: SocketAddr) -> anyhow::Result<u16> {
|
||||
{
|
||||
let inner = self.inner.read().await;
|
||||
|
|
@ -184,6 +184,9 @@ impl UdpPortPool {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: When the port pool is exhausted, it should re-queue the least recently used port.
|
||||
// TODO: Limit number of ports in use by peer IP
|
||||
|
||||
let mut inner = self.inner.write().await;
|
||||
let port = inner
|
||||
.queue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue