this post was submitted on 17 Dec 2023
7 points (100.0% liked)
Rust Programming
7734 readers
1 users here now
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
If all you want is to break through NAT, you can try a TURN client (rusturn for instance). Unfortunately, STUN/TURN doesn't solve the entire problem (there are types of NAT that it can't break through and you need to fall back to full relay mode) but this technology is still used for P2P voice calls all over the place.
You could consider Veilid, which already handles a lot of DHT stuff. It's not exactly ultra low latency but it does solve the reachability solution without you having to host any STUN/TURN servers yourself. You can also tweak the protocol a little (either get Tor-like privacy through a whole bunch of intermediate nodes, or just pick two nodes per direction for lower latency).
I don't think there's a Rust crate, but Yggdrasil can also take care of NAT for you while at the same time being exposed like a normal network, so you don't need to learn a new API.
There's libtor that'll let you embed a Tor client inside your application. Of course Tor is most well-known for privacy and such, but it's also very effective at busting through any kind of NAT you can imagine.
Unfortunately, there is no way to get P2P working across the internet without some kind of handshake server, someone needs to tell you where to find the other nodes.
Thanks a bunch for the detailed response! Yes, for this project which is not really serious I just need to have some NAT scenarios working, so that I can try it with a few friends. I'm on a quest to understand how decentralized technologies and cryptography work. I think rusturn should do the trick.