# New idea using.DHT

**URL:** https://forum.syncthing.net/t/new-idea-using-dht/6980
**Category:** Development
**Created:** [March 17, 2016, 1:45pm UTC](https://forum.syncthing.net/t/new-idea-using-dht/6980 "2016-03-17T13:45:59Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Manu](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/m/7c8e57/32.png) [@Manu](https://forum.syncthing.net/u/Manu)
#### Post date: [March 17, 2016, 1:45pm UTC](https://forum.syncthing.net/t/new-idea-using-dht/6980/1 "2016-03-17T13:45:59Z")

</div>

I would like to present you an idea to get Syncthing more like BTSync.

However, I love Syncthing and I think that we shouldn’t change how Syncthing is working but we can develop an extern application to add the BTSync philosophy to Syncthing.

I propose to use a DHT (key =\> value) which has two types of data:

1. The list of shared directories ;

2. The list of confirming messages.

We can use the following algorithm:

1. When a new shared directory is created, we generate a new ID called SHARE\_ID. After that, we add a key/value in the DHT:

a. key = SHA512(SHARE\_ID)

b. value = AES512( syncthing device id, syncthing directory id) which the crypto key is “SHARE\_ID”.

1. The user can send the SHARE\_ID to his friend by phone or by mail.

2. The friend enter the SHARE\_ID. Our application hash SHARE\_ID and find the value in the DHT. The value is decrypted using SHARE\_ID and user’s syncthing adds the “syncthing device id” and “the syncthing directory id” of the initial share. After that, the friend’s application adds a new key/value in the DHT like this:

a. key = SHA512(syncthing device id)

b. value = (new user to syncthing directory id, friend’s syncthing device id) which ) which the public crypto RSA key is “SHARE\_ID”.

1. Finally, the initial syncthing instance check regularly the DHT if the key= SHA512(syncthing device id) exists. If this is the case, then get the value, decrypt the value with his private RSA key and adds the friend’s syncthing id to the share.

What do you thing about this ?

---

<div class="post-metadata">

### Author: ![calmh](https://forum.syncthing.net/user_avatar/forum.syncthing.net/calmh/32/15311_2.png) [@calmh](https://forum.syncthing.net/u/calmh)
#### Post date: [March 17, 2016, 1:51pm UTC](https://forum.syncthing.net/t/new-idea-using-dht/6980/2 "2016-03-17T13:51:57Z")

</div>

First part sounds vaguely reasonable. 🙂 The second part I think is unnecessary - since the SHARE\_ID is a secret, the new device could simply present it as a password / one time token when first connecting, to validate themselves. I think is quite similar to what was discussed recently in some topic around here, except then we were using the discovery servers instead of a DHT, but same-same.

---

<div class="post-metadata">

### Author: ![rumpelsepp](https://forum.syncthing.net/user_avatar/forum.syncthing.net/rumpelsepp/32/2006_2.png) [@rumpelsepp](https://forum.syncthing.net/u/rumpelsepp)
#### Post date: [March 17, 2016, 2:16pm UTC](https://forum.syncthing.net/t/new-idea-using-dht/6980/3 "2016-03-17T14:16:01Z")

</div>

Some refs:

> [@Discovery resiliency / DHT](https://forum.syncthing.net/t/discovery-resiliency-dht/6884):
>
> Do you have something in mind for this already? I’d still like to see a proper DHT, but I understand that there might be a problem of trust and privacy. Instead, how about having each project member host a discovery/relaypool server, and decentralize it that way?

> [@DHT for global discovery](https://forum.syncthing.net/t/dht-for-global-discovery/379/4):
>
> and global one won’t because the global server is inaccessible. just set up your own “global” server in your network, in the config file there is a setting for that: \<globalAnnounceServer\>announce.syncthing.net:22025\</globalAnnounceServer\> DHT could be something for far-future but i also don’t see a important reason why we would want it now.

> [@Research: Bit Torrent Research -- Protocolls, DHT, Fast UDP xFerer](https://forum.syncthing.net/t/research-bit-torrent-research-protocolls-dht-fast-udp-xferer/1912):
>
> Bittorrent Spec nd Description from n erlier revision [https://s3.amazonaws.com/syncthing-resarch/BitTorrentSpec.pdf](https://s3.amazonaws.com/syncthing-resarch/BitTorrentSpec.pdf) How Efficient is itorrent Protocol (data loss, etc)? [https://s3.amazonaws.com/syncthing-resarch/HowEfficientIsBittorrent.pdf](https://s3.amazonaws.com/syncthing-resarch/HowEfficientIsBittorrent.pdf) UDDT+ Rapid transport protocol for Bitorrent [https://s3.amazonaws.com/syncthing-resarch/UDTRapid+Protocolppt](https://s3.amazonaws.com/syncthing-resarch/UDTRapid+Protocolppt) UDT: Breakingthe TCP dattatransfer bottleneck [https://s3.amazonaws.com/syncthing-resarch/UDT]Breaking\DataTransferBottlenek.ppt](https://s3.amazonaws.com/syncthing-resarch/UDT%5DBreaking%5CDataTransferBottlenek.ppt)

---

<div class="post-metadata">

### Author: ![AudriusButkevicius](https://forum.syncthing.net/user_avatar/forum.syncthing.net/audriusbutkevicius/32/277_2.png) [@AudriusButkevicius](https://forum.syncthing.net/u/AudriusButkevicius)
#### Post date: [March 17, 2016, 3:00pm UTC](https://forum.syncthing.net/t/new-idea-using-dht/6980/4 "2016-03-17T15:00:48Z")

</div>

Do you have any security concerns? Otherwise it seems fairly plausible to implement.

---

<div class="post-metadata">

### Author: ![calmh](https://forum.syncthing.net/user_avatar/forum.syncthing.net/calmh/32/15311_2.png) [@calmh](https://forum.syncthing.net/u/calmh)
#### Post date: [March 17, 2016, 3:03pm UTC](https://forum.syncthing.net/t/new-idea-using-dht/6980/5 "2016-03-17T15:03:15Z")

</div>

No, no particular concerns, I mean it’s inline with what we’ve discussed before except then I called the SHARE\_ID a “one time token”, and was thinking the discovery servers could do it instead of the DHT. But no, either way would be fine I guess.

---

<div class="post-metadata">

### Author: ![AudriusButkevicius](https://forum.syncthing.net/user_avatar/forum.syncthing.net/audriusbutkevicius/32/277_2.png) [@AudriusButkevicius](https://forum.syncthing.net/u/AudriusButkevicius)
#### Post date: [March 17, 2016, 3:16pm UTC](https://forum.syncthing.net/t/new-idea-using-dht/6980/6 "2016-03-17T15:16:59Z")

</div>

So I am not concerned about where stuff goes, but rather how to do it. I guess if we do this HelloMsg business, we could trivially implement this. Otherwise polling could be used.

---

<div class="post-metadata">

### Author: ![devanubis](https://forum.syncthing.net/user_avatar/forum.syncthing.net/devanubis/32/1879_2.png) [@devanubis](https://forum.syncthing.net/u/devanubis)
#### Post date: [March 17, 2016, 8:36pm UTC](https://forum.syncthing.net/t/new-idea-using-dht/6980/7 "2016-03-17T20:36:45Z")

</div>

I might be missing something, but I don’t see the need for the DHT in this process?

If I understand correctly, this just achieves setting up a shared folder between two devices, without the initial device having to manually confirm that the new device is permitted?

I don’t see why that needs to involve a DHT to pass information between two peers. You’re already sharing a secret outside of the application, that secret can just be used to authenticate the new device…

If the owner of the initial device (Alice) sends the following to a friend (Bob) by email or however:

1. Alice’s device ID
2. Folder name
3. A single-use SECRET

Now, copy and pasting these three manually is annoying, but we can just concatenate them into one string (device IDs are already long so what’s a few more characters?) and have a single input field for “quick-add new folder”.

1. Alice generates the “magic” string, and their device remembers the _secret_
2. Alice shares the “magic” string with Bob offline
3. Bob enters this into their device
4. Bob’s device looks up the IP for Alice’s device ID
5. Connects to Alice’s device and sends the _secret_ along with Bob’s device ID
6. Alice’s device can then confirms that the folder should be shared with Bob and skips the manual confirmation usually required 1.1 Both Alice and Bob then forget the secret as it’s no use any more

The only reason I can see for the DHT is to allow the _initial_ device to add the _new_ device without both devices needing to be online at the same time. Given Syncthing is P2P there isn’t much benefit to that…

Again, sorry if I’m missing something, but I just don’t see the need for a DHT to pass messages between two devices who already have a shared secret…

---

<div class="post-metadata">

### Author: ![AudriusButkevicius](https://forum.syncthing.net/user_avatar/forum.syncthing.net/audriusbutkevicius/32/277_2.png) [@AudriusButkevicius](https://forum.syncthing.net/u/AudriusButkevicius)
#### Post date: [March 17, 2016, 8:47pm UTC](https://forum.syncthing.net/t/new-idea-using-dht/6980/8 "2016-03-17T20:47:44Z")

</div>

Agree, DHT is totally redundant here, and all of this can be delivered via discovery servers.

So this is all well if you have 2 devices, if you have more, it’s not clear what the right thing to do here is. At the point you connect to Alice, should you auto-trust all the devices Alice is sharing the folder with? At which point any of them might be an attacker which exploits a bug in syncthing…

If not, and you are expected to add all devices manually, then it’s just as bad as sending the device ID around (because you already have the folder).

---

<div class="post-metadata">

### Author: ![Manu](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/m/7c8e57/32.png) [@Manu](https://forum.syncthing.net/u/Manu)
#### Post date: [March 17, 2016, 8:57pm UTC](https://forum.syncthing.net/t/new-idea-using-dht/6980/9 "2016-03-17T20:57:15Z")

</div>

I purpose to use a DHT for two reasons:

- don’t change the core of Syncthing
- don’t depend on a central server

---

<div class="post-metadata">

### Author: ![AudriusButkevicius](https://forum.syncthing.net/user_avatar/forum.syncthing.net/audriusbutkevicius/32/277_2.png) [@AudriusButkevicius](https://forum.syncthing.net/u/AudriusButkevicius)
#### Post date: [March 17, 2016, 9:09pm UTC](https://forum.syncthing.net/t/new-idea-using-dht/6980/10 "2016-03-17T21:09:58Z")

</div>

You still depend on server(s) for bootstrapping the DHT, and introducing anything of this type will be a change to syncthing.

---

<div class="post-metadata">

### Author: ![Manu](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/m/7c8e57/32.png) [@Manu](https://forum.syncthing.net/u/Manu)
#### Post date: [March 17, 2016, 9:15pm UTC](https://forum.syncthing.net/t/new-idea-using-dht/6980/11 "2016-03-17T21:15:00Z")

</div>

It’s for that I purpose to add this in the GUI wrappers and not in Syncthing.

---

<div class="post-metadata">

### Author: ![calmh](https://forum.syncthing.net/user_avatar/forum.syncthing.net/calmh/32/15311_2.png) [@calmh](https://forum.syncthing.net/u/calmh)
#### Post date: [March 17, 2016, 9:18pm UTC](https://forum.syncthing.net/t/new-idea-using-dht/6980/12 "2016-03-17T21:18:51Z")

</div>

I’m all for prototyping this outside of Syncthing. If it turns out to be awesome, we’ll happily integrate it.

---

<div class="post-metadata">

### Author: ![AudriusButkevicius](https://forum.syncthing.net/user_avatar/forum.syncthing.net/audriusbutkevicius/32/277_2.png) [@AudriusButkevicius](https://forum.syncthing.net/u/AudriusButkevicius)
#### Post date: [March 17, 2016, 9:23pm UTC](https://forum.syncthing.net/t/new-idea-using-dht/6980/13 "2016-03-17T21:23:00Z")

</div>

I am just afraid that we will end up with another out of process bolt-on ;D

---

<div class="post-metadata">

### Author: ![canton7](https://forum.syncthing.net/user_avatar/forum.syncthing.net/canton7/32/9528_2.png) [@canton7](https://forum.syncthing.net/u/canton7)
#### Post date: [March 17, 2016, 10:05pm UTC](https://forum.syncthing.net/t/new-idea-using-dht/6980/14 "2016-03-17T22:05:44Z")

</div>

People, more often than not, use Syncthing between multiple OSs. That makes implementing it in the existing wrappers a bit painful…

---

<div class="post-metadata">

### Author: ![Nutomic](https://forum.syncthing.net/user_avatar/forum.syncthing.net/nutomic/32/270_2.png) [@Nutomic](https://forum.syncthing.net/u/Nutomic)
#### Post date: [March 17, 2016, 11:36pm UTC](https://forum.syncthing.net/t/new-idea-using-dht/6980/15 "2016-03-17T23:36:21Z")

</div>

Agreed, sharing folders is a core part of Syncthing functionality that affects every platform. Implementing it in wrappers means lots of duplicated efforts.

If you don’t want to roll it out to all users, make an alpha version, or hide it somewhere in the settings.

---

<div class="post-metadata">

### Author: ![AudriusButkevicius](https://forum.syncthing.net/user_avatar/forum.syncthing.net/audriusbutkevicius/32/277_2.png) [@AudriusButkevicius](https://forum.syncthing.net/u/AudriusButkevicius)
#### Post date: [March 17, 2016, 11:38pm UTC](https://forum.syncthing.net/t/new-idea-using-dht/6980/16 "2016-03-17T23:38:30Z")

</div>

So I am fond of this whole idea which removes extra steps in getting up and running (and potentially getting us closer to hiding devices, as they stop mattering), we just haven’t fleshed it out how users expect it to work, hence I think we should have a discussion, summarize and create a wiki/feature/milestone/whatever.

---

<div class="post-metadata">

### Author: ![calmh](https://forum.syncthing.net/user_avatar/forum.syncthing.net/calmh/32/15311_2.png) [@calmh](https://forum.syncthing.net/u/calmh)
#### Post date: [March 18, 2016, 12:17pm UTC](https://forum.syncthing.net/t/new-idea-using-dht/6980/17 "2016-03-18T12:17:51Z")

</div>

Yes. I’m pro having this in the core. But it’s not fleshed out. Hence if someone wants to work on it, doing it externally would be one way to _get_ it fleshed out. But by all means do write up the details etc and implement it in core if you like (for “you” being anyone out there).

---

<div class="post-metadata">

### Author: ![joni](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/j/3d9bf3/32.png) [@joni](https://forum.syncthing.net/u/joni)
#### Post date: [March 23, 2016, 7:57am UTC](https://forum.syncthing.net/t/new-idea-using-dht/6980/18 "2016-03-23T07:57:09Z")

</div>

sirs,

Synchting is GREAT!

There is need at science people to have open system to distribute scientific paper’s. Also we open eBook’s and libraryes.

Syncthing could be easyly developed to work as well as public shareing system Open Science paper’s, Open eBooks,… This type information need’s more complex search/index system and connectivity to library indexing programs like [mendelay.com](http://mendelay.com),…

There could be choice to have encryption in use or not depending network, material source,…

So,… BTSYnc whit better indexing and possibility not to use encryption to save system resources!!

---

<div class="post-metadata">

### Author: ![rumpelsepp](https://forum.syncthing.net/user_avatar/forum.syncthing.net/rumpelsepp/32/2006_2.png) [@rumpelsepp](https://forum.syncthing.net/u/rumpelsepp)
#### Post date: [March 26, 2016, 11:21am UTC](https://forum.syncthing.net/t/new-idea-using-dht/6980/19 "2016-03-26T11:21:43Z")

</div>

> [@joni](#):
>
> Syncthing could be easyly developed to work as well as public shareing system Open Science paper’s, Open eBooks,… This type information need’s more complex search/index system and connectivity to library indexing programs like [mendelay.com](http://mendelay.com),…

There are better solutions for that. IMO that’s out of scope for syncthing.

> [@joni](#):
>
> There could be choice to have encryption in use or not depending network, material source,…
> 
> So,… BTSYnc whit better indexing and possibility not to use encryption to save system resources!!

No, see site search: [Search results for 'disable encryption' - Syncthing Community Forum](https://forum.syncthing.net/search?q=disable%20encryption)

---

<div class="post-metadata">

### Author: ![Micha](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/m/c37758/32.png) [@Micha](https://forum.syncthing.net/u/Micha)
#### Post date: [April 5, 2016, 3:50pm UTC](https://forum.syncthing.net/t/new-idea-using-dht/6980/20 "2016-04-05T15:50:07Z")

</div>

Hi

I started with Syncthing two weeks ago and it’s a great piece of work. I’m running my own infrastructure with relay and discovery server. Btw. running a discovery server behind an Apache reverse proxy wasn’t that easy to figure out the details 😉

Back to the topic: I have one node which is always online. Therefore it is reachable by all my mobile nodes. I defined the shares from my mobile devices and gave them share names. I published these shares to my central node. Unfortunately I gave them identically names. That is a problem. Finally, I ended up with names like ‘Devicename/Sharename’. Now it works.

It would be great to have share IDs. When I create a new share on a node, it should calculate a random id for that share. Additionally, I would enter a name, which has nothing to do with the syncing process itself.

What do you think?

Cheers Micha

[Next page](https://forum.syncthing.net/t/new-idea-using-dht/6980.md?page=2)
