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:
Aram 🍐 2021-10-25 19:05:40 -04:00
parent 282d4f48eb
commit d975efefaf
3 changed files with 106 additions and 36 deletions

View file

@ -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