diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64f6689e..0bb7ae24 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: os: - ubuntu-latest node: - - '14' + - '18' steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e5302563..037e5acf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version: 14 + node-version: 18 - name: Cache uses: actions/cache@v3 with: diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index bd98abab..6db0d135 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -12,7 +12,7 @@ jobs: pull-requests: write steps: - - uses: actions/stale@v6 + - uses: actions/stale@v7 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-issue-message: 'Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?' diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d9e92d8..4150d276 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [10.0.2](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.1...v10.0.2) (2023-02-01) + + +### Bug Fixes + +* **deps:** update dependency ws to v8 ([#448](https://github.com/webtorrent/bittorrent-tracker/issues/448)) ([2209d4f](https://github.com/webtorrent/bittorrent-tracker/commit/2209d4f21bdee10e575c1728c3accf7bd34380c9)), closes [#449](https://github.com/webtorrent/bittorrent-tracker/issues/449) + ## [10.0.1](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.0...v10.0.1) (2022-12-07) diff --git a/lib/client/http-tracker.js b/lib/client/http-tracker.js index 8dfe718a..07b2990c 100644 --- a/lib/client/http-tracker.js +++ b/lib/client/http-tracker.js @@ -159,13 +159,13 @@ class HTTPTracker extends Tracker { } catch (err) { return cb(new Error(`Error decoding tracker response: ${err.message}`)) } - const failure = data['failure reason'] + const failure = data['failure reason'] && Buffer.from(data['failure reason']).toString() if (failure) { debug(`failure from ${requestUrl} (${failure})`) return cb(new Error(failure)) } - const warning = data['warning message'] + const warning = data['warning message'] && Buffer.from(data['warning message']).toString() if (warning) { debug(`warning from ${requestUrl} (${warning})`) self.client.emit('warning', new Error(warning)) @@ -194,10 +194,10 @@ class HTTPTracker extends Tracker { this.client.emit('update', response) let addrs - if (Buffer.isBuffer(data.peers)) { + if (ArrayBuffer.isView(data.peers)) { // tracker returned compact response try { - addrs = compact2string.multi(data.peers) + addrs = compact2string.multi(Buffer.from(data.peers)) } catch (err) { return this.client.emit('warning', err) } @@ -211,10 +211,10 @@ class HTTPTracker extends Tracker { }) } - if (Buffer.isBuffer(data.peers6)) { + if (ArrayBuffer.isView(data.peers6)) { // tracker returned compact response try { - addrs = compact2string.multi6(data.peers6) + addrs = compact2string.multi6(Buffer.from(data.peers6)) } catch (err) { return this.client.emit('warning', err) } diff --git a/package.json b/package.json index 856f18c8..4d0f3abb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bittorrent-tracker", "description": "Simple, robust, BitTorrent tracker (client & server) implementation", - "version": "10.0.1", + "version": "10.0.2", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", @@ -27,7 +27,7 @@ }, "type": "module", "dependencies": { - "bencode": "^3.0.0", + "bencode": "^3.0.3", "bittorrent-peerid": "^1.3.3", "bn.js": "^5.2.0", "chrome-dgram": "^3.0.6", @@ -49,15 +49,16 @@ "socks": "^2.0.0", "string2compact": "^2.0.0", "unordered-array-remove": "^1.0.2", - "ws": "^7.4.5" + "ws": "^8.0.0" }, "devDependencies": { + "@mapbox/node-pre-gyp": "1.0.10", "@webtorrent/semantic-release-config": "1.0.8", - "magnet-uri": "6.2.0", - "semantic-release": "19.0.5", + "magnet-uri": "7.0.2", + "semantic-release": "20.1.0", "standard": "*", - "tape": "5.6.1", - "webtorrent-fixtures": "2.0.0", + "tape": "5.6.3", + "webtorrent-fixtures": "2.0.2", "wrtc": "0.4.7" }, "engines": { diff --git a/server.js b/server.js index 3ef4349c..dd823f42 100644 --- a/server.js +++ b/server.js @@ -6,7 +6,7 @@ import http from 'http' import peerid from 'bittorrent-peerid' import series from 'run-series' import string2compact from 'string2compact' -import ws from 'ws' +import { WebSocketServer } from 'ws' import common from './lib/common.js' import Swarm from './lib/server/swarm.js' @@ -14,7 +14,6 @@ import parseHttpRequest from './lib/server/parse-http.js' import parseUdpRequest from './lib/server/parse-udp.js' import parseWebSocketRequest from './lib/server/parse-websocket.js' -const { Server: WebSocketServer } = ws const debug = Debug('bittorrent-tracker:server') const hasOwnProperty = Object.prototype.hasOwnProperty @@ -351,7 +350,7 @@ class Server extends EventEmitter { } createSwarm (infoHash, cb) { - if (Buffer.isBuffer(infoHash)) infoHash = infoHash.toString('hex') + if (ArrayBuffer.isView(infoHash)) infoHash = infoHash.toString('hex') process.nextTick(() => { const swarm = this.torrents[infoHash] = new Server.Swarm(infoHash, this) @@ -360,7 +359,7 @@ class Server extends EventEmitter { } getSwarm (infoHash, cb) { - if (Buffer.isBuffer(infoHash)) infoHash = infoHash.toString('hex') + if (ArrayBuffer.isView(infoHash)) infoHash = infoHash.toString('hex') process.nextTick(() => { cb(null, this.torrents[infoHash]) diff --git a/test/request-handler.js b/test/request-handler.js index b24110fa..6532cbbb 100644 --- a/test/request-handler.js +++ b/test/request-handler.js @@ -47,7 +47,7 @@ function testRequestHandler (t, serverType) { client1.once('update', data => { t.equal(data.complete, 246) - t.equal(data.extraData.toString(), 'hi') + t.equal(Buffer.from(data.extraData).toString(), 'hi') client1.destroy(() => { t.pass('client1 destroyed')