2 ms·
https://news.ycombinator.com/item?id=40879547 https://news.ycombinator.com/item?id=40879547 async fn stun( server: SocketAddr, mut socket:
by joshka 2y ago
https://news.ycombinator.com/item?id=40879547 https://news.ycombinator.com/item?id=40879547
async fn stun(
server: SocketAddr,
mut socket: impl Sink<(BindingRequest, SocketAddr), Error = color_eyre::Report>
+ Stream<Item = Result<(BindingResponse, SocketAddr), color_eyre::Report>>
+ Unpin
+ Send
+ 'static,
) -> Result<SocketAddr> {
socket.send((BindingRequest, server)).await?;
let (message, _server) = socket.next().await.ok_or_eyre("No response")??;
Ok(message.address)
}
Fully working code at https://gist.github.com/joshka/af299be87dbd1f64060e47227b5772ef https://gist.github.com/joshka/af299be87dbd1f64060e47227b577...