Skip to content

Use decentralized discovery (DHT) #3388

Open

Description

@calmh

It's probably time to investigate decentralizing discovery. Doing so would reduce our infrastructure burden and reduce centralized knowledge of the network. In a DHT we want to be able to look up the contact details for a given device ID. We want to publish our own contact details into the DHT. We don't necessarily want to make it simple for a passive observer to map the entire network, so it would be nice if the contact details were encrypted.


I suggest that we could use a key-value database laid out like:

Key: SHA256(device ID)

Value: The contact details, in protobuf format, encrypted using the device ID as a shared secret.

Given that I know the device ID I'm looking for, I can then hash it and look it up, and decrypt the answer. For other nodes in the network, the data is mostly gibberish as you need to know the device ID it represents to be able to interpret it and reversing the SHA256(device ID) to an actual device ID is not feasible.

As far as an actual implementation goes I've surveyed the Go ecosystem to try to find a suitable DHT package. So far I've not really succeeded. Here are the ones I've looked at and some notes on them; it would be lovely if someone did find or develop a good package for this.

If anyone wants to pick this up and run with it, please do so, and announce yourself in the comments below :)

Activity

  1. added
    enhancementNew features or improvements of some kind, as opposed to a problem (bug)
    on Jul 5, 2016
  2. added this to the milestone on Jul 5, 2016
  3. AudriusButkevicius commented on Jul 5, 2016

    @AudriusButkevicius
    Member

    Ipfs people are using kademila afaik.

    Anyways, you still need infrastructure to bootstrap, and how do we perform authentication against other peers being non-malicious, prevent malicious peers from overwriting keys, or even bootstrap server from being malicious?

  4. calmh commented on Jul 5, 2016

    @calmh
    MemberAuthor

    https://godoc.org/github.com/ipfs/go-ipfs/routing/dht looks quite good, yes, thanks!

    Certainly we'll need a couple of bootstrap nodes. But I don't think they need to be as beefy as our current discovery servers, and more importantly they shouldn't need to scale much in the future.

    As for the maliciousness I'm not sure. Decentralizing things makes that difficult. The worst case scenario is then being tricked to connect to the wrong place when looking for a certain device ID, blocking discovery of a given device... Certainly the stored value could be signed by the device certificate, and the certificate attached, but that doesn't stop anyone from just uploading a blob of garbage for a given lookup key.

    Gnnh: https://github.com/ipfs/go-ipfs/blob/master/routing/dht/dht.go#L19

  5. raichu commented on Jul 5, 2016

    @raichu
  6. cdhowie commented on Jul 7, 2016

    @cdhowie
    Contributor

    The worst case scenario is then being tricked to connect to the wrong place when looking for a certain device ID, blocking discovery of a given device...

    I don't think that's a feasible attack, since the value would be encrypted by the device ID. Such an attack would have to be targeted against a specific, known device ID -- and for that to even work, your DHT node needs to be the one responsible for SHA256(device ID). And even if you successfully pull that off, the traffic is end-to-end encrypted. All you'd really be able to see (assuming you proxy the data) are the IPs on both sides and the amount of data being transferred. You can kinda do this already by running a public relay server, right?

    The "store garbage" attack is much more worrying to me. To my knowledge, the way other DHT networks (torrents for example) combat this problem is by having the key be a hash of the value -- not something we can realistically do here.

  7. cdhowie commented on Jul 7, 2016

    @cdhowie
    Contributor

    The "store garbage" attack is much more worrying to me.

    A realization I just had is that any kind of verification mechanism put in place to avoid a garbage attack would have to incorporate a timestamp, or it would be susceptible to a replay attack, where a previous (valid) value is stored under the same key. For mobile clients that are constantly changing IPs, this could prevent any nodes from connecting to them.

  8. calmh commented on Jul 7, 2016

    @calmh
    MemberAuthor

    I think this will necessarily be some sort of security trade off. We'll gain some security (no need for a trusted middle man who has all the data, harder to DoS, etc) and lose some (harder to prevent false information). But as long as the feasible attack is mostly to prevent lookup against a specific device ID I think it may be worth it. It's just one discovery method among many after all.

  9. AudriusButkevicius commented on Jul 7, 2016

    @AudriusButkevicius
    Member

    Or just DDoS the bootstrapping node...

  10. calmh commented on Jul 7, 2016

    @calmh
    MemberAuthor

    That could still be fine though, if you could still reach some other device to bootstrap, say via local discovery, or if you're already connected to the network. But sure, agree we need the three geographically diverse bootstrap nodes and it's certainly not bulletproof. But honestly the bigger threat at the moment is probably me screwing up the discovery servers by fatfingering something. :)

  11. aviau commented on Jul 14, 2016

    @aviau
    Contributor

    That could still be fine though, if you could still reach some other device to bootstrap, say via local discovery, or if you're already connected to the network

    One other method around DDoS-ing the bootstrap node is that clients should save all nodes that they know to the disk. Whenever they restart they can try to bootstrap with all of these nodes if the master bootstrap node is down. The bootstrap node is only critical for the fist time the client is started.

  12. Ferroin commented on Jul 15, 2016

    @Ferroin

    That becomes problematic when dealing with clients with dynamic addresses, you'd need a system with a static address in the network for such a scheme to work reliably, because there's the possibility that all the other systems change address.

  13. canton7 commented on Jul 15, 2016

    @canton7
    Contributor

    I think @aviau meant all other DHT nodes which that device had discovered, and not all configured Syncthing devices.

    There will probably be enough DHT nodes which either have static IPs, or whose IP hasn't changed (most dynamic IPs rarely change in practice) for a node to find one which is still contactable, and so reconnect itself to the network.

  14. Ferroin commented on Jul 15, 2016

    @Ferroin

    To retain feature parity though, there would need to be an option to run independently of the default bootstrap servers and DHT network. Otherwise, this is functionally a regression for anyone using a custom global discovery server. This becomes even more important if all nodes are expected to participate, especially considering people like me who have to pay for bandwidth and data transfer for our nodes which do have static addresses. Such a situation of paying for bandwidth is a lot more common than you think, an will be the case for almost anyone using cloud hosting or running over a mobile broadband connection, and in fact is much better served by a centralized discovery mechanism like what Syncthing has now.

  15. aviau commented on Jul 15, 2016

    @aviau
    Contributor

    There will probably be enough DHT nodes which either have static IPs

    Exactly. We use this method for Ring.

  16. 100 remaining items

  17. sjehuda commented on May 10, 2024

    @sjehuda

    DHT is one of the technologies that bad governments and bad corporations hate the most.

    DHT is an important technology. I operate several machines world wide to share over 5 million files via DHT over the BitTorrent system and I use not even a single BitTorrent Tracker to discover peers.

    @AudriusButkevicius

    You still need infrastructure to bootstrap, and how do we perform authentication against other peers being non-malicious, prevent malicious peers from overwriting keys, or even bootstrap server from being malicious?

    @SoniEx2

    what stops you from uh, running multiple DHTs for all the supported key types?

    Gentlemen, these are good notes you have made.

    The VoIP client Jami (previously GNU Ring, and SFLphone), from @savoirfairelinux, which has started as a SIP/IAX VoIP client has later added support to a completely decentralized system which uses DHT to discover peers of its decentralized VoIP system.

    See OpenDHT and this article (Tar archive) which probably has been censored either by a bad intelligence agency or by a bad corporation.

    Also, to increase identity verification you can make DHT possible at the condition of using PGP keys, similarly to the cjdns system from @cjdelisle.


    You might also want to add support to cjdns and I2P systems.

    You can refer to Seth who gracefully explains the I2P system.


    Another important comment about the importance DHT

    The so called entertainment industry (i.e. inteligence controlled cultural subversion industry) has ceased to discuss about P2P for over a decade, and instead of publicly fighting BitTorrent, the industry has increased the prevalence of so called "streaming services" and have limped the internet with the help of the Net Neutrality propaganda which was designed to harm systems like Syncthing and non-corporate online services.

    The reason for this is because DHT has made BitTorrent unstoppable and the best resort to fight against BitTorrent is to stop talking about it and hope people would forget about it.

    Another important comment about the issue with intermediating resources

    Centralized resources are more often subjected to compromisation than decentralized resources.

    The Syncthing Relay Nodes, and also BitTorrent Trackers, are centralized in nature and have an identity which can be tracked and potentially hijacked by a bad entity.

    Many domains and IP addresses of BitTorrent Tracker that went offline are now owned by DOOBLE (the so called we are not so evil corrporation), and these domain still do not function as BitTorrent Trackers, yet BitTorrent clients with these domains assigned are being exploited by turning them into a mean of identification, as long as the people who use BitTorrent did not remove the outdated BitTorrent Trackers.

    So it might be for Syncthing Relay Nodes.

    Let us not be subjected to this scenario.

  18. cjdelisle commented on May 10, 2024

    @cjdelisle

    DHT is one of the technologies that bad governments and bad corporations hate the most.

    It's not quite like that, all DHTs are inherently susceptible to poison and sybil attacks. For example if I don't like entry XXXX I can generate a ton of fake entries and keep the ones with keys which are numerically closest to XXXX, then I insert them into the DHT to clog up the nodes which hold them. Likewise, I can generate fake nodes, using the same collision attack to get node IDs that are numerically closest to XXXX such that most nodes will drop XXXX because it appears that it is already handled by my (fake) nodes.

    The reason for this is because DHT has made BitTorrent unstoppable

    Yes and no. The Bittorrent DHT does make Bittorrent a lot more robust against attacks, but not for the reasons you might think. The DHT is attackable, as stated, but the nodes in the DHT are not all what they appear to be. The major DHT nodes are not some uTorrent install running on someone's laptop, they're on servers operated by the Good Ol' Boys, so if you start trying to attack the DHT, you may find your IP addresses suddenly getting blocked and then you're unreachable to most of the DHT network. The DHT bootstraps off of DNS seed servers and if the seed operators only point people to the "known good guy" DHT nodes, it's easy for an attacker to just end up isolated from the whole network.

    When this is combined with the proliferation of Trackers, it creates a platform which is very frustrating to attack. You can go after the DHT and it will degrade somewhat but you don't get to pull out a clear win, and in any case the trackers will carry the network so basically no one will notice that anything happened. You can also go after the trackers, but there are a lot of them, in a lot of countries, and even if you manage to take down a large subset of trackers, the network will be carried by the DHT, so attacks on Bittorrent are just miserably frustrating to carry out.

    You might also want to add support to cjdns and I2P systems.

    For cjdns, all you need is IPv6 support and to not forbid communication with addresses in the fc00::/8 block.

  19. calmh commented on May 10, 2024

    @calmh
    MemberAuthor

    There's a whole lot of handwaving in this thread. We have a fairly simple set of requirements:

    1. we need to map a 256 bit key (the device ID) to a small piece of data (the discovery information)
    2. that information needs to change regularly
    3. we want to run a check on that information (e.g., a signature) before accepting it as legitimate

    All the "get an immutable piece of data by hash" or "get an ip:port for a node with a random 160 bit ID" solutions don't move anything forward, because they solve a different problem than the one we have.

  20. bt90 commented on May 10, 2024

    @bt90
    Contributor

    The biggest obstacle, IMHO, is that while there are DHTs that offer some sort of protected/signed payload, they rely on public key cryptography. The thing is that the initial pairing is done without the full public key. So we end up with a bootstrapping problem.

  21. EternityForest commented on May 10, 2024

    @EternityForest
  22. jadsongmatos commented on Jun 28, 2024

    @jadsongmatos

    One of the ways to reduce server waste would be to leverage existing Torrent Tracker servers, similar to the P2PT project, which uses WebTorrent Trackers as signaling servers for P2P connections.

    P2PT is a library that connects P2P very differently. P2PT works by using WebTorrent Trackers as signaling servers, converting an application's unique identifier into a valid Info Hash, which is sent to the trackers to obtain a list of web peers using the application.

    By taking a similar approach, Syncthing could use WebTorrent Trackers for P2P discovery, reducing reliance on dedicated servers and improving scalability. This method uses existing infrastructure to reduce costs and make communication more efficient.

    References:

  23. added theissue type on May 30, 2025
  24. aydencook03 commented on Apr 29, 2026

    @aydencook03

    A possible alternative to DHT that still keeps discovery decentralized would be to use Nostr relays. There are many p2p projects that utilize nostr ephemeral events for peer discovery. Hashtree is an example. This would be simpler and more lightweight than a DHT.

  25. sjehuda commented on May 1, 2026

    @sjehuda

    @aydencook03 This might be a good idea. Do you have code references?

    Nevertheless, DHT is probably preferable, as it is utilized with BitTorrent, eDonkey2000, Gnutella, and other networks; and, most implementations are lean.

    Of course, implementing a mechanism to query consequent IP addresses (so called "brute force") be a good addition to software which support DHT.

    Perhaps implementing all three (DHT, Nostr, Query) be a good idea.

  26. sjehuda commented on May 1, 2026

    @sjehuda

    @aydencook03 This might be a good idea. Do you have code references?

  27. aydencook03 commented on May 1, 2026

    @aydencook03

    @sjehuda I don't. But if people think it's a good idea then I could find some or put something together myself. I've made a post in the forums so that this idea can be discussed.

  28. sjehuda commented on May 1, 2026

    @sjehuda

    While I prefer and biased towards DHT, as I have experience with DHT, your idea might be even better.

    The fact that maybe it was not tried yet, does not mean that it is not better.

    I am not an authority; yet,, I am infavour of considering your idea.

  29. added 3 commits that reference this issue on Nov 5, 2026
    ece4c7f
    0f292a7
    3f79583
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew features or improvements of some kind, as opposed to a problem (bug)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions