mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2024-12-14 11:26:25 +00:00
24 lines
584 B
JavaScript
24 lines
584 B
JavaScript
var Server = require('../').Server
|
|
|
|
exports.createServer = function (t, serverType, cb) {
|
|
var opts = serverType === 'http' ? { udp: false, ws: false } : { http: false, ws: 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)
|
|
})
|
|
}
|