Caught this issue because of the new eviction tests. Essentially, this
change moves the socketPool into the client instance instead of a
reused variable at the module level.
When a client sends stop (or is evicted) the server will close the
websocket connection if that client is not in any other swarms (based
on peerId). However, if we are using a single socket for multiple
clients (as was the case before this commit), then other clients will
have their sockets unintentionally closed by the server.
Use the new Buffer APIs from Node v6 for added security. For example,
`Buffer.from()` will throw if passed a number, unlike `Buffer()` which
allocated UNINITIALIZED memory in that case.
Use the `safe-buffer` package for compatibility with previous versions
of
Node.js, including v4.x, v0.12, and v0.10.
https://github.com/feross/safe-buffer
To use the client, you used to pass in four arguments:
`new Client(peerId, port, parsedTorrent, opts)`
Now, passing in the torrent is no longer required, just the `announce`
and `infoHash` properties. This decouples this package from
`parse-torrent`.
All options get passed in together now:
new Client({
infoHash: '', // hex string or Buffer
peerId: '', // hex string or Buffer
announce: [], // list of tracker server urls
port: 6881 // torrent client port, (in browser, optional)
})
All the normal optional arguments (rtcConfig, wrtc, etc.) can still be
passed in with the rest of these options.
Fixes#118. Fixes#115.
Added ws tests for scrape.
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 })
```