this post was submitted on 17 Dec 2023
7 points (100.0% liked)

Rust Programming

8160 readers
1 users here now

founded 5 years ago
MODERATORS
 

I've seen a few but I can't decide which protocol to use yet. I'm working on a DHT pet project and I'd like to avoid making it rely on any relay servers.

Thanks in advance for any pointers!

all 5 comments
sorted by: hot top controversial new old
[–] [email protected] 4 points 11 months ago (2 children)

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.

[–] [email protected] 2 points 11 months ago

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.

[–] [email protected] 1 points 10 months ago (1 children)

Whoa... why was your response deleted?