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
path: root/lib
diff options
context:
space:
mode:
authorDiego Rodríguez <diegorbaquero@gmail.com>2018-08-31 02:08:39 +0300
committerDiego Rodríguez <diegorbaquero@gmail.com>2018-08-31 02:08:39 +0300
commitccf2f8daf235b4bf2dab61b553cb8f6b4626c705 (patch)
tree6e1fb51bd240479ccc46ccf54f1aad6c97d1452c /lib
parent12f3833cf6b3ab59b675ba77edf6c012e2f8824e (diff)
Fix standard errors
Diffstat (limited to 'lib')
-rw-r--r--lib/peer.js52
1 files changed, 26 insertions, 26 deletions
diff --git a/lib/peer.js b/lib/peer.js
index 90dfc30..0ddf535 100644
--- a/lib/peer.js
+++ b/lib/peer.js
@@ -1,12 +1,12 @@
-const arrayRemove = require('unordered-array-remove');
-const debug = require('debug')('webtorrent:peer');
-const Wire = require('bittorrent-protocol');
+const arrayRemove = require('unordered-array-remove')
+const debug = require('debug')('webtorrent:peer')
+const Wire = require('bittorrent-protocol')
-const WebConn = require('./webconn');
+const WebConn = require('./webconn')
-const CONNECT_TIMEOUT_TCP = 5000;
-const CONNECT_TIMEOUT_WEBRTC = 25000;
-const HANDSHAKE_TIMEOUT = 25000;
+const CONNECT_TIMEOUT_TCP = 5000
+const CONNECT_TIMEOUT_WEBRTC = 25000
+const HANDSHAKE_TIMEOUT = 25000
/**
* WebRTC peer connections start out connected, because WebRTC peers require an
@@ -14,7 +14,7 @@ const HANDSHAKE_TIMEOUT = 25000;
* that lets you refer to a WebRTC endpoint.
*/
exports.createWebRTCPeer = (conn, swarm) => {
- const peer = new Peer(conn.id, 'webrtc');
+ const peer = new Peer(conn.id, 'webrtc')
peer.conn = conn
peer.swarm = swarm
@@ -35,8 +35,8 @@ exports.createWebRTCPeer = (conn, swarm) => {
* know what swarm the connection is intended for.
*/
exports.createTCPIncomingPeer = conn => {
- const addr = `${conn.remoteAddress}:${conn.remotePort}`;
- const peer = new Peer(addr, 'tcpIncoming');
+ const addr = `${conn.remoteAddress}:${conn.remotePort}`
+ const peer = new Peer(addr, 'tcpIncoming')
peer.conn = conn
peer.addr = addr
@@ -50,7 +50,7 @@ exports.createTCPIncomingPeer = conn => {
* available connection), the client can attempt to connect to the address.
*/
exports.createTCPOutgoingPeer = (addr, swarm) => {
- const peer = new Peer(addr, 'tcpOutgoing');
+ const peer = new Peer(addr, 'tcpOutgoing')
peer.addr = addr
peer.swarm = swarm
@@ -61,7 +61,7 @@ exports.createTCPOutgoingPeer = (addr, swarm) => {
* Peer that represents a Web Seed (BEP17 / BEP19).
*/
exports.createWebSeedPeer = (url, swarm) => {
- const peer = new Peer(url, 'webSeed');
+ const peer = new Peer(url, 'webSeed')
peer.swarm = swarm
peer.conn = new WebConn(url, swarm)
@@ -77,7 +77,7 @@ exports.createWebSeedPeer = (url, swarm) => {
* @param {string} type the type of the peer
*/
class Peer {
- constructor(id, type) {
+ constructor (id, type) {
this.id = id
this.type = type
@@ -100,7 +100,7 @@ class Peer {
* Called once the peer is connected (i.e. fired 'connect' event)
* @param {Socket} conn
*/
- onConnect() {
+ onConnect () {
if (this.destroyed) return
this.connected = true
@@ -108,7 +108,7 @@ class Peer {
clearTimeout(this.connectTimeout)
- const conn = this.conn;
+ const conn = this.conn
conn.once('end', () => {
this.destroy()
})
@@ -122,7 +122,7 @@ class Peer {
this.destroy(err)
})
- const wire = this.wire = new Wire();
+ const wire = this.wire = new Wire()
wire.type = this.type
wire.once('end', () => {
this.destroy()
@@ -151,7 +151,7 @@ class Peer {
* @param {string} infoHash
* @param {string} peerId
*/
- onHandshake(infoHash, peerId) {
+ onHandshake (infoHash, peerId) {
if (!this.swarm) return // `this.swarm` not set yet, so do nothing
if (this.destroyed) return
@@ -171,7 +171,7 @@ class Peer {
this.retries = 0
- let addr = this.addr;
+ let addr = this.addr
if (!addr && this.conn.remoteAddress && this.conn.remotePort) {
addr = `${this.conn.remoteAddress}:${this.conn.remotePort}`
}
@@ -183,15 +183,15 @@ class Peer {
if (!this.sentHandshake) this.handshake()
}
- handshake() {
+ handshake () {
const opts = {
dht: this.swarm.private ? false : !!this.swarm.client.dht
- };
+ }
this.wire.handshake(this.swarm.infoHash, this.swarm.client.peerId, opts)
this.sentHandshake = true
}
- startConnectTimeout() {
+ startConnectTimeout () {
clearTimeout(this.connectTimeout)
this.connectTimeout = setTimeout(() => {
this.destroy(new Error('connect timeout'))
@@ -199,7 +199,7 @@ class Peer {
if (this.connectTimeout.unref) this.connectTimeout.unref()
}
- startHandshakeTimeout() {
+ startHandshakeTimeout () {
clearTimeout(this.handshakeTimeout)
this.handshakeTimeout = setTimeout(() => {
this.destroy(new Error('handshake timeout'))
@@ -207,7 +207,7 @@ class Peer {
if (this.handshakeTimeout.unref) this.handshakeTimeout.unref()
}
- destroy(err) {
+ destroy (err) {
if (this.destroyed) return
this.destroyed = true
this.connected = false
@@ -217,9 +217,9 @@ class Peer {
clearTimeout(this.connectTimeout)
clearTimeout(this.handshakeTimeout)
- const swarm = this.swarm;
- const conn = this.conn;
- const wire = this.wire;
+ const swarm = this.swarm
+ const conn = this.conn
+ const wire = this.wire
this.swarm = null
this.conn = null