Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support the dht store extension #27

Open
faried opened this issue Aug 14, 2014 · 1 comment
Open

support the dht store extension #27

faried opened this issue Aug 14, 2014 · 1 comment

Comments

@faried
Copy link

faried commented Aug 14, 2014

Summary of the changes so far:

  • I can use libtorrent's code to query DHT nodes and get/put items.
  • I haven't written test cases or cleaned up the code.
  • It needs a lot of work.

I have a tarball of some partially working code here. It's the repository + my files. It really is a work in progress -- nowhere near ready for integration right now. Some of the code is likely incorrect; I explain why below.

I've tested libtorrent against my code, and using libtorrent's standalone dht_put program, I can both put and get immutable data from my modified DHT code. Here's what I did:

I started dht/examples/router on a server that's reachable from the internet. It's a small program that starts a DHT on port 9882, does not announce itself with the public routers, and waits forever for connections. I started the router with ./router -v=5 -logtostederr=true so I could see all the activity.
I downloaded and unpacked libtorrent-rasterbar-1.0.1, and added dht_put.cpp to the tools directory. I modified the file to make it use only my router node. To compile it, you can either modify tools/Makefile.am to add a build target for dht_put (you'll need automake 1.14 installed) or compile it manually.

After compiling dht_put, type ./dht_put put "hello there". It should talk to the router, and do a get followed by a put (you'll see that in the router's output). It'll print out the SHA-1 hash for the string 11:hello there, and you'll see the router store the value hello there. Next, if you try ./dht_put get <the hash>, it should talk to the router and return the string hello there. If you give it a different hash, it won't be able to fetch anything.

One thing that I didn't pay attention to carefully is the argument for put as described in the spec. You have to give it a valid object that can be bencoded -- a string, an integer, a list, or a dictionary. The code on both sides (the sending node and the storage node) will bencode the object before calculating the SHA-1 hash.

I'm sort of aiming for the same public UI for the DHT Get and Put methods: GET takes an infohash, and PUT takes a bencodable object (maybe as a string?).

One thing I haven't had much success with is using the DHT's methods to actually get/put stuff. I wrote a small amount of code (not in the tarball) to operate the same way as dht_put, but it seems to spin after it receives the string to be sent out over the network, somewhere in the put method in getput.go.

A problem I have is that I haven't looked at the client code (Taipei) yet, so I don't have a good idea on how to integrate things properly. I mean to work on this today (Thursday), but stuff came up at home, and I've been busy.

@nictuku
Copy link
Owner

nictuku commented Aug 14, 2014

Have a look at the examples directory, that might clarify how it is supposed to work.

@nictuku nictuku changed the title notes on supporting the dht store extension support the dht store extension Nov 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants