This PR merges webtorrent-tracker into this repo. Keeping the code in
sync between the two repos was becoming burdensome. This change should
not effect performance of the server since the webtorrent tracker is
disabled by default.
To enable the webtorrent tracker (disabled by default), do:
```js
var server = new Server({ ws: true })
```
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
This reverts commit 74d9139049.
Conflicts:
server.js
feross commented on 74d9139 5 hours ago
> Do we need to check for empty params here?
>
> _onRequest should return an error via callback because
> params.action is missing. Won't that work?
74d9139049 (commitcomment-8937428)
When you restart the tracker server, all peers it's tracking are
discarded. Then, clients that are already running will continue to send
`update` events, but the tracker throws them away because it was
expected to get a `start` event first.
This should only be a warning, and not a fatal error. I just made the
following changes:
- unexpected `started` event (for peer already in swarm) is treated as
an `update`
- unexpected `stopped` event is discarded
- unexpected `completed` event is treated as a `start`
- unexpected `update` event (from peer not in swarm) is treated as
`start`
Fixes#42