mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2024-12-13 19:06:27 +00:00
82e6792a6b
Breaking changes: - 'listening' event no longer emits with `port` param - `server.port` property removed (instead, use `server.http.address().port`) Added features: - expose http server as `server.http` - expose udp server as `server.udp` - client.destroy() - ungracefully leave the swarm - server: added `filter` option to black/whitelist torrents Bugfixes: - client considers udp tracker errors to be warnings - emit 'start', 'stop', 'update', etc. AFTER response sent - fix udp error response action and message being `undefined` Internal: - remove `portfinder` dep - add complete test for `filter` functionality
24 lines
562 B
JavaScript
24 lines
562 B
JavaScript
var Server = require('../').Server
|
|
|
|
exports.createServer = function (t, serverType, cb) {
|
|
var opts = serverType === 'http' ? { udp: false } : { http: false }
|
|
var server = new Server(opts)
|
|
|
|
server.on('error', function (err) {
|
|
t.error(err)
|
|
})
|
|
|
|
server.on('warning', function (err) {
|
|
t.error(err)
|
|
})
|
|
|
|
server.listen(0, function () {
|
|
var port = server[serverType].address().port
|
|
var announceUrl = serverType === 'http'
|
|
? 'http://127.0.0.1:' + port + '/announce'
|
|
: 'udp://127.0.0.1:' + port
|
|
|
|
cb(server, announceUrl)
|
|
})
|
|
}
|