bittorrent-tracker/test/common.js
Feross Aboukhadijeh 82e6792a6b BREAKING CHANGES
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
2015-01-29 14:59:08 -08:00

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)
})
}