n0-computer / iroh

A toolkit for building distributed applications
https://iroh.computer
Apache License 2.0
2.55k stars 158 forks source link

Configurable throttling for iroh-net relays #2673

Open rklaehn opened 2 months ago

rklaehn commented 2 months ago

Some people have offered to run "altruistic relays" for iroh-net. However, in order to run such an altruistic relay, you would need a way to throttle all connections that don't switch to direct after some time, otherwise there would be a chance that the operator of an altruistic relay would end up with a huge bandwidth bill.

This is something we ourselves might need at some point, e.g. if a heavy app that builds on iroh-net goes viral. So it might be a good idea to build this in proactively.

Nuhvi commented 2 months ago

For context (albeit out of the scope of this issue):

An altruistic relay would be discoverable from a Mainline hardcoded topic (like content-discovery example).

By default, Mainline returns ~20 random addresses so you get the load-balancing you need.

But that topic might be spammed, so the ultimate solution might be a separate DHT (using the rust's Mainline library) so that only "good" relays are kept in the routing table, so nodes would test each other's for holepunching, and not just responsiveness for ping requests.