All Projects → mh-cbon → dht

mh-cbon / dht

Licence: other
golang dht / Kademlia

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to dht

ipvpn
[WIP] Easy-to-use decentralized secure overlay private network (for any device)
Stars: ✭ 24 (+0%)
Mutual labels:  dht, kademlia
dhtrobot
A kademila DHT implement in go
Stars: ✭ 40 (+66.67%)
Mutual labels:  dht, kademlia
peerstohttp
Simple torrent proxy to http stream controlled over REST-like api
Stars: ✭ 30 (+25%)
Mutual labels:  dht, kademlia
PhantasmaChain
Blockchain with native storage and smart contract integration.
Stars: ✭ 74 (+208.33%)
Mutual labels:  dht, kademlia
Layr
A decentralized (p2p) file storage system built atop Kademlia DHT that enforces data integrity, privacy, and availability through sharding, proofs of retrievability, redundancy, and encryption, with smart-contract powered incentive scheme
Stars: ✭ 90 (+275%)
Mutual labels:  dht, kademlia
Lbry Sdk
The LBRY SDK for building decentralized, censorship resistant, monetized, digital content apps.
Stars: ✭ 7,169 (+29770.83%)
Mutual labels:  dht, kademlia
Torsniff
torsniff - a sniffer that sniffs torrents from BitTorrent network
Stars: ✭ 3,800 (+15733.33%)
Mutual labels:  dht, bep0005
dht
golang dht(Distributed Hash Table) node
Stars: ✭ 30 (+25%)
Mutual labels:  dht, bep0005
Olric
Distributed cache and in-memory key/value data store. It can be used both as an embedded Go library and as a language-independent service.
Stars: ✭ 2,067 (+8512.5%)
Mutual labels:  dht
Magnetico
Autonomous (self-hosted) BitTorrent DHT search engine suite.
Stars: ✭ 2,626 (+10841.67%)
Mutual labels:  dht
Magnetw
磁力链接聚合搜索
Stars: ✭ 12,621 (+52487.5%)
Mutual labels:  dht
Magnet And Torrent Search Engine
磁力链接和 BT 种子的搜索引擎
Stars: ✭ 154 (+541.67%)
Mutual labels:  dht
Zx Bt
一个基于BitTorrent协议的DHT磁力嗅探器,并基于Elasticsearch存储/检索Torrent的Metadata信息
Stars: ✭ 244 (+916.67%)
Mutual labels:  dht
K Bucket
Kademlia DHT K-bucket implementation as a binary tree
Stars: ✭ 136 (+466.67%)
Mutual labels:  dht
tinyBT
Implementation of the Bittorrent and Mainline DHT protocol for Distributed Computing applications
Stars: ✭ 30 (+25%)
Mutual labels:  dht
Dhtcrawler
一个简单的dht爬虫,用于搜集infohash
Stars: ✭ 125 (+420.83%)
Mutual labels:  dht
Dht
BitTorrent DHT Protocol && DHT Spider.
Stars: ✭ 2,459 (+10145.83%)
Mutual labels:  dht
Chord
Implementation of Chord DHT(Distributed Hash Table) paper
Stars: ✭ 118 (+391.67%)
Mutual labels:  dht
Dht
dht is used by anacrolix/torrent, and is intended for use as a library in other projects both torrent related and otherwise
Stars: ✭ 184 (+666.67%)
Mutual labels:  dht
Dhtesp
Optimized DHT library for ESP32/ESP8266 using Arduino framework
Stars: ✭ 184 (+666.67%)
Mutual labels:  dht

dht

travis Status Go Report Card GoDoc MIT License

Package dht is a kademlia implementation of a Distributed Hash Table.

It implements bep05 / bep42 / bep43 / bep44

Useful resources

TOC

Api

> example/main2.go

// to test repetitive single lookup.
package main

import (
	"flag"
	"fmt"
	"log"

	"github.com/mh-cbon/dht/bootstrap"
	"github.com/mh-cbon/dht/bucket"
	"github.com/mh-cbon/dht/dht"
	"github.com/mh-cbon/dht/logger"
)

func main2() {
	var v bool
	flag.BoolVar(&v, "vv", false, "verbose mode")
	flag.Parse()

	ready := func(d *dht.DHT) error {
		if v {
			d.AddLogger(logger.Text(log.Printf))
		}
		fmt.Println("Running bootstrap...")
		publicIP, err := d.BootstrapAuto(nil, bootstrap.Public)
		if err != nil {
			return err
		}
		if publicIP != nil {
			log.Printf("public IP bootstrap %v:%v\n", publicIP.IP, publicIP.Port)
		}

		selfID := []byte(d.ID())
		fmt.Printf("your node id %x\n", selfID)

		// that s good, we are ready.

		fmt.Println("Boostrap done...")

		// you can run a lookup to find nodes matching an info_hash or target.
		// info_hash and target are hex string.
		target := "faf5c61ddcc5e8a2dabede0f3b482cd9aea9434c"
		targetID, _ := dht.HexToBytes(target)
		for {
			fmt.Printf("Performing lookup request for %x\n", targetID)
			lookupErr := d.LookupStores(target, nil)
			if lookupErr != nil {
				return lookupErr
			}

			// then get the closest peers for that target
			closest, err := d.ClosestStores(target, 16)
			if err != nil {
				return err
			}
			fmt.Printf("Found %v nodes close to %x\n", len(closest), targetID)
			for _, c := range closest {
				fmt.Printf("%-24v %x %v\n", c.GetAddr(), c.GetID(), bucket.Distance(targetID, c.GetID()))
			}
		}
		return nil
	}
	if err := dht.New(dht.DefaultOps()).Serve(ready); err != nil {
		if err != nil {
			log.Fatal(err)
		}
	}
}

Cli

The provided main.go program helps to play with the bittorrent/dht table.

  -annimplied
    	Announce an implied port.
  -annport int
    	The port of the announce query.
  -blocklist string
    	A peer guardian ip list to block (Some organization:1.0.0.0-1.255.255.255)
  -bnodes string
    	The boostrap node address list seprated by a coma, or public to use pre configured list of public bootstrap nodes, or 'no' to bootstrap empty
  -did string
    	The id of your node in the dht network
  -do string
    	The action to perform boostrap|closest_stores|closest_peers|ping|announce_peer|get_peers|find_node|get|put|genkey|sign (default "boostrap")
  -kconcurrency int
    	The number of nodes to refresh on k-bucket split (default 8)
  -keyname string
    	The name of the key
  -ksize int
    	The size of the k-buckets (default 20)
  -listen string
    	The listen address of the udp socket
  -pip string
    	The public ip of your node to share with other nodes.
  -qconcurrency int
    	The number of simultaneous outgoing requests (default 24)
  -qtimeout string
    	The query timeout (default "1s")
  -remote string
    	The remote address to query ip:port|closest_store|closest_peers
  -salt string
    	The salt to use to put/sign a value.
  -seq int
    	The seq value of get/put.
  -target string
    	Info hash target 20 bytes string hex encoded.
  -tsecret string
    	the secret of the token server
  -val string
    	A value to put.
  -vv
    	verbose mode
  -wait
    	Enter in wait mode after the command ran.

Cli Examples

go run main.go -do closest_peers -target faf5c61ddcc5e8a2dabede0f3b482cd9aea9434c -qtimeout 1s -vv -bnodes public

# run a node on 127...:9091, with an empty bootstrap, verbose, wait mode
go run main.go -listen 127.0.0.1:9091 -wait -bnodes no -vv

# sign a value prints useful information like keys, target etc
go run main.go -do sign -keyname bep44test -val "Hello World!"
go run main.go -do sign -keyname bep44test -val "Hello World!" -salt foobar

# put a value on a specific address (127.0.0.1:9090)
go run main.go -listen 127.0.0.1:9091 -bnodes no -remote "127.0.0.1:9090" -do put -val "Hello World!" -vv
# get a value from a remote
go run main.go -listen 127.0.0.1:9091 -bnodes no -remote "127.0.0.1:9090" -do get -target e5f96f6f38320f0f33959cb4d3d656452117aadb -vv

# put a mutable value on a specific address
go run main.go -listen 127.0.0.1:9091 -bnodes no -remote "127.0.0.1:9090" -do put -keyname bep44test -val "Hello World!" -salt foobar -seq 1 -vv
# get a mutable value on a specific address
go run main.go -listen 127.0.0.1:9091 -bnodes no -remote "127.0.0.1:9090" -do get -keyname bep44test -target 411eba73b6f087ca51a3795d9c8c938d365e32c1 -salt foobar -seq 1 -vv

Credits && inspiration

Thanks SO!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].