Skip to content

Commit 7d12556

Browse files
committed
REFACTOR: remove all udp functionality from server, client, tests.
1 parent 051aa50 commit 7d12556

File tree

13 files changed

+3
-598
lines changed

13 files changed

+3
-598
lines changed

client/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const Peer = require('simple-peer')
66

77
const common = require('../lib/common')
88
const HTTPTracker = require('./http-tracker') // empty object in browser
9-
const UDPTracker = require('./udp-tracker') // empty object in browser
109
const WebSocketTracker = require('./websocket-tracker')
1110

1211
/**
@@ -102,8 +101,6 @@ class Client extends EventEmitter {
102101
if ((protocol === 'http:' || protocol === 'https:') &&
103102
typeof HTTPTracker === 'function') {
104103
return new HTTPTracker(this, announceUrl)
105-
} else if (protocol === 'udp:' && typeof UDPTracker === 'function') {
106-
return new UDPTracker(this, announceUrl)
107104
} else if ((protocol === 'ws:' || protocol === 'wss:') && webrtcSupport) {
108105
// Skip ws:// trackers on https:// sites because they throw SecurityError
109106
if (protocol === 'ws:' && typeof window !== 'undefined' &&

client/udp-tracker.js

Lines changed: 0 additions & 293 deletions
This file was deleted.

server/index.js

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const series = require('run-series')
44
const string2compact = require('string2compact')
55

66
const attachHttpService = require('./services/attachHttp')
7-
const attachUdpService = require('./services/attachUdp')
87
const attachWSService = require('./services/attachWS')
98
const setupStatsRoute = require('./services/statsRoute')
109
const common = require('../lib/common')
@@ -39,8 +38,6 @@ class Server extends EventEmitter {
3938
this.torrents = {};
4039

4140
this.http = null;
42-
this.udp4 = null;
43-
this.udp6 = null;
4441
this.ws = null;
4542

4643
debug("new server %s", JSON.stringify(opts));
@@ -61,10 +58,10 @@ class Server extends EventEmitter {
6158

6259
if (opts.http !== false) attachHttpService(this, onListening);
6360
if (opts.ws !== false) attachWSService(this, onListening);
64-
if (opts.udp !== false) attachUdpService(this, onListening);
6561
if (opts.stats !== false) setupStatsRoute(this, onListening);
6662

67-
let num = !!this.http + !!this.udp4 + !!this.udp6
63+
// TODO: UGH
64+
let num = !!this.http
6865
this.num = num
6966

7067
const self = this
@@ -78,16 +75,6 @@ class Server extends EventEmitter {
7875
}
7976
}
8077

81-
onListening() {
82-
this.num -= 1
83-
84-
if (this.num === 0) {
85-
this.listening = true
86-
debug('listening')
87-
this.emit('listening')
88-
}
89-
}
90-
9178
onError (err) {
9279
this.emit('error', err)
9380
}
@@ -109,17 +96,12 @@ class Server extends EventEmitter {
10996
}
11097

11198
const httpPort = isObject(port) ? (port.http || 0) : port
112-
const udpPort = isObject(port) ? (port.udp || 0) : port
11399

114100
// binding to :: only receives IPv4 connections if the bindv6only sysctl is set 0,
115101
// which is the default on many operating systems
116102
const httpHostname = isObject(hostname) ? hostname.http : hostname
117-
const udp4Hostname = isObject(hostname) ? hostname.udp : hostname
118-
const udp6Hostname = isObject(hostname) ? hostname.udp6 : hostname
119103

120104
if (this.http) this.http.listen(httpPort, httpHostname)
121-
if (this.udp4) this.udp4.bind(udpPort, udp4Hostname)
122-
if (this.udp6) this.udp6.bind(udpPort, udp6Hostname)
123105
}
124106

125107
close(cb) {
@@ -138,10 +120,7 @@ class Server extends EventEmitter {
138120
}
139121
}
140122

141-
[ this.udp4,
142-
this.udp6,
143-
this.ws
144-
].forEach(closeService)
123+
closeService(this.ws)
145124

146125
if (this.http) this.http.close(cb)
147126
else cb(null)

0 commit comments

Comments
 (0)