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

Add IPv6 DHT support #950

Open
wants to merge 3 commits into
base: master
from
Open
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Real init

  • Loading branch information
Aaron1011 committed Oct 17, 2016
commit bc77591f905a178f6784a2a07bfbe7fdea805c9d
@@ -22,8 +22,6 @@ var zeroFill = require('zero-fill')
var TCPPool = require('./lib/tcp-pool') // browser exclude
var Torrent = require('./lib/torrent')

var util = require('util')

/**
* WebTorrent version.
*/
@@ -122,26 +120,18 @@ function WebTorrent (opts) {
self._downloadSpeed = speedometer()
self._uploadSpeed = speedometer()

debug('Real init!')

// We need one DHT for IPv4, and one DHT for IPv6, as per BEP-0032:
// "A node wishing to participate in both DHTs must maintain two distinct routing tables, one for IPv4 and one for IPv6."

var newOpts

if (opts.dht !== false && typeof DHT === 'function' /* browser exclude */) {
newOpts = extend({ nodeId: self.nodeId, ipv6: false }, opts.dht)
debug('IPv4 dht: ' + util.inspect(opts, false, null))
self.dht = new DHT(newOpts)
self.dht = new DHT(extend({ nodeId: self.nodeId, ipv6: false }, opts.dht))
this._initDHT(self.dht)
} else {
self.dht = false
}

if (opts.dht6 !== false && typeof DHT === 'function' /* browser exclude */) {
newOpts = extend({ nodeId: self.nodeId, ipv6: true }, opts.dht6)
debug('IPv6 dht: ' + util.inspect(opts, false, null))
self.dht6 = new DHT(newOpts)
self.dht6 = new DHT(extend({ nodeId: self.nodeId, ipv6: true }, opts.dht6))
this._initDHT(self.dht6)
} else {
self.dht6 = false
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.