• Stars
    star
    401
  • Rank 107,625 (Top 3 %)
  • Language
    C++
  • License
    MIT License
  • Created about 11 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

DHT bootstrap server

bootstrap-dht

The DHT bootstrap server can be used as an introducer to the bittorrent DHT network. Like the ones running at router.utorrent.com and router.bittorrent.com.

BitTorrent clients can use this server to join the DHT, assuming some number of clients are agreeing on using the same server.

The command line options are:

usage: dht-bootstrap <external-IP> [options]

OPTIONS:
--help                prints this message.
--threads <n>         spawns <n> threads (defaults to the
                      number of hardware cores).
--nodes <n>           sets the number of nodes to keep in
                      the node buffer. Once full, the oldest
                      nodes are replaced as new nodes come in.
--ping-queue <n>      sets the max number of nodes to keep in
                      the ping queue. Nodes are held in the queue
                      for 15 minutes.
--no-verify-id        disable filtering nodes based on their node ID
                      and external IP (allow any node in on the
                      node list to hand out).
--ipv6 <ip>           listen for IPv6 packets on the given address
                      can be specified more than once
--version <version>   The client version to insert into all outgoing
                      packets. The version format must be 2 characters
                      followed by a dash and an integer.
--dir <path>          specify the directory where the node buckets are
                      stored on disk. Defaults to ".".
--port <listen-port>  Sets the port to listen on (for all interfaces)
                      defaults to 6881
--x-pollinate <ip> <port>
                      if the ping queue becomes too small, request more
                      nodes from this DHT node.

The first argument when launching the server is its own IP. This is not only relevant for binding the socket to this interface but is also used when generating its own DHT node ID.

The number of threads defaults to the number of CPU cores but can be overridden by the --threads argument.

The number of DHT nodes to keep in the cache of nodes to hand out defaults to 10000000 and can be overridden by --nodes. It may not be lower than 1000.

The ping queue is the max number of nodes allowed in the queue waiting to be pinged. Nodes are (ideally) pinged 15 minutes after seen. If too many nodes are pinging the dht-bootstrapper to hold them all for 15 minutes in the ping buffer, the rate of pinging is throttled to match.

For example, the default of 5000000 nodes in the ping buffer restricts the ping rate to (5000000 / 900 = ) 5555 pings per second. Experience from router.utorrent.com suggests that about 45% of pings succeeds and end up being added to the node buffer. At the default rate, that means the entire node buffer is replaced every 66 minutes. i.e. once you're in the node buffer, you'll be handed out to nodes for abut 66 minutes before you are replaced by someone else.

The current rate at router.utorrent.com is about 20000 requests per second. Every request returns 16 nodes. That means every node in the node buffer is handed out once every (10000000 / 16 / 20000 ~=) 31 seconds.

Only nodes whose node ID match their external IP address (according to this) are pinged.

dht-bootstrap listens on port 6881 by default. You may specify a different port using the --port command line option.

A more detailed description of how it's implemented can be found in the header of main.cpp.

The source for the bootstrap server is released under the MIT license. Please contribute back fixes and improvements!

building

To build, you need boost and boost-build installed. Build by running: b2.

If you prefer to build manually, just compile main.cpp, bdecode.cpp and link against the boost.system library as well as adding boost to your include path.

To build you need a compiler with C++11 support.

acknowledgments

Thanks to following people who have contributed code or discovered bugs in bootstrap-dht:

Team_LPJ@BoB working with Zero Day Initiative (ZDI)

More Repositories

1

libutp

uTorrent Transport Protocol library
C++
1,074
star
2

bittorrent.org

HTML
356
star
3

sqltorrent

C
265
star
4

go-btfs

BTFS - The First Scalable Decentralized Storage System - A Foundational Platform for Decentralized Applications
HTML
231
star
5

btc

Command-line BitTorrent remote control (btc)
Python
153
star
6

scout

Securely locate peers without central servers
C
151
star
7

webui

JavaScript
112
star
8

bencode

Python
75
star
9

libbtdht

C++
38
star
10

Helix

BitTorrent Tracker
C++
32
star
11

okui

An okay OpenGL-based UI framework.
C++
30
star
12

btfs-dashboard

A Client helps users to manage their BTFS nodes
JavaScript
25
star
13

scraps

Useful scraps of C++.
C++
21
star
14

BTIPs

The BTFS Improvement Proposal repository
18
star
15

sync_api_sample

Python
11
star
16

ut-signing-tool

C++
10
star
17

libbtutils

C++
10
star
18

sync_slack

BitTorrent Sync sample integration with Slack
Python
8
star
19

utorrent_help

Utorrent and bittorrent help files
CSS
7
star
20

simon

A tool to judge your code
Python
7
star
21

sitrep

Public-facing status reports for your infrastructure.
Python
7
star
22

librtmp

Ticket #5945
C
6
star
23

tornado-sqs

Python
6
star
24

social

Home of the social media library for Bittorrent Apps
JavaScript
5
star
25

widgets

The Bittorrent Widgets package is a collection of widgets that integrate with the Apps for BitTorrent SDK, and simplify common behaviors.
JavaScript
4
star
26

org.bittorrent.scribble

Clojure library for generating Graphite graph URLs
Clojure
4
star
27

boost_1_44_0

C++
3
star
28

live-build-environments

Build environments for our stuff
Shell
3
star
29

btfs-airdrop

Solidity
3
star
30

generator-btapp

yeoman webapp generator fork for a btapp sites
JavaScript
3
star
31

ipboard_proxy

Ruby
2
star
32

btfs-encryption

Go
2
star
33

jshackle

Helper macros for JNI programming
C++
2
star
34

docker-kubectl

Docker container for kubectl
1
star
35

live-ci-tools

A [small] collection of CI tools
Python
1
star
36

SDL

Fork of SDL with some minor tweaks
C
1
star
37

go-btfs-cmds

Go
1
star
38

cookbook-bt-foo

Ruby
1
star
39

libtommath-test

C
1
star
40

bigcouch-bin

bigcouch binary repo
Python
1
star
41

mongoose-context-protected-plugin

JavaScript
1
star
42

btfs-vault

Cheque protocol of BTFS node
JavaScript
1
star