Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulen Garcia Leunda <hicom150@gmail.com>2020-09-30 22:39:09 +0300
committerJulen Garcia Leunda <hicom150@gmail.com>2020-10-02 16:37:33 +0300
commit692b3d113c0a08a17ee53bca7e16180a94b4fbfe (patch)
tree07ba6df67701f9397d46a0ddaf26f7f5b2c880a1 /index.js
parent7aee819796c540df0b247fec1853098f9a591d4c (diff)
Add uTP support (BEP29)
Diffstat (limited to 'index.js')
-rw-r--r--index.js21
1 files changed, 11 insertions, 10 deletions
diff --git a/index.js b/index.js
index f024ba8..312ebe7 100644
--- a/index.js
+++ b/index.js
@@ -14,7 +14,7 @@ const Peer = require('simple-peer')
const randombytes = require('randombytes')
const speedometer = require('speedometer')
-const TCPPool = require('./lib/tcp-pool') // browser exclude
+const ConnPool = require('./lib/conn-pool') // browser exclude
const Torrent = require('./lib/torrent')
const VERSION = require('./package.json').version
@@ -72,6 +72,7 @@ class WebTorrent extends EventEmitter {
this.tracker = opts.tracker !== undefined ? opts.tracker : {}
this.torrents = []
this.maxConns = Number(opts.maxConns) || 55
+ this.utp = opts.utp === true
this._debug(
'new webtorrent (peerId %s, nodeId %s, port %s)',
@@ -95,8 +96,8 @@ class WebTorrent extends EventEmitter {
}
}
- if (typeof TCPPool === 'function') {
- this._tcpPool = new TCPPool(this)
+ if (typeof ConnPool === 'function') {
+ this._connPool = new ConnPool(this)
} else {
process.nextTick(() => {
this._onListening()
@@ -355,8 +356,8 @@ class WebTorrent extends EventEmitter {
address () {
if (!this.listening) return null
- return this._tcpPool
- ? this._tcpPool.server.address()
+ return this._connPool
+ ? this._connPool.tcpServer.address()
: { address: '0.0.0.0', family: 'IPv4', port: 0 }
}
@@ -377,9 +378,9 @@ class WebTorrent extends EventEmitter {
torrent.destroy(cb)
})
- if (this._tcpPool) {
+ if (this._connPool) {
tasks.push(cb => {
- this._tcpPool.destroy(cb)
+ this._connPool.destroy(cb)
})
}
@@ -394,7 +395,7 @@ class WebTorrent extends EventEmitter {
if (err) this.emit('error', err)
this.torrents = []
- this._tcpPool = null
+ this._connPool = null
this.dht = null
}
@@ -402,9 +403,9 @@ class WebTorrent extends EventEmitter {
this._debug('listening')
this.listening = true
- if (this._tcpPool) {
+ if (this._connPool) {
// Sometimes server.address() returns `null` in Docker.
- const address = this._tcpPool.server.address()
+ const address = this._connPool.tcpServer.address()
if (address) this.torrentPort = address.port
}