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 support for NAT traversal techniques #1437

Open
wants to merge 20 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

Merge branch 'master' into nat-traversal

  • Loading branch information
oleiba committed Sep 6, 2018
commit 5f1f2c0a9ff39bb248bc27e9b0e5ddec30ecbb4d
@@ -95,13 +95,13 @@ class WebTorrent extends EventEmitter {
}
}

self._natTraversal = require('./lib/nat-traversal') // browser exclude
this._natTraversal = require('./lib/nat-traversal') // browser exclude

if (typeof TCPPool === 'function') {
self._tcpPool = new TCPPool(self)
this._tcpPool = new TCPPool(this)
} else {
process.nextTick(function () {
self._onListening()
this._onListening()
})
}

@@ -117,12 +117,12 @@ class WebTorrent extends EventEmitter {
this._destroy(err)
})

self.dht.once('listening', function () {
var address = self.dht.address()
this.dht.once('listening', function () {
var address = this.dht.address()
if (address) {
self.dhtPort = address.port
this.dhtPort = address.port
if (self._natTraversal.portMapping) {
self._natTraversal.portMapping(self.dhtPort, 'udp')
this._natTraversal.portMapping(this.dhtPort, 'udp')
}
}
})
@@ -384,15 +384,15 @@ class WebTorrent extends EventEmitter {
})
}

parallel(tasks, cb)

if (self._natTraversal.destroy) {
tasks.push(function (cb) {
self._natTraversal.destroy(cb)
})
}
if (this._natTraversal.destroy) {
tasks.push(function (cb) {
this._natTraversal.destroy(cb)
})
}

parallel(tasks, cb)
parallel(tasks, cb)

if (err) this.emit('error', err)

this.torrents = []
this._tcpPool = null
@@ -418,6 +418,7 @@ class WebTorrent extends EventEmitter {
this._natTraversal.portMapping(this.torrentPort, 'tcp')
}
}
this.emit('listening')
}

_debug () {
@@ -1,16 +1,12 @@
module.exports = Server

var arrayRemove = require('unordered-array-remove')
var http = require('http')
var mime = require('mime')
var pump = require('pump')
var rangeParser = require('range-parser')
var url = require('url')

function Server (torrent, opts) {
var server = http.createServer()
var natTraversal = require('./nat-traversal')
if (!opts) opts = {}
const arrayRemove = require('unordered-array-remove')
const http = require('http')
const mime = require('mime')
const pump = require('pump')
const rangeParser = require('range-parser')
const url = require('url')

function Server (torrent, opts = {}) {
const server = http.createServer()
if (!opts.origin) opts.origin = '*' // allow all origins by default

const sockets = []
You are viewing a condensed version of this merge commit. You can view the full changes here.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.