From 3bda69834517771cfd682640296ae783a9fae074 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Tue, 16 Nov 2021 08:37:32 +0000 Subject: [PATCH 001/119] chore(deps): update dependency tape to v5.3.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 63cc9e52..141b4e20 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "magnet-uri": "6.2.0", "semantic-release": "18.0.0", "standard": "*", - "tape": "5.3.1", + "tape": "5.3.2", "webtorrent-fixtures": "1.7.5", "wrtc": "0.4.7" }, From ebbeb2fc49da913c7a2498eb97aec82b9cc510a7 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Wed, 24 Nov 2021 08:38:27 +0000 Subject: [PATCH 002/119] chore(deps): update dependency semantic-release to v18.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 141b4e20..ee70f779 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "devDependencies": { "@webtorrent/semantic-release-config": "1.0.7", "magnet-uri": "6.2.0", - "semantic-release": "18.0.0", + "semantic-release": "18.0.1", "standard": "*", "tape": "5.3.2", "webtorrent-fixtures": "1.7.5", From 8d156c7cc05fe85443af7ec14f35acbf158058df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Rodr=C3=ADguez=20Baquero?= Date: Thu, 25 Nov 2021 11:50:52 -0500 Subject: [PATCH 003/119] doc: trust proxy opt --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a7a5724d..02261001 100644 --- a/README.md +++ b/README.md @@ -189,6 +189,7 @@ var server = new Server({ http: true, // enable http server? [default=true] ws: true, // enable websocket server? [default=true] stats: true, // enable web-based statistics? [default=true] + trustProxy: false // enable trusting x-forwarded-for header for remote IP [default=false] filter: function (infoHash, params, cb) { // Blacklist/whitelist function for allowing/disallowing torrents. If this option is // omitted, all torrents are allowed. It is possible to interface with a database or From b0227c311e817454a1cf774d1d64e34e7978b1e6 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sun, 26 Dec 2021 07:56:36 +0000 Subject: [PATCH 004/119] chore(deps): update dependency tape to v5.4.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ee70f779..2b11c932 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "magnet-uri": "6.2.0", "semantic-release": "18.0.1", "standard": "*", - "tape": "5.3.2", + "tape": "5.4.0", "webtorrent-fixtures": "1.7.5", "wrtc": "0.4.7" }, From b21d2ccc770de1cb471c146f9b9023f128ce5434 Mon Sep 17 00:00:00 2001 From: Bruce Hopkins Date: Tue, 4 Jan 2022 00:54:05 +0100 Subject: [PATCH 005/119] Updated docs to better match default server config (#405) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Updated docs to better match default server config * docs: updated to more recent version * docs: Changed var to const * Update README.md Co-authored-by: Diego Rodríguez Baquero --- README.md | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 02261001..0e95760d 100644 --- a/README.md +++ b/README.md @@ -182,14 +182,14 @@ client.on('scrape', function (data) { To start a BitTorrent tracker server to track swarms of peers: ```js -var Server = require('bittorrent-tracker').Server +const Server = require('bittorrent-tracker').Server -var server = new Server({ +const server = new Server({ udp: true, // enable udp server? [default=true] http: true, // enable http server? [default=true] ws: true, // enable websocket server? [default=true] stats: true, // enable web-based statistics? [default=true] - trustProxy: false // enable trusting x-forwarded-for header for remote IP [default=false] + trustProxy: false, // enable trusting x-forwarded-for header for remote IP [default=false] filter: function (infoHash, params, cb) { // Blacklist/whitelist function for allowing/disallowing torrents. If this option is // omitted, all torrents are allowed. It is possible to interface with a database or @@ -201,7 +201,7 @@ var server = new Server({ // This example only allows one torrent. - var allowed = (infoHash === 'aaa67059ed6bd08362da625b3ae77f6f4a075aaa') + const allowed = (infoHash === 'aaa67059ed6bd08362da625b3ae77f6f4a075aaa') if (allowed) { // If the callback is passed `null`, the torrent will be allowed. cb(null) @@ -230,12 +230,34 @@ server.on('warning', function (err) { server.on('listening', function () { // fired when all requested servers are listening - console.log('listening on http port:' + server.http.address().port) - console.log('listening on udp port:' + server.udp.address().port) + + // HTTP + const httpAddr = server.http.address() + const httpHost = httpAddr.address !== '::' ? httpAddr.address : 'localhost' + const httpPort = httpAddr.port + console.log(`HTTP tracker: http://${httpHost}:${httpPort}/announce`) + + // UDP + const udpAddr = server.udp.address() + const udpHost = udpAddr.address + const udpPort = udpAddr.port + console.log(`UDP tracker: udp://${udpHost}:${udpPort}`) + + // WS + const wsAddr = server.http.address() + const wsHost = wsAddr.address !== '::' ? wsAddr.address : 'localhost' + const wsPort = wsAddr.port + console.log(`WebSocket tracker: ws://${wsHost}:${wsPort}`) + }) + // start tracker server listening! Use 0 to listen on a random free port. -server.listen(port, hostname, onlistening) +const port = 0 +const hostname = "localhost" +server.listen(port, hostname, () => { + // Do something on listening... +}) // listen for individual tracker messages from peers: From 4df012037f34dfc644ec5972b9450063ddba83a9 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sun, 16 Jan 2022 04:20:20 +0000 Subject: [PATCH 006/119] chore(deps): update dependency tape to v5.4.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b11c932..e66d78e2 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "magnet-uri": "6.2.0", "semantic-release": "18.0.1", "standard": "*", - "tape": "5.4.0", + "tape": "5.4.1", "webtorrent-fixtures": "1.7.5", "wrtc": "0.4.7" }, From e3bbfc6260e39f69f8f33dc3d5e4424f5d93e617 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Wed, 26 Jan 2022 21:49:36 +0000 Subject: [PATCH 007/119] chore(deps): update dependency tape to v5.5.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e66d78e2..2771826f 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "magnet-uri": "6.2.0", "semantic-release": "18.0.1", "standard": "*", - "tape": "5.4.1", + "tape": "5.5.0", "webtorrent-fixtures": "1.7.5", "wrtc": "0.4.7" }, From 09f8d15d3315ed28b48b31e43efa26defdcb2781 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 11 Feb 2022 08:11:06 +0000 Subject: [PATCH 008/119] chore(deps): update dependency tape to v5.5.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2771826f..13bce4cf 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "magnet-uri": "6.2.0", "semantic-release": "18.0.1", "standard": "*", - "tape": "5.5.0", + "tape": "5.5.1", "webtorrent-fixtures": "1.7.5", "wrtc": "0.4.7" }, From 74065c7b6192f488d74eff9e818072bc627d9ba4 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sun, 13 Feb 2022 03:25:53 +0000 Subject: [PATCH 009/119] chore(deps): update dependency tape to v5.5.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 13bce4cf..183ad5e2 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "magnet-uri": "6.2.0", "semantic-release": "18.0.1", "standard": "*", - "tape": "5.5.1", + "tape": "5.5.2", "webtorrent-fixtures": "1.7.5", "wrtc": "0.4.7" }, From 023afb9a3228d60392a18e70f85cdb6af5fa79fb Mon Sep 17 00:00:00 2001 From: Ryan Finnie Date: Sat, 5 Mar 2022 16:17:19 -0800 Subject: [PATCH 010/119] fix: typo in ws example (#417) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e95760d..1f2a791c 100644 --- a/README.md +++ b/README.md @@ -244,7 +244,7 @@ server.on('listening', function () { console.log(`UDP tracker: udp://${udpHost}:${udpPort}`) // WS - const wsAddr = server.http.address() + const wsAddr = server.ws.address() const wsHost = wsAddr.address !== '::' ? wsAddr.address : 'localhost' const wsPort = wsAddr.port console.log(`WebSocket tracker: ws://${wsHost}:${wsPort}`) From 048bc455a78d5465d28fd7a7a77b5eebc684f587 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Sun, 6 Mar 2022 00:18:16 +0000 Subject: [PATCH 011/119] chore(release): 9.18.4 ## [9.18.4](https://github.com/webtorrent/bittorrent-tracker/compare/v9.18.3...v9.18.4) (2022-03-06) ### Bug Fixes * typo in ws example ([#417](https://github.com/webtorrent/bittorrent-tracker/issues/417)) ([023afb9](https://github.com/webtorrent/bittorrent-tracker/commit/023afb9a3228d60392a18e70f85cdb6af5fa79fb)) --- AUTHORS.md | 2 ++ CHANGELOG.md | 7 +++++++ package.json | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index e9a486a8..dd2a8b05 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -57,5 +57,7 @@ - semantic-release-bot (semantic-release-bot@martynus.net) - renovate[bot] (29139614+renovate[bot]@users.noreply.github.com) - Jocelyn Liu (yrliou@gmail.com) +- Bruce Hopkins (behopkinsjr@gmail.com) +- Ryan Finnie (ryan@finnie.org) #### Generated by tools/update-authors.sh. diff --git a/CHANGELOG.md b/CHANGELOG.md index b5f55ecc..ff662d03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [9.18.4](https://github.com/webtorrent/bittorrent-tracker/compare/v9.18.3...v9.18.4) (2022-03-06) + + +### Bug Fixes + +* typo in ws example ([#417](https://github.com/webtorrent/bittorrent-tracker/issues/417)) ([023afb9](https://github.com/webtorrent/bittorrent-tracker/commit/023afb9a3228d60392a18e70f85cdb6af5fa79fb)) + ## [9.18.3](https://github.com/webtorrent/bittorrent-tracker/compare/v9.18.2...v9.18.3) (2021-10-29) diff --git a/package.json b/package.json index 183ad5e2..1d901988 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bittorrent-tracker", "description": "Simple, robust, BitTorrent tracker (client & server) implementation", - "version": "9.18.3", + "version": "9.18.4", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", From e07721851f60f667213694ae46238f93fdd88d18 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 6 Mar 2022 01:19:00 +0100 Subject: [PATCH 012/119] chore(deps): update actions/setup-node action to v3 (#414) Co-authored-by: Renovate Bot --- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 822d21cc..122667ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: - '14' steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node }} - run: npm install diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6098b8e6..4920ce1c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,7 +15,7 @@ jobs: with: persist-credentials: false - name: Setup Node.js - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: node-version: 14 - name: Cache From aa2dc81dc3517b42c7bf66f829a019b3fa647358 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 6 Mar 2022 01:19:58 +0100 Subject: [PATCH 013/119] chore(deps): update actions/stale action to v5 (#416) Co-authored-by: Renovate Bot --- .github/workflows/stale.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 72597d8e..546af60a 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -12,7 +12,7 @@ jobs: pull-requests: write steps: - - uses: actions/stale@v4 + - uses: actions/stale@v5 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?' From 330301ab00a51110f435fa1b4b707d6219e6d8d1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 6 Mar 2022 01:23:16 +0100 Subject: [PATCH 014/119] chore(deps): update actions/checkout action to v3 (#415) Co-authored-by: Renovate Bot --- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 122667ca..64f6689e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: node: - '14' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4920ce1c..d7bf1e60 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: persist-credentials: false - name: Setup Node.js From f7928cfcc646cd95556549b64e61228892314682 Mon Sep 17 00:00:00 2001 From: Lookis Date: Fri, 25 Mar 2022 16:43:36 +0800 Subject: [PATCH 015/119] fix: connection leaks (#420) --- lib/client/websocket-tracker.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/client/websocket-tracker.js b/lib/client/websocket-tracker.js index 1573cfd2..7c48858b 100644 --- a/lib/client/websocket-tracker.js +++ b/lib/client/websocket-tracker.js @@ -301,6 +301,7 @@ class WebSocketTracker extends Tracker { clearTimeout(peer.trackerTimeout) peer.trackerTimeout = null delete this.peers[offerId] + peer.destroy() } else { debug(`got unexpected answer: ${JSON.stringify(data.answer)}`) } From 2a79101ef73e7e5d94a48544a009a3ea2458c63b Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 25 Mar 2022 08:44:32 +0000 Subject: [PATCH 016/119] chore(release): 9.18.5 ## [9.18.5](https://github.com/webtorrent/bittorrent-tracker/compare/v9.18.4...v9.18.5) (2022-03-25) ### Bug Fixes * connection leaks ([#420](https://github.com/webtorrent/bittorrent-tracker/issues/420)) ([f7928cf](https://github.com/webtorrent/bittorrent-tracker/commit/f7928cfcc646cd95556549b64e61228892314682)) --- AUTHORS.md | 1 + CHANGELOG.md | 7 +++++++ package.json | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index dd2a8b05..ccffe922 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -59,5 +59,6 @@ - Jocelyn Liu (yrliou@gmail.com) - Bruce Hopkins (behopkinsjr@gmail.com) - Ryan Finnie (ryan@finnie.org) +- Lookis (lookisliu@gmail.com) #### Generated by tools/update-authors.sh. diff --git a/CHANGELOG.md b/CHANGELOG.md index ff662d03..a7dc4711 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [9.18.5](https://github.com/webtorrent/bittorrent-tracker/compare/v9.18.4...v9.18.5) (2022-03-25) + + +### Bug Fixes + +* connection leaks ([#420](https://github.com/webtorrent/bittorrent-tracker/issues/420)) ([f7928cf](https://github.com/webtorrent/bittorrent-tracker/commit/f7928cfcc646cd95556549b64e61228892314682)) + ## [9.18.4](https://github.com/webtorrent/bittorrent-tracker/compare/v9.18.3...v9.18.4) (2022-03-06) diff --git a/package.json b/package.json index 1d901988..8c654dda 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bittorrent-tracker", "description": "Simple, robust, BitTorrent tracker (client & server) implementation", - "version": "9.18.4", + "version": "9.18.5", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", From 4b041ca3148e2d2dbc1f62326aff4d4ca48ce58a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 27 Mar 2022 22:47:49 +0300 Subject: [PATCH 017/119] chore(deps): update actions/cache action to v3 (#419) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): update actions/cache action to v3 * Update release.yml Co-authored-by: Renovate Bot Co-authored-by: Diego Rodríguez Baquero --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d7bf1e60..996fb728 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,9 +17,9 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version: 14 + node-version: 16 - name: Cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.npm key: ${{ runner.os }}-npm-${{ hashFiles('**/package.json') }} From 38c4fdbcc17f633590c0d592874a65586e447a5b Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 8 Apr 2022 19:36:06 +0000 Subject: [PATCH 018/119] chore(deps): update dependency tape to v5.5.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8c654dda..d048746e 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "magnet-uri": "6.2.0", "semantic-release": "18.0.1", "standard": "*", - "tape": "5.5.2", + "tape": "5.5.3", "webtorrent-fixtures": "1.7.5", "wrtc": "0.4.7" }, From 8d54938f164347d57a7991268d191e44b752de7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Rodr=C3=ADguez=20Baquero?= Date: Tue, 10 May 2022 19:56:27 -0500 Subject: [PATCH 019/119] fix: revert #420 --- lib/client/websocket-tracker.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/client/websocket-tracker.js b/lib/client/websocket-tracker.js index 7c48858b..1573cfd2 100644 --- a/lib/client/websocket-tracker.js +++ b/lib/client/websocket-tracker.js @@ -301,7 +301,6 @@ class WebSocketTracker extends Tracker { clearTimeout(peer.trackerTimeout) peer.trackerTimeout = null delete this.peers[offerId] - peer.destroy() } else { debug(`got unexpected answer: ${JSON.stringify(data.answer)}`) } From 01202185e605368c4833d5d38fc0a71d2e700aca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Rodr=C3=ADguez=20Baquero?= Date: Tue, 10 May 2022 20:01:52 -0500 Subject: [PATCH 020/119] ci: rollback to node 14 --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 996fb728..e5302563 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: 16 + node-version: 14 - name: Cache uses: actions/cache@v3 with: From a048097ab41231f15b835c44bc7ed24008afb9ec Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 11 May 2022 01:02:38 +0000 Subject: [PATCH 021/119] chore(release): 9.18.6 ## [9.18.6](https://github.com/webtorrent/bittorrent-tracker/compare/v9.18.5...v9.18.6) (2022-05-11) ### Bug Fixes * revert [#420](https://github.com/webtorrent/bittorrent-tracker/issues/420) ([8d54938](https://github.com/webtorrent/bittorrent-tracker/commit/8d54938f164347d57a7991268d191e44b752de7f)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7dc4711..79f8df94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [9.18.6](https://github.com/webtorrent/bittorrent-tracker/compare/v9.18.5...v9.18.6) (2022-05-11) + + +### Bug Fixes + +* revert [#420](https://github.com/webtorrent/bittorrent-tracker/issues/420) ([8d54938](https://github.com/webtorrent/bittorrent-tracker/commit/8d54938f164347d57a7991268d191e44b752de7f)) + ## [9.18.5](https://github.com/webtorrent/bittorrent-tracker/compare/v9.18.4...v9.18.5) (2022-03-25) diff --git a/package.json b/package.json index d048746e..7271f05b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bittorrent-tracker", "description": "Simple, robust, BitTorrent tracker (client & server) implementation", - "version": "9.18.5", + "version": "9.18.6", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", From ef76b3f3b6beee87f57d74addd0ca2ef2c517b6d Mon Sep 17 00:00:00 2001 From: Paul Sharypov Date: Wed, 1 Jun 2022 18:23:38 +0300 Subject: [PATCH 022/119] feat(events): Support of `paused` client event (#411) * feat: Added `paused` client event * fix(events): fixed 'invalid event' response on 'paused' request from client * fix(styles): fixed extra semicolon --- lib/common-node.js | 8 +++++--- lib/server/swarm.js | 11 +++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/common-node.js b/lib/common-node.js index b570f2b1..dab4b675 100644 --- a/lib/common-node.js +++ b/lib/common-node.js @@ -11,18 +11,20 @@ exports.REMOVE_IPV4_MAPPED_IPV6_RE = /^::ffff:/ exports.CONNECTION_ID = Buffer.concat([toUInt32(0x417), toUInt32(0x27101980)]) exports.ACTIONS = { CONNECT: 0, ANNOUNCE: 1, SCRAPE: 2, ERROR: 3 } -exports.EVENTS = { update: 0, completed: 1, started: 2, stopped: 3 } +exports.EVENTS = { update: 0, completed: 1, started: 2, stopped: 3, paused: 4 } exports.EVENT_IDS = { 0: 'update', 1: 'completed', 2: 'started', - 3: 'stopped' + 3: 'stopped', + 4: 'paused' } exports.EVENT_NAMES = { update: 'update', completed: 'complete', started: 'start', - stopped: 'stop' + stopped: 'stop', + paused: 'pause' } /** diff --git a/lib/server/swarm.js b/lib/server/swarm.js index 8194270f..c3602133 100644 --- a/lib/server/swarm.js +++ b/lib/server/swarm.js @@ -47,6 +47,8 @@ class Swarm { self._onAnnounceCompleted(params, peer, id) } else if (params.event === 'update') { self._onAnnounceUpdate(params, peer, id) + } else if (params.event === 'paused') { + self._onAnnouncePaused(params, peer, id) } else { cb(new Error('invalid event')) return @@ -132,6 +134,15 @@ class Swarm { this.peers.set(id, peer) } + _onAnnouncePaused (params, peer, id) { + if (!peer) { + debug('unexpected `paused` event from peer that is not in swarm') + return this._onAnnounceStarted(params, peer, id) // treat as a start + } + + this._onAnnounceUpdate(params, peer, id) + } + _getPeers (numwant, ownPeerId, isWebRTC) { const peers = [] const ite = randomIterate(this.peers.keys) From 4b5299b691e93b98038c6de3423fb22db55b0816 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 1 Jun 2022 15:26:39 +0000 Subject: [PATCH 023/119] chore(release): 9.19.0 # [9.19.0](https://github.com/webtorrent/bittorrent-tracker/compare/v9.18.6...v9.19.0) (2022-06-01) ### Features * **events:** Support of `paused` client event ([#411](https://github.com/webtorrent/bittorrent-tracker/issues/411)) ([ef76b3f](https://github.com/webtorrent/bittorrent-tracker/commit/ef76b3f3b6beee87f57d74addd0ca2ef2c517b6d)) --- AUTHORS.md | 1 + CHANGELOG.md | 7 +++++++ package.json | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index ccffe922..3d80837a 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -60,5 +60,6 @@ - Bruce Hopkins (behopkinsjr@gmail.com) - Ryan Finnie (ryan@finnie.org) - Lookis (lookisliu@gmail.com) +- Paul Sharypov (pavloniym@gmail.com) #### Generated by tools/update-authors.sh. diff --git a/CHANGELOG.md b/CHANGELOG.md index 79f8df94..2e511e3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [9.19.0](https://github.com/webtorrent/bittorrent-tracker/compare/v9.18.6...v9.19.0) (2022-06-01) + + +### Features + +* **events:** Support of `paused` client event ([#411](https://github.com/webtorrent/bittorrent-tracker/issues/411)) ([ef76b3f](https://github.com/webtorrent/bittorrent-tracker/commit/ef76b3f3b6beee87f57d74addd0ca2ef2c517b6d)) + ## [9.18.6](https://github.com/webtorrent/bittorrent-tracker/compare/v9.18.5...v9.18.6) (2022-05-11) diff --git a/package.json b/package.json index 7271f05b..74f64391 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bittorrent-tracker", "description": "Simple, robust, BitTorrent tracker (client & server) implementation", - "version": "9.18.6", + "version": "9.19.0", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", From e6d3189edf1a170197a799b97d84c632692b394f Mon Sep 17 00:00:00 2001 From: Cas <6506529+ThaUnknown@users.noreply.github.com> Date: Mon, 5 Dec 2022 23:06:54 +0100 Subject: [PATCH 024/119] feat: esm (#431) BREAKING CHANGE: ESM only * feat: esm * fix: linter oops --- bin/cmd.js | 4 ++-- client.js | 26 ++++++++++++----------- examples/express-embed/server.js | 4 ++-- index.js | 9 ++++---- lib/client/http-tracker.js | 25 +++++++++++----------- lib/client/tracker.js | 4 ++-- lib/client/udp-tracker.js | 26 ++++++++++++----------- lib/client/websocket-tracker.js | 20 ++++++++++-------- lib/common-node.js | 29 +++++++++++++------------ lib/common.js | 21 ++++++++++++------- lib/server/parse-http.js | 4 ++-- lib/server/parse-udp.js | 6 +++--- lib/server/parse-websocket.js | 4 ++-- lib/server/swarm.js | 12 ++++++----- package.json | 6 +++++- server.js | 36 +++++++++++++++++--------------- test/client-large-torrent.js | 8 +++---- test/client-magnet.js | 10 ++++----- test/client-ws-socket-pool.js | 8 +++---- test/client.js | 12 +++++------ test/common.js | 8 ++++--- test/destroy.js | 8 +++---- test/evict.js | 8 +++---- test/filter.js | 8 +++---- test/querystring.js | 4 ++-- test/request-handler.js | 10 ++++----- test/scrape.js | 25 +++++++++++----------- test/server.js | 8 +++---- test/stats.js | 10 ++++----- 29 files changed, 192 insertions(+), 171 deletions(-) diff --git a/bin/cmd.js b/bin/cmd.js index 965e00f7..fb7e0653 100755 --- a/bin/cmd.js +++ b/bin/cmd.js @@ -1,7 +1,7 @@ #!/usr/bin/env node -const minimist = require('minimist') -const Server = require('../').Server +import minimist from 'minimist' +import { Server } from '../index.js' const argv = minimist(process.argv.slice(2), { alias: { diff --git a/client.js b/client.js index c091c319..c90d7f90 100644 --- a/client.js +++ b/client.js @@ -1,14 +1,16 @@ -const debug = require('debug')('bittorrent-tracker:client') -const EventEmitter = require('events') -const once = require('once') -const parallel = require('run-parallel') -const Peer = require('simple-peer') -const queueMicrotask = require('queue-microtask') - -const common = require('./lib/common') -const HTTPTracker = require('./lib/client/http-tracker') // empty object in browser -const UDPTracker = require('./lib/client/udp-tracker') // empty object in browser -const WebSocketTracker = require('./lib/client/websocket-tracker') +import Debug from 'debug' +import EventEmitter from 'events' +import once from 'once' +import parallel from 'run-parallel' +import Peer from 'simple-peer' +import queueMicrotask from 'queue-microtask' + +import common from './lib/common.js' +import HTTPTracker from './lib/client/http-tracker.js' // empty object in browser +import UDPTracker from './lib/client/udp-tracker.js' // empty object in browser +import WebSocketTracker from './lib/client/websocket-tracker.js' + +const debug = Debug('bittorrent-tracker:client') /** * BitTorrent tracker client. @@ -289,4 +291,4 @@ Client.scrape = (opts, cb) => { return client } -module.exports = Client +export default Client diff --git a/examples/express-embed/server.js b/examples/express-embed/server.js index cfdbbec8..947dcbfb 100755 --- a/examples/express-embed/server.js +++ b/examples/express-embed/server.js @@ -1,7 +1,7 @@ #!/usr/bin/env node -const Server = require('../..').Server -const express = require('express') +import { Server } from '../../index.js' +import express from 'express' const app = express() // https://wiki.theory.org/BitTorrentSpecification#peer_id diff --git a/index.js b/index.js index de5d73c7..e812c41c 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,6 @@ /*! bittorrent-tracker. MIT License. WebTorrent LLC */ -const Client = require('./client') -const Server = require('./server') +import Client from './client.js' +import Server from './server.js' -module.exports = Client -module.exports.Client = Client -module.exports.Server = Server +export default Client +export { Client, Server } diff --git a/lib/client/http-tracker.js b/lib/client/http-tracker.js index 6fcea8d7..8dfe718a 100644 --- a/lib/client/http-tracker.js +++ b/lib/client/http-tracker.js @@ -1,14 +1,15 @@ -const arrayRemove = require('unordered-array-remove') -const bencode = require('bencode') -const clone = require('clone') -const compact2string = require('compact2string') -const debug = require('debug')('bittorrent-tracker:http-tracker') -const get = require('simple-get') -const Socks = require('socks') - -const common = require('../common') -const Tracker = require('./tracker') - +import arrayRemove from 'unordered-array-remove' +import bencode from 'bencode' +import clone from 'clone' +import Debug from 'debug' +import get from 'simple-get' +import Socks from 'socks' + +import common from '../common.js' +import Tracker from './tracker.js' +import compact2string from 'compact2string' + +const debug = Debug('bittorrent-tracker:http-tracker') const HTTP_SCRAPE_SUPPORT = /\/(announce)[^/]*$/ /** @@ -256,4 +257,4 @@ class HTTPTracker extends Tracker { HTTPTracker.prototype.DEFAULT_ANNOUNCE_INTERVAL = 30 * 60 * 1000 // 30 minutes -module.exports = HTTPTracker +export default HTTPTracker diff --git a/lib/client/tracker.js b/lib/client/tracker.js index cbbd23de..1129ecd8 100644 --- a/lib/client/tracker.js +++ b/lib/client/tracker.js @@ -1,4 +1,4 @@ -const EventEmitter = require('events') +import EventEmitter from 'events' class Tracker extends EventEmitter { constructor (client, announceUrl) { @@ -25,4 +25,4 @@ class Tracker extends EventEmitter { } } -module.exports = Tracker +export default Tracker diff --git a/lib/client/udp-tracker.js b/lib/client/udp-tracker.js index 65d97e40..9162d76f 100644 --- a/lib/client/udp-tracker.js +++ b/lib/client/udp-tracker.js @@ -1,14 +1,16 @@ -const arrayRemove = require('unordered-array-remove') -const BN = require('bn.js') -const clone = require('clone') -const compact2string = require('compact2string') -const debug = require('debug')('bittorrent-tracker:udp-tracker') -const dgram = require('dgram') -const randombytes = require('randombytes') -const Socks = require('socks') - -const common = require('../common') -const Tracker = require('./tracker') +import arrayRemove from 'unordered-array-remove' +import BN from 'bn.js' +import clone from 'clone' +import Debug from 'debug' +import dgram from 'dgram' +import randombytes from 'randombytes' +import Socks from 'socks' + +import common from '../common.js' +import Tracker from './tracker.js' +import compact2string from 'compact2string' + +const debug = Debug('bittorrent-tracker:udp-tracker') /** * UDP torrent tracker client (for an individual tracker) @@ -329,4 +331,4 @@ function toUInt64 (n) { function noop () {} -module.exports = UDPTracker +export default UDPTracker diff --git a/lib/client/websocket-tracker.js b/lib/client/websocket-tracker.js index 1573cfd2..3799510a 100644 --- a/lib/client/websocket-tracker.js +++ b/lib/client/websocket-tracker.js @@ -1,12 +1,14 @@ -const clone = require('clone') -const debug = require('debug')('bittorrent-tracker:websocket-tracker') -const Peer = require('simple-peer') -const randombytes = require('randombytes') -const Socket = require('simple-websocket') -const Socks = require('socks') +import clone from 'clone' +import Debug from 'debug' +import Peer from 'simple-peer' +import randombytes from 'randombytes' +import Socket from 'simple-websocket' +import Socks from 'socks' -const common = require('../common') -const Tracker = require('./tracker') +import common from '../common.js' +import Tracker from './tracker.js' + +const debug = Debug('bittorrent-tracker:websocket-tracker') // Use a socket pool, so tracker clients share WebSocket objects for the same server. // In practice, WebSockets are pretty slow to establish, so this gives a nice performance @@ -439,4 +441,4 @@ WebSocketTracker._socketPool = socketPool function noop () {} -module.exports = WebSocketTracker +export default WebSocketTracker diff --git a/lib/common-node.js b/lib/common-node.js index dab4b675..18af19c9 100644 --- a/lib/common-node.js +++ b/lib/common-node.js @@ -3,23 +3,23 @@ * These are separate from common.js so they can be skipped when bundling for the browser. */ -const querystring = require('querystring') +import querystring from 'querystring' -exports.IPV4_RE = /^[\d.]+$/ -exports.IPV6_RE = /^[\da-fA-F:]+$/ -exports.REMOVE_IPV4_MAPPED_IPV6_RE = /^::ffff:/ +export const IPV4_RE = /^[\d.]+$/ +export const IPV6_RE = /^[\da-fA-F:]+$/ +export const REMOVE_IPV4_MAPPED_IPV6_RE = /^::ffff:/ -exports.CONNECTION_ID = Buffer.concat([toUInt32(0x417), toUInt32(0x27101980)]) -exports.ACTIONS = { CONNECT: 0, ANNOUNCE: 1, SCRAPE: 2, ERROR: 3 } -exports.EVENTS = { update: 0, completed: 1, started: 2, stopped: 3, paused: 4 } -exports.EVENT_IDS = { +export const CONNECTION_ID = Buffer.concat([toUInt32(0x417), toUInt32(0x27101980)]) +export const ACTIONS = { CONNECT: 0, ANNOUNCE: 1, SCRAPE: 2, ERROR: 3 } +export const EVENTS = { update: 0, completed: 1, started: 2, stopped: 3, paused: 4 } +export const EVENT_IDS = { 0: 'update', 1: 'completed', 2: 'started', 3: 'stopped', 4: 'paused' } -exports.EVENT_NAMES = { +export const EVENT_NAMES = { update: 'update', completed: 'complete', started: 'start', @@ -31,20 +31,19 @@ exports.EVENT_NAMES = { * Client request timeout. How long to wait before considering a request to a * tracker server to have timed out. */ -exports.REQUEST_TIMEOUT = 15000 +export const REQUEST_TIMEOUT = 15000 /** * Client destroy timeout. How long to wait before forcibly cleaning up all * pending requests, open sockets, etc. */ -exports.DESTROY_TIMEOUT = 1000 +export const DESTROY_TIMEOUT = 1000 -function toUInt32 (n) { +export function toUInt32 (n) { const buf = Buffer.allocUnsafe(4) buf.writeUInt32BE(n, 0) return buf } -exports.toUInt32 = toUInt32 /** * `querystring.parse` using `unescape` instead of decodeURIComponent, since bittorrent @@ -52,7 +51,7 @@ exports.toUInt32 = toUInt32 * @param {string} q * @return {Object} */ -exports.querystringParse = q => querystring.parse(q, null, null, { decodeURIComponent: unescape }) +export const querystringParse = q => querystring.parse(q, null, null, { decodeURIComponent: unescape }) /** * `querystring.stringify` using `escape` instead of encodeURIComponent, since bittorrent @@ -60,7 +59,7 @@ exports.querystringParse = q => querystring.parse(q, null, null, { decodeURIComp * @param {Object} obj * @return {string} */ -exports.querystringStringify = obj => { +export const querystringStringify = obj => { let ret = querystring.stringify(obj, null, null, { encodeURIComponent: escape }) ret = ret.replace(/[@*/+]/g, char => // `escape` doesn't encode the characters @*/+ so we do it manually `%${char.charCodeAt(0).toString(16).toUpperCase()}`) diff --git a/lib/common.js b/lib/common.js index 0a2026bc..d418a323 100644 --- a/lib/common.js +++ b/lib/common.js @@ -1,18 +1,19 @@ /** * Functions/constants needed by both the client and server. */ +import * as common from './common-node.js' -exports.DEFAULT_ANNOUNCE_PEERS = 50 -exports.MAX_ANNOUNCE_PEERS = 82 +export const DEFAULT_ANNOUNCE_PEERS = 50 +export const MAX_ANNOUNCE_PEERS = 82 -exports.binaryToHex = str => { +export const binaryToHex = str => { if (typeof str !== 'string') { str = String(str) } return Buffer.from(str, 'binary').toString('hex') } -exports.hexToBinary = str => { +export const hexToBinary = str => { if (typeof str !== 'string') { str = String(str) } @@ -31,7 +32,7 @@ exports.hexToBinary = str => { // Bug reports: // - Chrome: https://bugs.chromium.org/p/chromium/issues/detail?id=734880 // - Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1374505 -exports.parseUrl = str => { +export const parseUrl = str => { const url = new URL(str.replace(/^udp:/, 'http:')) if (str.match(/^udp:/)) { @@ -45,5 +46,11 @@ exports.parseUrl = str => { return url } -const config = require('./common-node') -Object.assign(exports, config) +export default { + DEFAULT_ANNOUNCE_PEERS, + MAX_ANNOUNCE_PEERS, + binaryToHex, + hexToBinary, + parseUrl, + ...common +} diff --git a/lib/server/parse-http.js b/lib/server/parse-http.js index 7b2d5e2c..5847251f 100644 --- a/lib/server/parse-http.js +++ b/lib/server/parse-http.js @@ -1,6 +1,6 @@ -module.exports = parseHttpRequest +import common from '../common.js' -const common = require('../common') +export default parseHttpRequest function parseHttpRequest (req, opts) { if (!opts) opts = {} diff --git a/lib/server/parse-udp.js b/lib/server/parse-udp.js index 939bcb5d..935420cd 100644 --- a/lib/server/parse-udp.js +++ b/lib/server/parse-udp.js @@ -1,7 +1,7 @@ -module.exports = parseUdpRequest +import ipLib from 'ip' +import common from '../common.js' -const ipLib = require('ip') -const common = require('../common') +export default parseUdpRequest function parseUdpRequest (msg, rinfo) { if (msg.length < 16) throw new Error('received packet is too short') diff --git a/lib/server/parse-websocket.js b/lib/server/parse-websocket.js index 21b48fcb..5aeba9e1 100644 --- a/lib/server/parse-websocket.js +++ b/lib/server/parse-websocket.js @@ -1,6 +1,6 @@ -module.exports = parseWebSocketRequest +import common from '../common.js' -const common = require('../common') +export default parseWebSocketRequest function parseWebSocketRequest (socket, opts, params) { if (!opts) opts = {} diff --git a/lib/server/swarm.js b/lib/server/swarm.js index c3602133..9e3a0a20 100644 --- a/lib/server/swarm.js +++ b/lib/server/swarm.js @@ -1,7 +1,9 @@ -const arrayRemove = require('unordered-array-remove') -const debug = require('debug')('bittorrent-tracker:swarm') -const LRU = require('lru') -const randomIterate = require('random-iterate') +import arrayRemove from 'unordered-array-remove' +import Debug from 'debug' +import LRU from 'lru' +import randomIterate from 'random-iterate' + +const debug = Debug('bittorrent-tracker:swarm') // Regard this as the default implementation of an interface that you // need to support when overriding Server.createSwarm() and Server.getSwarm() @@ -159,4 +161,4 @@ class Swarm { } } -module.exports = Swarm +export default Swarm diff --git a/package.json b/package.json index 74f64391..afe4b7fd 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "bugs": { "url": "https://github.com/webtorrent/bittorrent-tracker/issues" }, + "type": "module", "dependencies": { "bencode": "^2.0.1", "bittorrent-peerid": "^1.3.3", @@ -60,7 +61,10 @@ "wrtc": "0.4.7" }, "engines": { - "node": ">=12" + "node": ">=12.20.0" + }, + "exports": { + "import": "./index.js" }, "keywords": [ "bittorrent", diff --git a/server.js b/server.js index 3bdbea71..3ef4349c 100644 --- a/server.js +++ b/server.js @@ -1,19 +1,21 @@ -const bencode = require('bencode') -const debug = require('debug')('bittorrent-tracker:server') -const dgram = require('dgram') -const EventEmitter = require('events') -const http = require('http') -const peerid = require('bittorrent-peerid') -const series = require('run-series') -const string2compact = require('string2compact') -const WebSocketServer = require('ws').Server - -const common = require('./lib/common') -const Swarm = require('./lib/server/swarm') -const parseHttpRequest = require('./lib/server/parse-http') -const parseUdpRequest = require('./lib/server/parse-udp') -const parseWebSocketRequest = require('./lib/server/parse-websocket') - +import bencode from 'bencode' +import Debug from 'debug' +import dgram from 'dgram' +import EventEmitter from 'events' +import http from 'http' +import peerid from 'bittorrent-peerid' +import series from 'run-series' +import string2compact from 'string2compact' +import ws from 'ws' + +import common from './lib/common.js' +import Swarm from './lib/server/swarm.js' +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 /** @@ -805,4 +807,4 @@ function toNumber (x) { function noop () {} -module.exports = Server +export default Server diff --git a/test/client-large-torrent.js b/test/client-large-torrent.js index a72f9cb0..db0d0fbf 100644 --- a/test/client-large-torrent.js +++ b/test/client-large-torrent.js @@ -1,7 +1,7 @@ -const Client = require('../') -const common = require('./common') -const fixtures = require('webtorrent-fixtures') -const test = require('tape') +import Client from '../index.js' +import common from './common.js' +import fixtures from 'webtorrent-fixtures' +import test from 'tape' const peerId = Buffer.from('01234567890123456789') diff --git a/test/client-magnet.js b/test/client-magnet.js index 7138cbd9..a6268b3f 100644 --- a/test/client-magnet.js +++ b/test/client-magnet.js @@ -1,8 +1,8 @@ -const Client = require('../') -const common = require('./common') -const fixtures = require('webtorrent-fixtures') -const magnet = require('magnet-uri') -const test = require('tape') +import Client from '../index.js' +import common from './common.js' +import fixtures from 'webtorrent-fixtures' +import magnet from 'magnet-uri' +import test from 'tape' const peerId = Buffer.from('01234567890123456789') diff --git a/test/client-ws-socket-pool.js b/test/client-ws-socket-pool.js index 4c041c2a..6d3fe1a3 100644 --- a/test/client-ws-socket-pool.js +++ b/test/client-ws-socket-pool.js @@ -1,7 +1,7 @@ -const Client = require('../') -const common = require('./common') -const fixtures = require('webtorrent-fixtures') -const test = require('tape') +import Client from '../index.js' +import common from './common.js' +import fixtures from 'webtorrent-fixtures' +import test from 'tape' const peerId = Buffer.from('01234567890123456789') const port = 6681 diff --git a/test/client.js b/test/client.js index 4ad16f85..c579058c 100644 --- a/test/client.js +++ b/test/client.js @@ -1,9 +1,9 @@ -const Client = require('../') -const common = require('./common') -const http = require('http') -const fixtures = require('webtorrent-fixtures') -const net = require('net') -const test = require('tape') +import Client from '../index.js' +import common from './common.js' +import http from 'http' +import fixtures from 'webtorrent-fixtures' +import net from 'net' +import test from 'tape' const peerId1 = Buffer.from('01234567890123456789') const peerId2 = Buffer.from('12345678901234567890') diff --git a/test/common.js b/test/common.js index 9bd098ed..5ff6ce39 100644 --- a/test/common.js +++ b/test/common.js @@ -1,6 +1,6 @@ -const Server = require('../').Server +import { Server } from '../index.js' -exports.createServer = (t, opts, cb) => { +export const createServer = (t, opts, cb) => { if (typeof opts === 'string') opts = { serverType: opts } opts.http = (opts.serverType === 'http') @@ -27,7 +27,7 @@ exports.createServer = (t, opts, cb) => { }) } -exports.mockWebsocketTracker = client => { +export const mockWebsocketTracker = client => { client._trackers[0]._generateOffers = (numwant, cb) => { const offers = [] for (let i = 0; i < numwant; i++) { @@ -38,3 +38,5 @@ exports.mockWebsocketTracker = client => { }) } } + +export default { mockWebsocketTracker, createServer } diff --git a/test/destroy.js b/test/destroy.js index 27d47605..e9d7af3a 100644 --- a/test/destroy.js +++ b/test/destroy.js @@ -1,7 +1,7 @@ -const Client = require('../') -const common = require('./common') -const fixtures = require('webtorrent-fixtures') -const test = require('tape') +import Client from '../index.js' +import common from './common.js' +import fixtures from 'webtorrent-fixtures' +import test from 'tape' const peerId = Buffer.from('01234567890123456789') const port = 6881 diff --git a/test/evict.js b/test/evict.js index a256a916..76967fd3 100644 --- a/test/evict.js +++ b/test/evict.js @@ -1,7 +1,7 @@ -const Client = require('../') -const common = require('./common') -const test = require('tape') -const wrtc = require('wrtc') +import Client from '../index.js' +import common from './common.js' +import test from 'tape' +import wrtc from 'wrtc' const infoHash = '4cb67059ed6bd08362da625b3ae77f6f4a075705' const peerId = Buffer.from('01234567890123456789') diff --git a/test/filter.js b/test/filter.js index fee7dd77..4dc3da02 100644 --- a/test/filter.js +++ b/test/filter.js @@ -1,7 +1,7 @@ -const Client = require('../') -const common = require('./common') -const fixtures = require('webtorrent-fixtures') -const test = require('tape') +import Client from '../index.js' +import common from './common.js' +import fixtures from 'webtorrent-fixtures' +import test from 'tape' const peerId = Buffer.from('01234567890123456789') diff --git a/test/querystring.js b/test/querystring.js index 2ce20fe2..85e14e54 100644 --- a/test/querystring.js +++ b/test/querystring.js @@ -1,5 +1,5 @@ -const common = require('../lib/common') -const test = require('tape') +import common from '../lib/common.js' +import test from 'tape' // https://github.com/webtorrent/webtorrent/issues/196 test('encode special chars +* in http tracker urls', t => { diff --git a/test/request-handler.js b/test/request-handler.js index b60f9674..b24110fa 100644 --- a/test/request-handler.js +++ b/test/request-handler.js @@ -1,8 +1,8 @@ -const Client = require('../') -const common = require('./common') -const fixtures = require('webtorrent-fixtures') -const test = require('tape') -const Server = require('../server') +import Client from '../index.js' +import common from './common.js' +import fixtures from 'webtorrent-fixtures' +import test from 'tape' +import Server from '../server.js' const peerId = Buffer.from('01234567890123456789') diff --git a/test/scrape.js b/test/scrape.js index 047d2495..b702fc68 100644 --- a/test/scrape.js +++ b/test/scrape.js @@ -1,16 +1,15 @@ -const bencode = require('bencode') -const Client = require('../') -const common = require('./common') -const commonLib = require('../lib/common') -const commonTest = require('./common') -const fixtures = require('webtorrent-fixtures') -const get = require('simple-get') -const test = require('tape') +import bencode from 'bencode' +import Client from '../index.js' +import common from './common.js' +import commonLib from '../lib/common.js' +import fixtures from 'webtorrent-fixtures' +import get from 'simple-get' +import test from 'tape' const peerId = Buffer.from('01234567890123456789') function testSingle (t, serverType) { - commonTest.createServer(t, serverType, (server, announceUrl) => { + common.createServer(t, serverType, (server, announceUrl) => { const client = new Client({ infoHash: fixtures.leaves.parsedTorrent.infoHash, announce: announceUrl, @@ -52,7 +51,7 @@ test('ws: single info_hash scrape', t => { }) function clientScrapeStatic (t, serverType) { - commonTest.createServer(t, serverType, (server, announceUrl) => { + common.createServer(t, serverType, (server, announceUrl) => { const client = Client.scrape({ announce: announceUrl, infoHash: fixtures.leaves.parsedTorrent.infoHash, @@ -116,7 +115,7 @@ function clientScrapeMulti (t, serverType) { const infoHash1 = fixtures.leaves.parsedTorrent.infoHash const infoHash2 = fixtures.alice.parsedTorrent.infoHash - commonTest.createServer(t, serverType, (server, announceUrl) => { + common.createServer(t, serverType, (server, announceUrl) => { Client.scrape({ infoHash: [infoHash1, infoHash2], announce: announceUrl @@ -156,7 +155,7 @@ test('server: multiple info_hash scrape (manual http request)', t => { const binaryInfoHash1 = commonLib.hexToBinary(fixtures.leaves.parsedTorrent.infoHash) const binaryInfoHash2 = commonLib.hexToBinary(fixtures.alice.parsedTorrent.infoHash) - commonTest.createServer(t, 'http', (server, announceUrl) => { + common.createServer(t, 'http', (server, announceUrl) => { const scrapeUrl = announceUrl.replace('/announce', '/scrape') const url = `${scrapeUrl}?${commonLib.querystringStringify({ @@ -192,7 +191,7 @@ test('server: all info_hash scrape (manual http request)', t => { const binaryInfoHash = commonLib.hexToBinary(fixtures.leaves.parsedTorrent.infoHash) - commonTest.createServer(t, 'http', (server, announceUrl) => { + common.createServer(t, 'http', (server, announceUrl) => { const scrapeUrl = announceUrl.replace('/announce', '/scrape') // announce a torrent to the tracker diff --git a/test/server.js b/test/server.js index 0acfabd9..cb1095e1 100644 --- a/test/server.js +++ b/test/server.js @@ -1,7 +1,7 @@ -const Client = require('../') -const common = require('./common') -const test = require('tape') -const wrtc = require('wrtc') +import Client from '../index.js' +import common from './common.js' +import test from 'tape' +import wrtc from 'wrtc' const infoHash = '4cb67059ed6bd08362da625b3ae77f6f4a075705' const peerId = Buffer.from('01234567890123456789') diff --git a/test/stats.js b/test/stats.js index 74128c2f..3ffa3fe3 100644 --- a/test/stats.js +++ b/test/stats.js @@ -1,8 +1,8 @@ -const Client = require('../') -const commonTest = require('./common') -const fixtures = require('webtorrent-fixtures') -const get = require('simple-get') -const test = require('tape') +import Client from '../index.js' +import commonTest from './common.js' +import fixtures from 'webtorrent-fixtures' +import get from 'simple-get' +import test from 'tape' const peerId = Buffer.from('-WW0091-4ea5886ce160') const unknownPeerId = Buffer.from('01234567890123456789') From de947a703aa2b39286af2898437e215e8458b963 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 5 Dec 2022 22:09:46 +0000 Subject: [PATCH 025/119] chore(release): 10.0.0 # [10.0.0](https://github.com/webtorrent/bittorrent-tracker/compare/v9.19.0...v10.0.0) (2022-12-05) ### Features * esm ([#431](https://github.com/webtorrent/bittorrent-tracker/issues/431)) ([e6d3189](https://github.com/webtorrent/bittorrent-tracker/commit/e6d3189edf1a170197a799b97d84c632692b394f)) ### BREAKING CHANGES * ESM only * feat: esm * fix: linter oops --- AUTHORS.md | 1 + CHANGELOG.md | 16 ++++++++++++++++ package.json | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index 3d80837a..e6d57d90 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -61,5 +61,6 @@ - Ryan Finnie (ryan@finnie.org) - Lookis (lookisliu@gmail.com) - Paul Sharypov (pavloniym@gmail.com) +- Cas (6506529+ThaUnknown@users.noreply.github.com) #### Generated by tools/update-authors.sh. diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e511e3d..c99cb6f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +# [10.0.0](https://github.com/webtorrent/bittorrent-tracker/compare/v9.19.0...v10.0.0) (2022-12-05) + + +### Features + +* esm ([#431](https://github.com/webtorrent/bittorrent-tracker/issues/431)) ([e6d3189](https://github.com/webtorrent/bittorrent-tracker/commit/e6d3189edf1a170197a799b97d84c632692b394f)) + + +### BREAKING CHANGES + +* ESM only + +* feat: esm + +* fix: linter oops + # [9.19.0](https://github.com/webtorrent/bittorrent-tracker/compare/v9.18.6...v9.19.0) (2022-06-01) diff --git a/package.json b/package.json index afe4b7fd..9fcaef92 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bittorrent-tracker", "description": "Simple, robust, BitTorrent tracker (client & server) implementation", - "version": "9.19.0", + "version": "10.0.0", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", From 15bcf895d8a2c5de54f8cb3df5cd6e3baa789d8d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 5 Dec 2022 22:10:07 +0000 Subject: [PATCH 026/119] chore(deps): update dependency @webtorrent/semantic-release-config to v1.0.8 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9fcaef92..433e2c88 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "ws": "^7.4.5" }, "devDependencies": { - "@webtorrent/semantic-release-config": "1.0.7", + "@webtorrent/semantic-release-config": "1.0.8", "magnet-uri": "6.2.0", "semantic-release": "18.0.1", "standard": "*", From bf74ecf70bef8e8deb335d6327f707348b328a00 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 6 Dec 2022 01:21:07 +0000 Subject: [PATCH 027/119] chore(deps): update dependency tape to v5.6.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 433e2c88..5807bff9 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "magnet-uri": "6.2.0", "semantic-release": "18.0.1", "standard": "*", - "tape": "5.5.3", + "tape": "5.6.1", "webtorrent-fixtures": "1.7.5", "wrtc": "0.4.7" }, From 926ceee0bac6dfe49877566aaa3cf645689492d1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 7 Dec 2022 11:39:00 -0500 Subject: [PATCH 028/119] fix(deps): update dependency bencode to v3 (#434) [skip ci] Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5807bff9..de7c4f62 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ }, "type": "module", "dependencies": { - "bencode": "^2.0.1", + "bencode": "^3.0.0", "bittorrent-peerid": "^1.3.3", "bn.js": "^5.2.0", "chrome-dgram": "^3.0.6", From 35ede9c8d770508806e52d3e250387c9e3a6d5da Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 7 Dec 2022 11:39:20 -0500 Subject: [PATCH 029/119] chore(deps): update dependency webtorrent-fixtures to v2 (#436) [skip ci] Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index de7c4f62..a91ac070 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "semantic-release": "18.0.1", "standard": "*", "tape": "5.6.1", - "webtorrent-fixtures": "1.7.5", + "webtorrent-fixtures": "2.0.0", "wrtc": "0.4.7" }, "engines": { From 40c25674f5e09af520138132aa84c3dba17608b3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 7 Dec 2022 11:39:48 -0500 Subject: [PATCH 030/119] chore(deps): update actions/stale action to v6 (#428) [skip ci] Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/stale.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 546af60a..bd98abab 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -12,7 +12,7 @@ jobs: pull-requests: write steps: - - uses: actions/stale@v5 + - uses: actions/stale@v6 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?' From ac84fbd44c16c77f594af9f406bedbfd1a4376ef Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 7 Dec 2022 11:40:11 -0500 Subject: [PATCH 031/119] chore(deps): update dependency semantic-release to v19 [security] (#423) [skip ci] Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a91ac070..54cd89bd 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "devDependencies": { "@webtorrent/semantic-release-config": "1.0.8", "magnet-uri": "6.2.0", - "semantic-release": "18.0.1", + "semantic-release": "19.0.3", "standard": "*", "tape": "5.6.1", "webtorrent-fixtures": "2.0.0", From 9be843c5e46ac2ab518187bf0d348e1e69e8633d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 7 Dec 2022 11:40:29 -0500 Subject: [PATCH 032/119] fix(deps): update dependency string2compact to v2 (#437) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 54cd89bd..e1c84787 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "simple-peer": "^9.11.0", "simple-websocket": "^9.1.0", "socks": "^2.0.0", - "string2compact": "^1.3.0", + "string2compact": "^2.0.0", "unordered-array-remove": "^1.0.2", "ws": "^7.4.5" }, From cb0bdfcfa7f820ca9680e804914ee81b3b4fa25c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 7 Dec 2022 11:40:48 -0500 Subject: [PATCH 033/119] chore(deps): update dependency semantic-release to v19.0.5 (#438) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e1c84787..d34674f7 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "devDependencies": { "@webtorrent/semantic-release-config": "1.0.8", "magnet-uri": "6.2.0", - "semantic-release": "19.0.3", + "semantic-release": "19.0.5", "standard": "*", "tape": "5.6.1", "webtorrent-fixtures": "2.0.0", From df39fed6faf20b6a345fe6136759294ddbbe7b65 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 7 Dec 2022 16:43:39 +0000 Subject: [PATCH 034/119] chore(release): 10.0.1 ## [10.0.1](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.0...v10.0.1) (2022-12-07) ### Bug Fixes * **deps:** update dependency bencode to v3 ([#434](https://github.com/webtorrent/bittorrent-tracker/issues/434)) [skip ci] ([926ceee](https://github.com/webtorrent/bittorrent-tracker/commit/926ceee0bac6dfe49877566aaa3cf645689492d1)) * **deps:** update dependency string2compact to v2 ([#437](https://github.com/webtorrent/bittorrent-tracker/issues/437)) ([9be843c](https://github.com/webtorrent/bittorrent-tracker/commit/9be843c5e46ac2ab518187bf0d348e1e69e8633d)) --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c99cb6f6..3d9e92d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## [10.0.1](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.0...v10.0.1) (2022-12-07) + + +### Bug Fixes + +* **deps:** update dependency bencode to v3 ([#434](https://github.com/webtorrent/bittorrent-tracker/issues/434)) [skip ci] ([926ceee](https://github.com/webtorrent/bittorrent-tracker/commit/926ceee0bac6dfe49877566aaa3cf645689492d1)) +* **deps:** update dependency string2compact to v2 ([#437](https://github.com/webtorrent/bittorrent-tracker/issues/437)) ([9be843c](https://github.com/webtorrent/bittorrent-tracker/commit/9be843c5e46ac2ab518187bf0d348e1e69e8633d)) + # [10.0.0](https://github.com/webtorrent/bittorrent-tracker/compare/v9.19.0...v10.0.0) (2022-12-05) diff --git a/package.json b/package.json index d34674f7..856f18c8 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.0", + "version": "10.0.1", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", From 0d297e4e1f2b924f6b99965f3fd3677723d3a628 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 17 Jan 2023 02:30:17 +0000 Subject: [PATCH 035/119] chore(deps): update dependency tape to v5.6.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 856f18c8..031550b1 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "magnet-uri": "6.2.0", "semantic-release": "19.0.5", "standard": "*", - "tape": "5.6.1", + "tape": "5.6.3", "webtorrent-fixtures": "2.0.0", "wrtc": "0.4.7" }, From dda99359eb033774e0e4608b7b08cab302e35528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Rodr=C3=ADguez=20Baquero?= Date: Thu, 26 Jan 2023 10:22:50 -0500 Subject: [PATCH 036/119] ci: upgrade node --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From b38acbdbe5ac81ebb02715ff96fd0324d0b73a7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Rodr=C3=ADguez=20Baquero?= Date: Sun, 29 Jan 2023 22:17:11 -0500 Subject: [PATCH 037/119] ci: add node-pre-gyp --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 031550b1..6eefad37 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "ws": "^7.4.5" }, "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", From 90ee33785160c85ab23ade0e95079500806d0643 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 29 Jan 2023 22:19:13 -0500 Subject: [PATCH 038/119] chore(deps): update actions/stale action to v7 (#439) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/stale.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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?' From 4bf8cb54dc00df6153c93499e82c264197d3e5d9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 29 Jan 2023 22:19:32 -0500 Subject: [PATCH 039/119] chore(deps): update dependency semantic-release to v20 (#441) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6eefad37..e78f28f2 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "@mapbox/node-pre-gyp": "1.0.10", "@webtorrent/semantic-release-config": "1.0.8", "magnet-uri": "6.2.0", - "semantic-release": "19.0.5", + "semantic-release": "20.1.0", "standard": "*", "tape": "5.6.3", "webtorrent-fixtures": "2.0.0", From 138c6e7327468ca44185c94e424c1153943ad876 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 29 Jan 2023 22:20:56 -0500 Subject: [PATCH 040/119] chore(deps): update dependency magnet-uri to v7 (#444) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e78f28f2..92dae3d5 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "devDependencies": { "@mapbox/node-pre-gyp": "1.0.10", "@webtorrent/semantic-release-config": "1.0.8", - "magnet-uri": "6.2.0", + "magnet-uri": "7.0.1", "semantic-release": "20.1.0", "standard": "*", "tape": "5.6.3", From b72d226ed88eec5b62b633172a39f142dc632af3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 1 Feb 2023 03:43:44 +0100 Subject: [PATCH 041/119] chore(deps): update webtorrent (#445) * chore(deps): update webtorrent * fix: dependencies (#446) --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Cas <6506529+ThaUnknown@users.noreply.github.com> --- lib/client/http-tracker.js | 12 ++++++------ package.json | 6 +++--- server.js | 4 ++-- test/request-handler.js | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) 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 92dae3d5..90099e49 100644 --- a/package.json +++ b/package.json @@ -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", @@ -54,11 +54,11 @@ "devDependencies": { "@mapbox/node-pre-gyp": "1.0.10", "@webtorrent/semantic-release-config": "1.0.8", - "magnet-uri": "7.0.1", + "magnet-uri": "7.0.2", "semantic-release": "20.1.0", "standard": "*", "tape": "5.6.3", - "webtorrent-fixtures": "2.0.0", + "webtorrent-fixtures": "2.0.2", "wrtc": "0.4.7" }, "engines": { diff --git a/server.js b/server.js index 3ef4349c..05364e89 100644 --- a/server.js +++ b/server.js @@ -351,7 +351,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 +360,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') From 7c4578f1b996ff909d8b691d403987f51115307c Mon Sep 17 00:00:00 2001 From: Cas <6506529+ThaUnknown@users.noreply.github.com> Date: Wed, 1 Feb 2023 11:31:48 +0100 Subject: [PATCH 042/119] ci: update release node version (#447) --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: From 2209d4f21bdee10e575c1728c3accf7bd34380c9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 1 Feb 2023 15:19:06 +0100 Subject: [PATCH 043/119] fix(deps): update dependency ws to v8 (#448) * fix(deps): update dependency ws to v8 * fix: ws imports (#449) --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Cas <6506529+ThaUnknown@users.noreply.github.com> --- package.json | 2 +- server.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 90099e49..3d69b4f3 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "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", diff --git a/server.js b/server.js index 05364e89..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 From 7356e34894ae55c3e077703b36f6ae4546bbcac3 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 1 Feb 2023 14:22:01 +0000 Subject: [PATCH 044/119] chore(release): 10.0.2 ## [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) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) 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/package.json b/package.json index 3d69b4f3..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", From bf4481c09a1b46337088cfdc14172592361085df Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 1 Mar 2023 05:43:04 +0000 Subject: [PATCH 045/119] chore(deps): update dependency semantic-release to v20.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4d0f3abb..7c6b2fb5 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "@mapbox/node-pre-gyp": "1.0.10", "@webtorrent/semantic-release-config": "1.0.8", "magnet-uri": "7.0.2", - "semantic-release": "20.1.0", + "semantic-release": "20.1.1", "standard": "*", "tape": "5.6.3", "webtorrent-fixtures": "2.0.2", From bf8831c64a0f307bbb486d873dfad2011965123e Mon Sep 17 00:00:00 2001 From: Tom Snelling Date: Fri, 17 Mar 2023 01:07:39 +0000 Subject: [PATCH 046/119] adds handling for x-forwarded-for comma-separated syntax (#452) --- lib/server/parse-http.js | 14 +++++++++++--- lib/server/parse-websocket.js | 14 +++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/lib/server/parse-http.js b/lib/server/parse-http.js index 5847251f..1e6fe315 100644 --- a/lib/server/parse-http.js +++ b/lib/server/parse-http.js @@ -33,9 +33,17 @@ function parseHttpRequest (req, opts) { common.MAX_ANNOUNCE_PEERS ) - params.ip = opts.trustProxy - ? req.headers['x-forwarded-for'] || req.connection.remoteAddress - : req.connection.remoteAddress.replace(common.REMOVE_IPV4_MAPPED_IPV6_RE, '') // force ipv4 + if (opts.trustProxy) { + if (req.headers['x-forwarded-for']) { + const [realIp] = req.headers['x-forwarded-for'].split(',') + params.ip = realIp.trim() + } else { + params.ip = req.connection.remoteAddress + } + } else { + params.ip = req.connection.remoteAddress.replace(common.REMOVE_IPV4_MAPPED_IPV6_RE, '') // force ipv4 + } + params.addr = `${common.IPV6_RE.test(params.ip) ? `[${params.ip}]` : params.ip}:${params.port}` params.headers = req.headers diff --git a/lib/server/parse-websocket.js b/lib/server/parse-websocket.js index 5aeba9e1..16fea56f 100644 --- a/lib/server/parse-websocket.js +++ b/lib/server/parse-websocket.js @@ -55,9 +55,17 @@ function parseWebSocketRequest (socket, opts, params) { // On first parse, save important data from `socket.upgradeReq` and delete it // to reduce memory usage. if (socket.upgradeReq) { - socket.ip = opts.trustProxy - ? socket.upgradeReq.headers['x-forwarded-for'] || socket.upgradeReq.connection.remoteAddress - : socket.upgradeReq.connection.remoteAddress.replace(common.REMOVE_IPV4_MAPPED_IPV6_RE, '') // force ipv4 + if (opts.trustProxy) { + if (socket.upgradeReq.headers['x-forwarded-for']) { + const [realIp] = socket.upgradeReq.headers['x-forwarded-for'].split(',') + socket.ip = realIp.trim() + } else { + socket.ip = socket.upgradeReq.connection.remoteAddress + } + } else { + socket.ip = socket.upgradeReq.connection.remoteAddress.replace(common.REMOVE_IPV4_MAPPED_IPV6_RE, '') // force ipv4 + } + socket.port = socket.upgradeReq.connection.remotePort if (socket.port) { socket.addr = `${common.IPV6_RE.test(socket.ip) ? `[${socket.ip}]` : socket.ip}:${socket.port}` From 76a2c7a978ea3660626da5d9184dee1eff50650d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 18 Mar 2023 20:39:04 +0000 Subject: [PATCH 047/119] chore(deps): update dependency semantic-release to v20.1.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7c6b2fb5..9705a62c 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "@mapbox/node-pre-gyp": "1.0.10", "@webtorrent/semantic-release-config": "1.0.8", "magnet-uri": "7.0.2", - "semantic-release": "20.1.1", + "semantic-release": "20.1.3", "standard": "*", "tape": "5.6.3", "webtorrent-fixtures": "2.0.2", From d31e8b6561174cadf4e10725b4fb1cf9af64bd7c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 2 Apr 2023 20:43:54 +0000 Subject: [PATCH 048/119] chore(deps): update dependency magnet-uri to v7.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9705a62c..f82db808 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "devDependencies": { "@mapbox/node-pre-gyp": "1.0.10", "@webtorrent/semantic-release-config": "1.0.8", - "magnet-uri": "7.0.2", + "magnet-uri": "7.0.3", "semantic-release": "20.1.3", "standard": "*", "tape": "5.6.3", From fc7c2324e8117b5cd7065a52bdcde61ab0399ab1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 8 May 2023 11:04:24 +0000 Subject: [PATCH 049/119] chore(deps): update dependency @webtorrent/semantic-release-config to v1.0.9 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f82db808..0b64a1e2 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ }, "devDependencies": { "@mapbox/node-pre-gyp": "1.0.10", - "@webtorrent/semantic-release-config": "1.0.8", + "@webtorrent/semantic-release-config": "1.0.9", "magnet-uri": "7.0.3", "semantic-release": "20.1.3", "standard": "*", From 3f01c29122efd726d805673da82f43ce5592b793 Mon Sep 17 00:00:00 2001 From: Cas <6506529+ThaUnknown@users.noreply.github.com> Date: Thu, 25 May 2023 19:18:36 +0200 Subject: [PATCH 050/119] perf: replace simple websocket with maintained one (#464) --- lib/client/websocket-tracker.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/client/websocket-tracker.js b/lib/client/websocket-tracker.js index 3799510a..75892ec5 100644 --- a/lib/client/websocket-tracker.js +++ b/lib/client/websocket-tracker.js @@ -2,7 +2,7 @@ import clone from 'clone' import Debug from 'debug' import Peer from 'simple-peer' import randombytes from 'randombytes' -import Socket from 'simple-websocket' +import Socket from '@thaunknown/simple-websocket' import Socks from 'socks' import common from '../common.js' @@ -214,7 +214,7 @@ class WebSocketTracker extends Tracker { this.expectingResponse = false try { - data = JSON.parse(data) + data = JSON.parse(Buffer.from(data)) } catch (err) { this.client.emit('warning', new Error('Invalid tracker response')) return diff --git a/package.json b/package.json index 0b64a1e2..c00c1506 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ }, "type": "module", "dependencies": { + "@thaunknown/simple-websocket": "^9.1.0", "bencode": "^3.0.3", "bittorrent-peerid": "^1.3.3", "bn.js": "^5.2.0", @@ -45,7 +46,6 @@ "run-series": "^1.1.9", "simple-get": "^4.0.0", "simple-peer": "^9.11.0", - "simple-websocket": "^9.1.0", "socks": "^2.0.0", "string2compact": "^2.0.0", "unordered-array-remove": "^1.0.2", From 6864ef9a24c3d9a4655a1cc25fbae1d47a374e75 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 25 May 2023 17:21:37 +0000 Subject: [PATCH 051/119] chore(release): 10.0.3 ## [10.0.3](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.2...v10.0.3) (2023-05-25) ### Performance Improvements * replace simple websocket with maintained one ([#464](https://github.com/webtorrent/bittorrent-tracker/issues/464)) ([3f01c29](https://github.com/webtorrent/bittorrent-tracker/commit/3f01c29122efd726d805673da82f43ce5592b793)) --- AUTHORS.md | 1 + CHANGELOG.md | 7 +++++++ package.json | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index e6d57d90..138681d6 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -62,5 +62,6 @@ - Lookis (lookisliu@gmail.com) - Paul Sharypov (pavloniym@gmail.com) - Cas (6506529+ThaUnknown@users.noreply.github.com) +- Tom Snelling (tomsnelling8@gmail.com) #### Generated by tools/update-authors.sh. diff --git a/CHANGELOG.md b/CHANGELOG.md index 4150d276..dce176eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [10.0.3](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.2...v10.0.3) (2023-05-25) + + +### Performance Improvements + +* replace simple websocket with maintained one ([#464](https://github.com/webtorrent/bittorrent-tracker/issues/464)) ([3f01c29](https://github.com/webtorrent/bittorrent-tracker/commit/3f01c29122efd726d805673da82f43ce5592b793)) + ## [10.0.2](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.1...v10.0.2) (2023-02-01) diff --git a/package.json b/package.json index c00c1506..04b59cf3 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.2", + "version": "10.0.3", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", From c99eb892088ef3c67ea5bf014dfdd86799251a7e Mon Sep 17 00:00:00 2001 From: Cas <6506529+ThaUnknown@users.noreply.github.com> Date: Fri, 26 May 2023 18:54:30 +0200 Subject: [PATCH 052/119] fix: drop buffer (#465) --- client.js | 24 +++++++++++------------ lib/client/http-tracker.js | 13 +++++++------ lib/client/udp-tracker.js | 34 ++++++++++++++++----------------- lib/client/websocket-tracker.js | 28 +++++++++++++-------------- lib/common-node.js | 8 +++++--- lib/common.js | 17 +---------------- lib/server/parse-http.js | 12 ++++++------ lib/server/parse-udp.js | 7 +++---- lib/server/parse-websocket.js | 14 +++++++------- package.json | 3 +-- server.js | 17 +++++++++-------- test/scrape.js | 7 ++++--- 12 files changed, 85 insertions(+), 99 deletions(-) diff --git a/client.js b/client.js index c90d7f90..9f36ce19 100644 --- a/client.js +++ b/client.js @@ -4,6 +4,7 @@ import once from 'once' import parallel from 'run-parallel' import Peer from 'simple-peer' import queueMicrotask from 'queue-microtask' +import { hex2arr, hex2bin, text2arr, arr2hex, arr2text } from 'uint8-util' import common from './lib/common.js' import HTTPTracker from './lib/client/http-tracker.js' // empty object in browser @@ -18,8 +19,8 @@ const debug = Debug('bittorrent-tracker:client') * Find torrent peers, to help a torrent client participate in a torrent swarm. * * @param {Object} opts options object - * @param {string|Buffer} opts.infoHash torrent info hash - * @param {string|Buffer} opts.peerId peer id + * @param {string|Uint8Array} opts.infoHash torrent info hash + * @param {string|Uint8Array} opts.peerId peer id * @param {string|Array.} opts.announce announce * @param {number} opts.port torrent client listening port * @param {function} opts.getAnnounceOpts callback to provide data to tracker @@ -39,15 +40,15 @@ class Client extends EventEmitter { this.peerId = typeof opts.peerId === 'string' ? opts.peerId - : opts.peerId.toString('hex') - this._peerIdBuffer = Buffer.from(this.peerId, 'hex') - this._peerIdBinary = this._peerIdBuffer.toString('binary') + : arr2hex(opts.peerId) + this._peerIdBuffer = hex2arr(this.peerId) + this._peerIdBinary = hex2bin(this.peerId) this.infoHash = typeof opts.infoHash === 'string' ? opts.infoHash.toLowerCase() - : opts.infoHash.toString('hex') - this._infoHashBuffer = Buffer.from(this.infoHash, 'hex') - this._infoHashBinary = this._infoHashBuffer.toString('binary') + : arr2hex(opts.infoHash) + this._infoHashBuffer = hex2arr(this.infoHash) + this._infoHashBinary = hex2bin(this.infoHash) debug('new client %s', this.infoHash) @@ -69,7 +70,7 @@ class Client extends EventEmitter { // Remove trailing slash from trackers to catch duplicates announce = announce.map(announceUrl => { - announceUrl = announceUrl.toString() + announceUrl = arr2text(announceUrl) if (announceUrl[announceUrl.length - 1] === '/') { announceUrl = announceUrl.substring(0, announceUrl.length - 1) } @@ -260,7 +261,7 @@ Client.scrape = (opts, cb) => { const clientOpts = Object.assign({}, opts, { infoHash: Array.isArray(opts.infoHash) ? opts.infoHash[0] : opts.infoHash, - peerId: Buffer.from('01234567890123456789'), // dummy value + peerId: text2arr('01234567890123456789'), // dummy value port: 6881 // dummy value }) @@ -284,9 +285,6 @@ Client.scrape = (opts, cb) => { } }) - opts.infoHash = Array.isArray(opts.infoHash) - ? opts.infoHash.map(infoHash => Buffer.from(infoHash, 'hex')) - : Buffer.from(opts.infoHash, 'hex') client.scrape({ infoHash: opts.infoHash }) return client } diff --git a/lib/client/http-tracker.js b/lib/client/http-tracker.js index 07b2990c..162c68fb 100644 --- a/lib/client/http-tracker.js +++ b/lib/client/http-tracker.js @@ -4,6 +4,7 @@ import clone from 'clone' import Debug from 'debug' import get from 'simple-get' import Socks from 'socks' +import { bin2hex, hex2bin, arr2text } from 'uint8-util' import common from '../common.js' import Tracker from './tracker.js' @@ -65,8 +66,8 @@ class HTTPTracker extends Tracker { } const infoHashes = (Array.isArray(opts.infoHash) && opts.infoHash.length > 0) - ? opts.infoHash.map(infoHash => infoHash.toString('binary')) - : (opts.infoHash && opts.infoHash.toString('binary')) || this.client._infoHashBinary + ? opts.infoHash.map(infoHash => hex2bin(infoHash)) + : (opts.infoHash && hex2bin(opts.infoHash)) || this.client._infoHashBinary const params = { info_hash: infoHashes } @@ -159,13 +160,13 @@ class HTTPTracker extends Tracker { } catch (err) { return cb(new Error(`Error decoding tracker response: ${err.message}`)) } - const failure = data['failure reason'] && Buffer.from(data['failure reason']).toString() + const failure = data['failure reason'] && arr2text(data['failure reason']) if (failure) { debug(`failure from ${requestUrl} (${failure})`) return cb(new Error(failure)) } - const warning = data['warning message'] && Buffer.from(data['warning message']).toString() + const warning = data['warning message'] && arr2text(data['warning message']) if (warning) { debug(`warning from ${requestUrl} (${warning})`) self.client.emit('warning', new Error(warning)) @@ -189,7 +190,7 @@ class HTTPTracker extends Tracker { const response = Object.assign({}, data, { announce: this.announceUrl, - infoHash: common.binaryToHex(data.info_hash) + infoHash: bin2hex(data.info_hash || String(data.info_hash)) }) this.client.emit('update', response) @@ -248,7 +249,7 @@ class HTTPTracker extends Tracker { // (separate from announce interval) const response = Object.assign(data[infoHash], { announce: this.announceUrl, - infoHash: common.binaryToHex(infoHash) + infoHash: bin2hex(infoHash) }) this.client.emit('scrape', response) }) diff --git a/lib/client/udp-tracker.js b/lib/client/udp-tracker.js index 9162d76f..b3218bc5 100644 --- a/lib/client/udp-tracker.js +++ b/lib/client/udp-tracker.js @@ -1,10 +1,9 @@ import arrayRemove from 'unordered-array-remove' -import BN from 'bn.js' import clone from 'clone' import Debug from 'debug' import dgram from 'dgram' -import randombytes from 'randombytes' import Socks from 'socks' +import { concat, hex2arr, randomBytes } from 'uint8-util' import common from '../common.js' import Tracker from './tracker.js' @@ -131,7 +130,7 @@ class UDPTracker extends Tracker { }, common.REQUEST_TIMEOUT) if (timeout.unref) timeout.unref() - send(Buffer.concat([ + send(concat([ common.CONNECTION_ID, common.toUInt32(common.ACTIONS.CONNECT), transactionId @@ -175,7 +174,8 @@ class UDPTracker extends Tracker { function onSocketMessage (msg) { if (proxySocket) msg = msg.slice(10) - if (msg.length < 8 || msg.readUInt32BE(4) !== transactionId.readUInt32BE(0)) { + const view = new DataView(transactionId.buffer) + if (msg.length < 8 || msg.readUInt32BE(4) !== view.getUint32(0)) { return onError(new Error('tracker sent invalid transaction id')) } @@ -270,14 +270,14 @@ class UDPTracker extends Tracker { function announce (connectionId, opts) { transactionId = genTransactionId() - send(Buffer.concat([ + send(concat([ connectionId, common.toUInt32(common.ACTIONS.ANNOUNCE), transactionId, self.client._infoHashBuffer, self.client._peerIdBuffer, toUInt64(opts.downloaded), - opts.left != null ? toUInt64(opts.left) : Buffer.from('FFFFFFFFFFFFFFFF', 'hex'), + opts.left != null ? toUInt64(opts.left) : hex2arr('ffffffffffffffff'), toUInt64(opts.uploaded), common.toUInt32(common.EVENTS[opts.event] || 0), common.toUInt32(0), // ip address (optional) @@ -291,10 +291,10 @@ class UDPTracker extends Tracker { transactionId = genTransactionId() const infoHash = (Array.isArray(opts.infoHash) && opts.infoHash.length > 0) - ? Buffer.concat(opts.infoHash) + ? concat(opts.infoHash) : (opts.infoHash || self.client._infoHashBuffer) - send(Buffer.concat([ + send(concat([ connectionId, common.toUInt32(common.ACTIONS.SCRAPE), transactionId, @@ -307,12 +307,13 @@ class UDPTracker extends Tracker { UDPTracker.prototype.DEFAULT_ANNOUNCE_INTERVAL = 30 * 60 * 1000 // 30 minutes function genTransactionId () { - return randombytes(4) + return randomBytes(4) } function toUInt16 (n) { - const buf = Buffer.allocUnsafe(2) - buf.writeUInt16BE(n, 0) + const buf = new Uint8Array(2) + const view = new DataView(buf.buffer) + view.setUint16(0, n) return buf } @@ -320,13 +321,12 @@ const MAX_UINT = 4294967295 function toUInt64 (n) { if (n > MAX_UINT || typeof n === 'string') { - const bytes = new BN(n).toArray() - while (bytes.length < 8) { - bytes.unshift(0) - } - return Buffer.from(bytes) + const buf = new Uint8Array(8) + const view = new DataView(buf.buffer) + view.setBigUint64(0, n) + return buf } - return Buffer.concat([common.toUInt32(0), common.toUInt32(n)]) + return concat([new Uint8Array(4), common.toUInt32(n)]) } function noop () {} diff --git a/lib/client/websocket-tracker.js b/lib/client/websocket-tracker.js index 75892ec5..3889eea2 100644 --- a/lib/client/websocket-tracker.js +++ b/lib/client/websocket-tracker.js @@ -1,11 +1,11 @@ import clone from 'clone' import Debug from 'debug' import Peer from 'simple-peer' -import randombytes from 'randombytes' import Socket from '@thaunknown/simple-websocket' import Socks from 'socks' +import { arr2text, arr2hex, hex2bin, bin2hex, randomBytes } from 'uint8-util' -import common from '../common.js' +import { DESTROY_TIMEOUT } from '../common.js' import Tracker from './tracker.js' const debug = Debug('bittorrent-tracker:websocket-tracker') @@ -80,8 +80,8 @@ class WebSocketTracker extends Tracker { } const infoHashes = (Array.isArray(opts.infoHash) && opts.infoHash.length > 0) - ? opts.infoHash.map(infoHash => infoHash.toString('binary')) - : (opts.infoHash && opts.infoHash.toString('binary')) || this.client._infoHashBinary + ? opts.infoHash.map(infoHash => hex2bin(infoHash)) + : (opts.infoHash && hex2bin(opts.infoHash)) || this.client._infoHashBinary const params = { action: 'scrape', info_hash: infoHashes @@ -138,7 +138,7 @@ class WebSocketTracker extends Tracker { // Otherwise, wait a short time for potential responses to come in from the // server, then force close the socket. - timeout = setTimeout(destroyCleanup, common.DESTROY_TIMEOUT) + timeout = setTimeout(destroyCleanup, DESTROY_TIMEOUT) // But, if a response comes from the server before the timeout fires, do cleanup // right away. @@ -214,7 +214,7 @@ class WebSocketTracker extends Tracker { this.expectingResponse = false try { - data = JSON.parse(Buffer.from(data)) + data = JSON.parse(arr2text(data)) } catch (err) { this.client.emit('warning', new Error('Invalid tracker response')) return @@ -233,7 +233,7 @@ class WebSocketTracker extends Tracker { if (data.info_hash !== this.client._infoHashBinary) { debug( 'ignoring websocket data from %s for %s (looking for %s: reused socket)', - this.announceUrl, common.binaryToHex(data.info_hash), this.client.infoHash + this.announceUrl, bin2hex(data.info_hash), this.client.infoHash ) return } @@ -266,7 +266,7 @@ class WebSocketTracker extends Tracker { if (data.complete != null) { const response = Object.assign({}, data, { announce: this.announceUrl, - infoHash: common.binaryToHex(data.info_hash) + infoHash: bin2hex(data.info_hash) }) this.client.emit('update', response) } @@ -275,7 +275,7 @@ class WebSocketTracker extends Tracker { if (data.offer && data.peer_id) { debug('creating peer (from remote offer)') peer = this._createPeer() - peer.id = common.binaryToHex(data.peer_id) + peer.id = bin2hex(data.peer_id) peer.once('signal', answer => { const params = { action: 'announce', @@ -293,10 +293,10 @@ class WebSocketTracker extends Tracker { } if (data.answer && data.peer_id) { - const offerId = common.binaryToHex(data.offer_id) + const offerId = bin2hex(data.offer_id) peer = this.peers[offerId] if (peer) { - peer.id = common.binaryToHex(data.peer_id) + peer.id = bin2hex(data.peer_id) this.client.emit('peer', peer) peer.signal(data.answer) @@ -323,7 +323,7 @@ class WebSocketTracker extends Tracker { // (separate from announce interval) const response = Object.assign(data[infoHash], { announce: this.announceUrl, - infoHash: common.binaryToHex(infoHash) + infoHash: bin2hex(infoHash) }) this.client.emit('scrape', response) }) @@ -376,13 +376,13 @@ class WebSocketTracker extends Tracker { checkDone() function generateOffer () { - const offerId = randombytes(20).toString('hex') + const offerId = arr2hex(randomBytes(20)) debug('creating peer (from _generateOffers)') const peer = self.peers[offerId] = self._createPeer({ initiator: true }) peer.once('signal', offer => { offers.push({ offer, - offer_id: common.hexToBinary(offerId) + offer_id: hex2bin(offerId) }) checkDone() }) diff --git a/lib/common-node.js b/lib/common-node.js index 18af19c9..9fefa5c4 100644 --- a/lib/common-node.js +++ b/lib/common-node.js @@ -4,12 +4,13 @@ */ import querystring from 'querystring' +import { concat } from 'uint8-util' export const IPV4_RE = /^[\d.]+$/ export const IPV6_RE = /^[\da-fA-F:]+$/ export const REMOVE_IPV4_MAPPED_IPV6_RE = /^::ffff:/ -export const CONNECTION_ID = Buffer.concat([toUInt32(0x417), toUInt32(0x27101980)]) +export const CONNECTION_ID = concat([toUInt32(0x417), toUInt32(0x27101980)]) export const ACTIONS = { CONNECT: 0, ANNOUNCE: 1, SCRAPE: 2, ERROR: 3 } export const EVENTS = { update: 0, completed: 1, started: 2, stopped: 3, paused: 4 } export const EVENT_IDS = { @@ -40,8 +41,9 @@ export const REQUEST_TIMEOUT = 15000 export const DESTROY_TIMEOUT = 1000 export function toUInt32 (n) { - const buf = Buffer.allocUnsafe(4) - buf.writeUInt32BE(n, 0) + const buf = new Uint8Array(4) + const view = new DataView(buf.buffer) + view.setUint32(0, n) return buf } diff --git a/lib/common.js b/lib/common.js index d418a323..ef888579 100644 --- a/lib/common.js +++ b/lib/common.js @@ -2,24 +2,11 @@ * Functions/constants needed by both the client and server. */ import * as common from './common-node.js' +export * from './common-node.js' export const DEFAULT_ANNOUNCE_PEERS = 50 export const MAX_ANNOUNCE_PEERS = 82 -export const binaryToHex = str => { - if (typeof str !== 'string') { - str = String(str) - } - return Buffer.from(str, 'binary').toString('hex') -} - -export const hexToBinary = str => { - if (typeof str !== 'string') { - str = String(str) - } - return Buffer.from(str, 'hex').toString('binary') -} - // HACK: Fix for WHATWG URL object not parsing non-standard URL schemes like // 'udp:'. Just replace it with 'http:' since we only need a few properties. // @@ -49,8 +36,6 @@ export const parseUrl = str => { export default { DEFAULT_ANNOUNCE_PEERS, MAX_ANNOUNCE_PEERS, - binaryToHex, - hexToBinary, parseUrl, ...common } diff --git a/lib/server/parse-http.js b/lib/server/parse-http.js index 1e6fe315..a6ba6a56 100644 --- a/lib/server/parse-http.js +++ b/lib/server/parse-http.js @@ -1,8 +1,8 @@ -import common from '../common.js' +import { bin2hex } from 'uint8-util' -export default parseHttpRequest +import common from '../common.js' -function parseHttpRequest (req, opts) { +export default function (req, opts) { if (!opts) opts = {} const s = req.url.split('?') const params = common.querystringParse(s[1]) @@ -14,12 +14,12 @@ function parseHttpRequest (req, opts) { if (typeof params.info_hash !== 'string' || params.info_hash.length !== 20) { throw new Error('invalid info_hash') } - params.info_hash = common.binaryToHex(params.info_hash) + params.info_hash = bin2hex(params.info_hash) if (typeof params.peer_id !== 'string' || params.peer_id.length !== 20) { throw new Error('invalid peer_id') } - params.peer_id = common.binaryToHex(params.peer_id) + params.peer_id = bin2hex(params.peer_id) params.port = Number(params.port) if (!params.port) throw new Error('invalid port') @@ -56,7 +56,7 @@ function parseHttpRequest (req, opts) { if (typeof binaryInfoHash !== 'string' || binaryInfoHash.length !== 20) { throw new Error('invalid info_hash') } - return common.binaryToHex(binaryInfoHash) + return bin2hex(binaryInfoHash) }) } } else { diff --git a/lib/server/parse-udp.js b/lib/server/parse-udp.js index 935420cd..f73b6491 100644 --- a/lib/server/parse-udp.js +++ b/lib/server/parse-udp.js @@ -1,9 +1,8 @@ import ipLib from 'ip' import common from '../common.js' +import { equal } from 'uint8-util' -export default parseUdpRequest - -function parseUdpRequest (msg, rinfo) { +export default function (msg, rinfo) { if (msg.length < 16) throw new Error('received packet is too short') const params = { @@ -13,7 +12,7 @@ function parseUdpRequest (msg, rinfo) { type: 'udp' } - if (!common.CONNECTION_ID.equals(params.connectionId)) { + if (!equal(common.CONNECTION_ID, params.connectionId)) { throw new Error('received packet with invalid connection id') } diff --git a/lib/server/parse-websocket.js b/lib/server/parse-websocket.js index 16fea56f..744a3c30 100644 --- a/lib/server/parse-websocket.js +++ b/lib/server/parse-websocket.js @@ -1,8 +1,8 @@ -import common from '../common.js' +import { bin2hex } from 'uint8-util' -export default parseWebSocketRequest +import common from '../common.js' -function parseWebSocketRequest (socket, opts, params) { +export default function (socket, opts, params) { if (!opts) opts = {} params = JSON.parse(params) // may throw @@ -14,18 +14,18 @@ function parseWebSocketRequest (socket, opts, params) { if (typeof params.info_hash !== 'string' || params.info_hash.length !== 20) { throw new Error('invalid info_hash') } - params.info_hash = common.binaryToHex(params.info_hash) + params.info_hash = bin2hex(params.info_hash) if (typeof params.peer_id !== 'string' || params.peer_id.length !== 20) { throw new Error('invalid peer_id') } - params.peer_id = common.binaryToHex(params.peer_id) + params.peer_id = bin2hex(params.peer_id) if (params.answer) { if (typeof params.to_peer_id !== 'string' || params.to_peer_id.length !== 20) { throw new Error('invalid `to_peer_id` (required with `answer`)') } - params.to_peer_id = common.binaryToHex(params.to_peer_id) + params.to_peer_id = bin2hex(params.to_peer_id) } params.left = Number(params.left) @@ -45,7 +45,7 @@ function parseWebSocketRequest (socket, opts, params) { if (typeof binaryInfoHash !== 'string' || binaryInfoHash.length !== 20) { throw new Error('invalid info_hash') } - return common.binaryToHex(binaryInfoHash) + return bin2hex(binaryInfoHash) }) } } else { diff --git a/package.json b/package.json index 04b59cf3..efe2b4f2 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,6 @@ "@thaunknown/simple-websocket": "^9.1.0", "bencode": "^3.0.3", "bittorrent-peerid": "^1.3.3", - "bn.js": "^5.2.0", "chrome-dgram": "^3.0.6", "clone": "^2.0.0", "compact2string": "^1.4.1", @@ -41,13 +40,13 @@ "once": "^1.4.0", "queue-microtask": "^1.2.3", "random-iterate": "^1.0.1", - "randombytes": "^2.1.0", "run-parallel": "^1.2.0", "run-series": "^1.1.9", "simple-get": "^4.0.0", "simple-peer": "^9.11.0", "socks": "^2.0.0", "string2compact": "^2.0.0", + "uint8-util": "^2.1.9", "unordered-array-remove": "^1.0.2", "ws": "^8.0.0" }, diff --git a/server.js b/server.js index dd823f42..f7023d99 100644 --- a/server.js +++ b/server.js @@ -7,6 +7,7 @@ import peerid from 'bittorrent-peerid' import series from 'run-series' import string2compact from 'string2compact' import { WebSocketServer } from 'ws' +import { hex2bin } from 'uint8-util' import common from './lib/common.js' import Swarm from './lib/server/swarm.js' @@ -488,7 +489,7 @@ class Server extends EventEmitter { socket.send(JSON.stringify({ action: params.action === common.ACTIONS.ANNOUNCE ? 'announce' : 'scrape', 'failure reason': err.message, - info_hash: common.hexToBinary(params.info_hash) + info_hash: hex2bin(params.info_hash) }), socket.onSend) this.emit('warning', err) @@ -506,7 +507,7 @@ class Server extends EventEmitter { socket.infoHashes.push(params.info_hash) } - response.info_hash = common.hexToBinary(params.info_hash) + response.info_hash = hex2bin(params.info_hash) // WebSocket tracker should have a shorter interval – default: 2 minutes response.interval = Math.ceil(this.intervalMs / 1000 / 5) @@ -526,8 +527,8 @@ class Server extends EventEmitter { action: 'announce', offer: params.offers[i].offer, offer_id: params.offers[i].offer_id, - peer_id: common.hexToBinary(params.peer_id), - info_hash: common.hexToBinary(params.info_hash) + peer_id: hex2bin(params.peer_id), + info_hash: hex2bin(params.info_hash) }), peer.socket.onSend) debug('sent offer to %s from %s', peer.peerId, params.peer_id) }) @@ -559,8 +560,8 @@ class Server extends EventEmitter { action: 'announce', answer: params.answer, offer_id: params.offer_id, - peer_id: common.hexToBinary(params.peer_id), - info_hash: common.hexToBinary(params.info_hash) + peer_id: hex2bin(params.peer_id), + info_hash: hex2bin(params.info_hash) }), toPeer.socket.onSend) debug('sent answer to %s from %s', toPeer.peerId, params.peer_id) @@ -685,7 +686,7 @@ class Server extends EventEmitter { } else if (params.compact === 0) { // IPv6 peers are not separate for non-compact responses response.peers = response.peers.map(peer => ({ - 'peer id': common.hexToBinary(peer.peerId), + 'peer id': hex2bin(peer.peerId), ip: peer.ip, port: peer.port })) @@ -729,7 +730,7 @@ class Server extends EventEmitter { } results.forEach(result => { - response.files[common.hexToBinary(result.infoHash)] = { + response.files[hex2bin(result.infoHash)] = { complete: result.complete || 0, incomplete: result.incomplete || 0, downloaded: result.complete || 0 // TODO: this only provides a lower-bound diff --git a/test/scrape.js b/test/scrape.js index b702fc68..38af0a42 100644 --- a/test/scrape.js +++ b/test/scrape.js @@ -5,6 +5,7 @@ import commonLib from '../lib/common.js' import fixtures from 'webtorrent-fixtures' import get from 'simple-get' import test from 'tape' +import { hex2bin } from 'uint8-util' const peerId = Buffer.from('01234567890123456789') @@ -152,8 +153,8 @@ test('udp: MULTI scrape using Client.scrape static method', t => { test('server: multiple info_hash scrape (manual http request)', t => { t.plan(13) - const binaryInfoHash1 = commonLib.hexToBinary(fixtures.leaves.parsedTorrent.infoHash) - const binaryInfoHash2 = commonLib.hexToBinary(fixtures.alice.parsedTorrent.infoHash) + const binaryInfoHash1 = hex2bin(fixtures.leaves.parsedTorrent.infoHash) + const binaryInfoHash2 = hex2bin(fixtures.alice.parsedTorrent.infoHash) common.createServer(t, 'http', (server, announceUrl) => { const scrapeUrl = announceUrl.replace('/announce', '/scrape') @@ -189,7 +190,7 @@ test('server: multiple info_hash scrape (manual http request)', t => { test('server: all info_hash scrape (manual http request)', t => { t.plan(10) - const binaryInfoHash = commonLib.hexToBinary(fixtures.leaves.parsedTorrent.infoHash) + const binaryInfoHash = hex2bin(fixtures.leaves.parsedTorrent.infoHash) common.createServer(t, 'http', (server, announceUrl) => { const scrapeUrl = announceUrl.replace('/announce', '/scrape') From 51a6b6d6c096408f01034c9c0d256047be299266 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 26 May 2023 16:57:26 +0000 Subject: [PATCH 053/119] chore(release): 10.0.4 ## [10.0.4](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.3...v10.0.4) (2023-05-26) ### Bug Fixes * drop buffer ([#465](https://github.com/webtorrent/bittorrent-tracker/issues/465)) ([c99eb89](https://github.com/webtorrent/bittorrent-tracker/commit/c99eb892088ef3c67ea5bf014dfdd86799251a7e)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dce176eb..8933a091 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [10.0.4](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.3...v10.0.4) (2023-05-26) + + +### Bug Fixes + +* drop buffer ([#465](https://github.com/webtorrent/bittorrent-tracker/issues/465)) ([c99eb89](https://github.com/webtorrent/bittorrent-tracker/commit/c99eb892088ef3c67ea5bf014dfdd86799251a7e)) + ## [10.0.3](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.2...v10.0.3) (2023-05-25) diff --git a/package.json b/package.json index efe2b4f2..afff1717 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.3", + "version": "10.0.4", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", From 52f55020f38894e4d45e12c87184540d8b0acad3 Mon Sep 17 00:00:00 2001 From: Cas <6506529+ThaUnknown@users.noreply.github.com> Date: Sat, 27 May 2023 18:41:31 +0200 Subject: [PATCH 054/119] fix: only stringify views (#467) --- client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.js b/client.js index 9f36ce19..5279a8ee 100644 --- a/client.js +++ b/client.js @@ -70,7 +70,7 @@ class Client extends EventEmitter { // Remove trailing slash from trackers to catch duplicates announce = announce.map(announceUrl => { - announceUrl = arr2text(announceUrl) + if (ArrayBuffer.isView(announceUrl)) announceUrl = arr2text(announceUrl) if (announceUrl[announceUrl.length - 1] === '/') { announceUrl = announceUrl.substring(0, announceUrl.length - 1) } From c5f70dd186405f391f7301ffa8f5dac70bb477d8 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Sat, 27 May 2023 16:44:28 +0000 Subject: [PATCH 055/119] chore(release): 10.0.5 ## [10.0.5](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.4...v10.0.5) (2023-05-27) ### Bug Fixes * only stringify views ([#467](https://github.com/webtorrent/bittorrent-tracker/issues/467)) ([52f5502](https://github.com/webtorrent/bittorrent-tracker/commit/52f55020f38894e4d45e12c87184540d8b0acad3)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8933a091..043cf1d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [10.0.5](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.4...v10.0.5) (2023-05-27) + + +### Bug Fixes + +* only stringify views ([#467](https://github.com/webtorrent/bittorrent-tracker/issues/467)) ([52f5502](https://github.com/webtorrent/bittorrent-tracker/commit/52f55020f38894e4d45e12c87184540d8b0acad3)) + ## [10.0.4](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.3...v10.0.4) (2023-05-26) diff --git a/package.json b/package.json index afff1717..6550f912 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.4", + "version": "10.0.5", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", From 3b2dedb4151615831ca12d3d0a830354b1c04e68 Mon Sep 17 00:00:00 2001 From: Cas <6506529+ThaUnknown@users.noreply.github.com> Date: Sat, 27 May 2023 19:14:52 +0200 Subject: [PATCH 056/119] fix: replace simple-peer with maintained one (#466) --- client.js | 2 +- lib/client/websocket-tracker.js | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client.js b/client.js index 5279a8ee..9942f361 100644 --- a/client.js +++ b/client.js @@ -2,7 +2,7 @@ import Debug from 'debug' import EventEmitter from 'events' import once from 'once' import parallel from 'run-parallel' -import Peer from 'simple-peer' +import Peer from '@thaunknown/simple-peer' import queueMicrotask from 'queue-microtask' import { hex2arr, hex2bin, text2arr, arr2hex, arr2text } from 'uint8-util' diff --git a/lib/client/websocket-tracker.js b/lib/client/websocket-tracker.js index 3889eea2..f933323c 100644 --- a/lib/client/websocket-tracker.js +++ b/lib/client/websocket-tracker.js @@ -1,6 +1,6 @@ import clone from 'clone' import Debug from 'debug' -import Peer from 'simple-peer' +import Peer from '@thaunknown/simple-peer' import Socket from '@thaunknown/simple-websocket' import Socks from 'socks' import { arr2text, arr2hex, hex2bin, bin2hex, randomBytes } from 'uint8-util' diff --git a/package.json b/package.json index 6550f912..86b9116d 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ }, "type": "module", "dependencies": { + "@thaunknown/simple-peer": "^9.12.0", "@thaunknown/simple-websocket": "^9.1.0", "bencode": "^3.0.3", "bittorrent-peerid": "^1.3.3", @@ -43,7 +44,6 @@ "run-parallel": "^1.2.0", "run-series": "^1.1.9", "simple-get": "^4.0.0", - "simple-peer": "^9.11.0", "socks": "^2.0.0", "string2compact": "^2.0.0", "uint8-util": "^2.1.9", From 17d4c66d9c5f22dfc19f9a6d5a6552444595f72a Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Sat, 27 May 2023 17:17:52 +0000 Subject: [PATCH 057/119] chore(release): 10.0.6 ## [10.0.6](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.5...v10.0.6) (2023-05-27) ### Bug Fixes * replace simple-peer with maintained one ([#466](https://github.com/webtorrent/bittorrent-tracker/issues/466)) ([3b2dedb](https://github.com/webtorrent/bittorrent-tracker/commit/3b2dedb4151615831ca12d3d0a830354b1c04e68)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 043cf1d8..6c4bcd39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [10.0.6](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.5...v10.0.6) (2023-05-27) + + +### Bug Fixes + +* replace simple-peer with maintained one ([#466](https://github.com/webtorrent/bittorrent-tracker/issues/466)) ([3b2dedb](https://github.com/webtorrent/bittorrent-tracker/commit/3b2dedb4151615831ca12d3d0a830354b1c04e68)) + ## [10.0.5](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.4...v10.0.5) (2023-05-27) diff --git a/package.json b/package.json index 86b9116d..4f0b4989 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.5", + "version": "10.0.6", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", From c338104687eabd38f36f690786c8c092e0a13a38 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 27 May 2023 22:07:20 +0200 Subject: [PATCH 058/119] chore(deps): update dependency magnet-uri to v7.0.4 (#468) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4f0b4989..bcb26840 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "devDependencies": { "@mapbox/node-pre-gyp": "1.0.10", "@webtorrent/semantic-release-config": "1.0.9", - "magnet-uri": "7.0.3", + "magnet-uri": "7.0.4", "semantic-release": "20.1.3", "standard": "*", "tape": "5.6.3", From ac3ea82ee62abd1d9bb5cd423e7a5d7b5dc9a4f7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 30 May 2023 23:18:11 +0000 Subject: [PATCH 059/119] chore(deps): update dependency magnet-uri to v7.0.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bcb26840..2a071b00 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "devDependencies": { "@mapbox/node-pre-gyp": "1.0.10", "@webtorrent/semantic-release-config": "1.0.9", - "magnet-uri": "7.0.4", + "magnet-uri": "7.0.5", "semantic-release": "20.1.3", "standard": "*", "tape": "5.6.3", From a12022ac2c81d7fa3ecb81163852161e64199cf4 Mon Sep 17 00:00:00 2001 From: Cas <6506529+ThaUnknown@users.noreply.github.com> Date: Mon, 5 Jun 2023 23:56:44 +0200 Subject: [PATCH 060/119] fix: imports (#471) --- lib/client/websocket-tracker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/client/websocket-tracker.js b/lib/client/websocket-tracker.js index f933323c..e577d3c3 100644 --- a/lib/client/websocket-tracker.js +++ b/lib/client/websocket-tracker.js @@ -5,7 +5,7 @@ import Socket from '@thaunknown/simple-websocket' import Socks from 'socks' import { arr2text, arr2hex, hex2bin, bin2hex, randomBytes } from 'uint8-util' -import { DESTROY_TIMEOUT } from '../common.js' +import common from '../common.js' import Tracker from './tracker.js' const debug = Debug('bittorrent-tracker:websocket-tracker') @@ -138,7 +138,7 @@ class WebSocketTracker extends Tracker { // Otherwise, wait a short time for potential responses to come in from the // server, then force close the socket. - timeout = setTimeout(destroyCleanup, DESTROY_TIMEOUT) + timeout = setTimeout(destroyCleanup, common.DESTROY_TIMEOUT) // But, if a response comes from the server before the timeout fires, do cleanup // right away. From a6bb919268359182415f6d5dd5b73b5f3484164a Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 5 Jun 2023 21:59:33 +0000 Subject: [PATCH 061/119] chore(release): 10.0.7 ## [10.0.7](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.6...v10.0.7) (2023-06-05) ### Bug Fixes * imports ([#471](https://github.com/webtorrent/bittorrent-tracker/issues/471)) ([a12022a](https://github.com/webtorrent/bittorrent-tracker/commit/a12022ac2c81d7fa3ecb81163852161e64199cf4)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c4bcd39..c3b43fd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [10.0.7](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.6...v10.0.7) (2023-06-05) + + +### Bug Fixes + +* imports ([#471](https://github.com/webtorrent/bittorrent-tracker/issues/471)) ([a12022a](https://github.com/webtorrent/bittorrent-tracker/commit/a12022ac2c81d7fa3ecb81163852161e64199cf4)) + ## [10.0.6](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.5...v10.0.6) (2023-05-27) diff --git a/package.json b/package.json index 2a071b00..9172092d 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.6", + "version": "10.0.7", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", From d7061f73b2ebff072e064971a5960749a7335bae Mon Sep 17 00:00:00 2001 From: Cas <6506529+ThaUnknown@users.noreply.github.com> Date: Wed, 7 Jun 2023 18:44:34 +0200 Subject: [PATCH 062/119] fix: bigInt (#472) --- lib/client/udp-tracker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/udp-tracker.js b/lib/client/udp-tracker.js index b3218bc5..3a3ad42a 100644 --- a/lib/client/udp-tracker.js +++ b/lib/client/udp-tracker.js @@ -323,7 +323,7 @@ function toUInt64 (n) { if (n > MAX_UINT || typeof n === 'string') { const buf = new Uint8Array(8) const view = new DataView(buf.buffer) - view.setBigUint64(0, n) + view.setBigUint64(0, BigInt(n)) return buf } return concat([new Uint8Array(4), common.toUInt32(n)]) From f9e8700177b0bae777109e0b284ffc4b8f2bd570 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 7 Jun 2023 19:00:05 +0200 Subject: [PATCH 063/119] chore(deps): update dependency semantic-release to v21 (#459) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9172092d..22b5e007 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "@mapbox/node-pre-gyp": "1.0.10", "@webtorrent/semantic-release-config": "1.0.9", "magnet-uri": "7.0.5", - "semantic-release": "20.1.3", + "semantic-release": "21.0.3", "standard": "*", "tape": "5.6.3", "webtorrent-fixtures": "2.0.2", From ff778f494649ecd3c3e68d02256bfe0b29b73e48 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 7 Jun 2023 18:05:08 +0000 Subject: [PATCH 064/119] chore(release): 10.0.8 ## [10.0.8](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.7...v10.0.8) (2023-06-07) ### Bug Fixes * bigInt ([#472](https://github.com/webtorrent/bittorrent-tracker/issues/472)) ([d7061f7](https://github.com/webtorrent/bittorrent-tracker/commit/d7061f73b2ebff072e064971a5960749a7335bae)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3b43fd2..b73db67f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [10.0.8](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.7...v10.0.8) (2023-06-07) + + +### Bug Fixes + +* bigInt ([#472](https://github.com/webtorrent/bittorrent-tracker/issues/472)) ([d7061f7](https://github.com/webtorrent/bittorrent-tracker/commit/d7061f73b2ebff072e064971a5960749a7335bae)) + ## [10.0.7](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.6...v10.0.7) (2023-06-05) diff --git a/package.json b/package.json index 22b5e007..850c8890 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.7", + "version": "10.0.8", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", From 0ddb991e3d3dff834e381436344ff75f94d1fb57 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 11 Jun 2023 00:32:03 +0000 Subject: [PATCH 065/119] chore(deps): update dependency semantic-release to v21.0.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 850c8890..c2af2a71 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "@mapbox/node-pre-gyp": "1.0.10", "@webtorrent/semantic-release-config": "1.0.9", "magnet-uri": "7.0.5", - "semantic-release": "21.0.3", + "semantic-release": "21.0.5", "standard": "*", "tape": "5.6.3", "webtorrent-fixtures": "2.0.2", From 7c845f030d07b1bf7060ab880b790ee85a8c7ac0 Mon Sep 17 00:00:00 2001 From: Cas <6506529+ThaUnknown@users.noreply.github.com> Date: Fri, 16 Jun 2023 23:05:28 +0200 Subject: [PATCH 066/119] perf: use peer/lite (#474) --- lib/client/websocket-tracker.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/client/websocket-tracker.js b/lib/client/websocket-tracker.js index e577d3c3..bc9f29e0 100644 --- a/lib/client/websocket-tracker.js +++ b/lib/client/websocket-tracker.js @@ -1,6 +1,6 @@ import clone from 'clone' import Debug from 'debug' -import Peer from '@thaunknown/simple-peer' +import Peer from '@thaunknown/simple-peer/lite.js' import Socket from '@thaunknown/simple-websocket' import Socks from 'socks' import { arr2text, arr2hex, hex2bin, bin2hex, randomBytes } from 'uint8-util' diff --git a/package.json b/package.json index c2af2a71..d935dc0d 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ }, "type": "module", "dependencies": { - "@thaunknown/simple-peer": "^9.12.0", + "@thaunknown/simple-peer": "^9.12.1", "@thaunknown/simple-websocket": "^9.1.0", "bencode": "^3.0.3", "bittorrent-peerid": "^1.3.3", From e3dd9b9003aefb6a6415ebd80b66744b74751aca Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 16 Jun 2023 21:08:26 +0000 Subject: [PATCH 067/119] chore(release): 10.0.9 ## [10.0.9](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.8...v10.0.9) (2023-06-16) ### Performance Improvements * use peer/lite ([#474](https://github.com/webtorrent/bittorrent-tracker/issues/474)) ([7c845f0](https://github.com/webtorrent/bittorrent-tracker/commit/7c845f030d07b1bf7060ab880b790ee85a8c7ac0)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b73db67f..33fe61c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [10.0.9](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.8...v10.0.9) (2023-06-16) + + +### Performance Improvements + +* use peer/lite ([#474](https://github.com/webtorrent/bittorrent-tracker/issues/474)) ([7c845f0](https://github.com/webtorrent/bittorrent-tracker/commit/7c845f030d07b1bf7060ab880b790ee85a8c7ac0)) + ## [10.0.8](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.7...v10.0.8) (2023-06-07) diff --git a/package.json b/package.json index d935dc0d..51158037 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.8", + "version": "10.0.9", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", From 5b8db067e48cc81796728ff538d7ff6efafc59b8 Mon Sep 17 00:00:00 2001 From: Cas <6506529+ThaUnknown@users.noreply.github.com> Date: Fri, 16 Jun 2023 23:50:47 +0200 Subject: [PATCH 068/119] perf: use simple-peer/lite (#475) --- client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.js b/client.js index 9942f361..c37345f1 100644 --- a/client.js +++ b/client.js @@ -2,7 +2,7 @@ import Debug from 'debug' import EventEmitter from 'events' import once from 'once' import parallel from 'run-parallel' -import Peer from '@thaunknown/simple-peer' +import Peer from '@thaunknown/simple-peer/lite.js' import queueMicrotask from 'queue-microtask' import { hex2arr, hex2bin, text2arr, arr2hex, arr2text } from 'uint8-util' From fcafbe5099bcdbc4205bb55e612c2db3a4121355 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 16 Jun 2023 21:53:42 +0000 Subject: [PATCH 069/119] chore(release): 10.0.10 ## [10.0.10](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.9...v10.0.10) (2023-06-16) ### Performance Improvements * use simple-peer/lite ([#475](https://github.com/webtorrent/bittorrent-tracker/issues/475)) ([5b8db06](https://github.com/webtorrent/bittorrent-tracker/commit/5b8db067e48cc81796728ff538d7ff6efafc59b8)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33fe61c7..7bf4f32c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [10.0.10](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.9...v10.0.10) (2023-06-16) + + +### Performance Improvements + +* use simple-peer/lite ([#475](https://github.com/webtorrent/bittorrent-tracker/issues/475)) ([5b8db06](https://github.com/webtorrent/bittorrent-tracker/commit/5b8db067e48cc81796728ff538d7ff6efafc59b8)) + ## [10.0.9](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.8...v10.0.9) (2023-06-16) diff --git a/package.json b/package.json index 51158037..21c87e40 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.9", + "version": "10.0.10", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", From 9840d4cfb938952448603c35906de1729c133771 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 29 Jun 2023 21:43:32 +0000 Subject: [PATCH 070/119] chore(deps): update dependency semantic-release to v21.0.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 21c87e40..4ea8b0ff 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "@mapbox/node-pre-gyp": "1.0.10", "@webtorrent/semantic-release-config": "1.0.9", "magnet-uri": "7.0.5", - "semantic-release": "21.0.5", + "semantic-release": "21.0.6", "standard": "*", "tape": "5.6.3", "webtorrent-fixtures": "2.0.2", From 5c97a2e153cadf7a54a3c74b0dce35b44c318ffe Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 3 Jul 2023 07:03:53 +0000 Subject: [PATCH 071/119] chore(deps): update dependency tape to v5.6.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4ea8b0ff..ef0ff6bf 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "magnet-uri": "7.0.5", "semantic-release": "21.0.6", "standard": "*", - "tape": "5.6.3", + "tape": "5.6.4", "webtorrent-fixtures": "2.0.2", "wrtc": "0.4.7" }, From e4aa13710888b9a52e294ba94e6a5992e8e7ccd5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 6 Jul 2023 03:56:07 +0000 Subject: [PATCH 072/119] chore(deps): update dependency semantic-release to v21.0.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ef0ff6bf..b5086ed1 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "@mapbox/node-pre-gyp": "1.0.10", "@webtorrent/semantic-release-config": "1.0.9", "magnet-uri": "7.0.5", - "semantic-release": "21.0.6", + "semantic-release": "21.0.7", "standard": "*", "tape": "5.6.4", "webtorrent-fixtures": "2.0.2", From 9ca746802f4ad44415e17e8ccd957d8b49fe7c30 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 13 Jul 2023 22:52:53 +0000 Subject: [PATCH 073/119] chore(deps): update dependency tape to v5.6.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b5086ed1..b8a8d07c 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "magnet-uri": "7.0.5", "semantic-release": "21.0.7", "standard": "*", - "tape": "5.6.4", + "tape": "5.6.5", "webtorrent-fixtures": "2.0.2", "wrtc": "0.4.7" }, From d2d361f953cea7c45846fba79f3350345e5c8d70 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 19 Jul 2023 21:45:05 +0000 Subject: [PATCH 074/119] chore(deps): update dependency tape to v5.6.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b8a8d07c..2f383ed6 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "magnet-uri": "7.0.5", "semantic-release": "21.0.7", "standard": "*", - "tape": "5.6.5", + "tape": "5.6.6", "webtorrent-fixtures": "2.0.2", "wrtc": "0.4.7" }, From 63e51444e7eddab86dc6fbc82c204d4d603e43fb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 23 Jul 2023 22:20:04 +0200 Subject: [PATCH 075/119] chore(deps): update dependency @mapbox/node-pre-gyp to v1.0.11 (#482) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2f383ed6..5c2bf6f5 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "ws": "^8.0.0" }, "devDependencies": { - "@mapbox/node-pre-gyp": "1.0.10", + "@mapbox/node-pre-gyp": "1.0.11", "@webtorrent/semantic-release-config": "1.0.9", "magnet-uri": "7.0.5", "semantic-release": "21.0.7", From bd1acfbdc104e5fd7018bc71ed9225f7e1c16990 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 23 Jul 2023 22:21:52 +0200 Subject: [PATCH 076/119] chore(deps): update actions/stale action to v8 (#484) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/stale.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 6db0d135..2b2bab3b 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -12,7 +12,7 @@ jobs: pull-requests: write steps: - - uses: actions/stale@v7 + - uses: actions/stale@v8 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?' From b487809c85d274d57ff39c198dc548b9a1a27617 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 24 Jul 2023 12:06:27 +0000 Subject: [PATCH 077/119] chore(deps): update dependency @webtorrent/semantic-release-config to v1.0.10 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5c2bf6f5..24188c1a 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ }, "devDependencies": { "@mapbox/node-pre-gyp": "1.0.11", - "@webtorrent/semantic-release-config": "1.0.9", + "@webtorrent/semantic-release-config": "1.0.10", "magnet-uri": "7.0.5", "semantic-release": "21.0.7", "standard": "*", From 11cce83ddd858813f5684da8a116de4bee6e518b Mon Sep 17 00:00:00 2001 From: Cas <6506529+ThaUnknown@users.noreply.github.com> Date: Wed, 2 Aug 2023 00:05:46 +0200 Subject: [PATCH 078/119] fix: mangled scrape infohashes (#486) --- lib/client/http-tracker.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/client/http-tracker.js b/lib/client/http-tracker.js index 162c68fb..9eefd892 100644 --- a/lib/client/http-tracker.js +++ b/lib/client/http-tracker.js @@ -4,7 +4,7 @@ import clone from 'clone' import Debug from 'debug' import get from 'simple-get' import Socks from 'socks' -import { bin2hex, hex2bin, arr2text } from 'uint8-util' +import { bin2hex, hex2bin, arr2text, text2arr, arr2hex } from 'uint8-util' import common from '../common.js' import Tracker from './tracker.js' @@ -244,12 +244,14 @@ class HTTPTracker extends Tracker { return } - keys.forEach(infoHash => { + keys.forEach(_infoHash => { // TODO: optionally handle data.flags.min_request_interval // (separate from announce interval) - const response = Object.assign(data[infoHash], { + const infoHash = _infoHash.length !== 20 ? arr2hex(text2arr(_infoHash)) : bin2hex(_infoHash) + + const response = Object.assign(data[_infoHash], { announce: this.announceUrl, - infoHash: bin2hex(infoHash) + infoHash }) this.client.emit('scrape', response) }) From ae54372ce94f78f3fe8d368c32788e3fd9526461 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 1 Aug 2023 22:08:37 +0000 Subject: [PATCH 079/119] chore(release): 10.0.11 ## [10.0.11](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.10...v10.0.11) (2023-08-01) ### Bug Fixes * mangled scrape infohashes ([#486](https://github.com/webtorrent/bittorrent-tracker/issues/486)) ([11cce83](https://github.com/webtorrent/bittorrent-tracker/commit/11cce83ddd858813f5684da8a116de4bee6e518b)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bf4f32c..c6365c39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [10.0.11](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.10...v10.0.11) (2023-08-01) + + +### Bug Fixes + +* mangled scrape infohashes ([#486](https://github.com/webtorrent/bittorrent-tracker/issues/486)) ([11cce83](https://github.com/webtorrent/bittorrent-tracker/commit/11cce83ddd858813f5684da8a116de4bee6e518b)) + ## [10.0.10](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.9...v10.0.10) (2023-06-16) diff --git a/package.json b/package.json index 24188c1a..e7b039d7 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.10", + "version": "10.0.11", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", From aeccf9c1c4b9115fd23b4fe1a0ab990b5add0f17 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 9 Aug 2023 09:48:00 +0200 Subject: [PATCH 080/119] fix(deps): update dependency bencode to v4 (#487) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e7b039d7..b2793ca8 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "dependencies": { "@thaunknown/simple-peer": "^9.12.1", "@thaunknown/simple-websocket": "^9.1.0", - "bencode": "^3.0.3", + "bencode": "^4.0.0", "bittorrent-peerid": "^1.3.3", "chrome-dgram": "^3.0.6", "clone": "^2.0.0", From ad00e131991635d11bc5ca87420d233de3d952ec Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 9 Aug 2023 07:50:55 +0000 Subject: [PATCH 081/119] chore(release): 10.0.12 ## [10.0.12](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.11...v10.0.12) (2023-08-09) ### Bug Fixes * **deps:** update dependency bencode to v4 ([#487](https://github.com/webtorrent/bittorrent-tracker/issues/487)) ([aeccf9c](https://github.com/webtorrent/bittorrent-tracker/commit/aeccf9c1c4b9115fd23b4fe1a0ab990b5add0f17)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6365c39..43224a7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [10.0.12](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.11...v10.0.12) (2023-08-09) + + +### Bug Fixes + +* **deps:** update dependency bencode to v4 ([#487](https://github.com/webtorrent/bittorrent-tracker/issues/487)) ([aeccf9c](https://github.com/webtorrent/bittorrent-tracker/commit/aeccf9c1c4b9115fd23b4fe1a0ab990b5add0f17)) + ## [10.0.11](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.10...v10.0.11) (2023-08-01) diff --git a/package.json b/package.json index b2793ca8..9d537a8a 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.11", + "version": "10.0.12", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", From 6c85f1eab11d8d9e97f29482aef72677b11ff0c3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 21 Aug 2023 01:16:35 +0000 Subject: [PATCH 082/119] chore(deps): update dependency semantic-release to v21.0.8 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9d537a8a..c3859fc3 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "@mapbox/node-pre-gyp": "1.0.11", "@webtorrent/semantic-release-config": "1.0.10", "magnet-uri": "7.0.5", - "semantic-release": "21.0.7", + "semantic-release": "21.0.8", "standard": "*", "tape": "5.6.6", "webtorrent-fixtures": "2.0.2", From 0f611476e6058ea675b5282c2bfeca9bec731f94 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 21 Aug 2023 03:31:09 +0000 Subject: [PATCH 083/119] chore(deps): update dependency semantic-release to v21.0.9 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c3859fc3..b017dac3 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "@mapbox/node-pre-gyp": "1.0.11", "@webtorrent/semantic-release-config": "1.0.10", "magnet-uri": "7.0.5", - "semantic-release": "21.0.8", + "semantic-release": "21.0.9", "standard": "*", "tape": "5.6.6", "webtorrent-fixtures": "2.0.2", From 3268ae5d7f77dae4fe2c9f01dbb9f3192cd55ae4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 25 Aug 2023 03:22:10 +0000 Subject: [PATCH 084/119] chore(deps): update dependency semantic-release to v21.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b017dac3..fe0af5e0 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "@mapbox/node-pre-gyp": "1.0.11", "@webtorrent/semantic-release-config": "1.0.10", "magnet-uri": "7.0.5", - "semantic-release": "21.0.9", + "semantic-release": "21.1.0", "standard": "*", "tape": "5.6.6", "webtorrent-fixtures": "2.0.2", From a6922f7ee83fd73ca386190d1deaaadbb66bcd3d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 25 Aug 2023 16:54:39 +0000 Subject: [PATCH 085/119] chore(deps): update dependency semantic-release to v21.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fe0af5e0..f47eb6bb 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "@mapbox/node-pre-gyp": "1.0.11", "@webtorrent/semantic-release-config": "1.0.10", "magnet-uri": "7.0.5", - "semantic-release": "21.1.0", + "semantic-release": "21.1.1", "standard": "*", "tape": "5.6.6", "webtorrent-fixtures": "2.0.2", From 7ddd0035919f0aa7f756a0251e3a00897358afeb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 17 Sep 2023 05:11:56 +0000 Subject: [PATCH 086/119] chore(deps): update dependency semantic-release to v21.1.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f47eb6bb..8cb197ce 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "@mapbox/node-pre-gyp": "1.0.11", "@webtorrent/semantic-release-config": "1.0.10", "magnet-uri": "7.0.5", - "semantic-release": "21.1.1", + "semantic-release": "21.1.2", "standard": "*", "tape": "5.6.6", "webtorrent-fixtures": "2.0.2", From de4a34b4aad5861a4a6f571a08c406a0a027780a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 22 Sep 2023 23:06:26 +0000 Subject: [PATCH 087/119] chore(deps): update dependency tape to v5.7.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8cb197ce..b39f3de6 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "magnet-uri": "7.0.5", "semantic-release": "21.1.2", "standard": "*", - "tape": "5.6.6", + "tape": "5.7.0", "webtorrent-fixtures": "2.0.2", "wrtc": "0.4.7" }, From 5e8673689f85d39e93a08d37b891940c455f048e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 12 Oct 2023 23:10:16 +0000 Subject: [PATCH 088/119] chore(deps): update dependency tape to v5.7.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b39f3de6..d6a856e1 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "magnet-uri": "7.0.5", "semantic-release": "21.1.2", "standard": "*", - "tape": "5.7.0", + "tape": "5.7.1", "webtorrent-fixtures": "2.0.2", "wrtc": "0.4.7" }, From e14738bd84b11fff3ebb8bf2a743796f51e7f834 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 22 Oct 2023 06:47:47 +0000 Subject: [PATCH 089/119] chore(deps): update dependency tape to v5.7.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d6a856e1..16294d41 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "magnet-uri": "7.0.5", "semantic-release": "21.1.2", "standard": "*", - "tape": "5.7.1", + "tape": "5.7.2", "webtorrent-fixtures": "2.0.2", "wrtc": "0.4.7" }, From bce64e155df6ff9fa605898cbf7498bf76188d8b Mon Sep 17 00:00:00 2001 From: Cas_ <6506529+ThaUnknown@users.noreply.github.com> Date: Tue, 31 Oct 2023 10:51:04 +0100 Subject: [PATCH 090/119] feat(major): drop simple-get (#443) BREAKING CHANGE: drop simple-get * perf: drop simple-get * feat: undici agent and socks * fix: undici as dev dependency * feat: require user passed proxy objects for http and ws * chore: include undici for tests --- README.md | 61 ++++------ lib/client/http-tracker.js | 108 ++++++++++-------- lib/client/websocket-tracker.js | 4 +- package.json | 3 +- test/client.js | 28 ++++- test/scrape.js | 73 ++++++------ test/stats.js | 195 ++++++++++++++++---------------- 7 files changed, 242 insertions(+), 230 deletions(-) diff --git a/README.md b/README.md index 1f2a791c..3f3b83ba 100644 --- a/README.md +++ b/README.md @@ -55,16 +55,16 @@ npm install bittorrent-tracker To connect to a tracker, just do this: ```js -var Client = require('bittorrent-tracker') +import Client from 'bittorrent-tracker' -var requiredOpts = { +const requiredOpts = { infoHash: new Buffer('012345678901234567890'), // hex string or Buffer peerId: new Buffer('01234567890123456789'), // hex string or Buffer announce: [], // list of tracker server urls port: 6881 // torrent client port, (in browser, optional) } -var optionalOpts = { +const optionalOpts = { // RTCPeerConnection config object (only used in browser) rtcConfig: {}, // User-Agent header for http requests @@ -81,47 +81,24 @@ var optionalOpts = { customParam: 'blah' // custom parameters supported } }, - // Proxy config object + // Proxy options (used to proxy requests in node) proxyOpts: { - // Socks proxy options (used to proxy requests in node) - socksProxy: { - // Configuration from socks module (https://github.com/JoshGlazebrook/socks) - proxy: { - // IP Address of Proxy (Required) - ipaddress: "1.2.3.4", - // TCP Port of Proxy (Required) - port: 1080, - // Proxy Type [4, 5] (Required) - // Note: 4 works for both 4 and 4a. - // Type 4 does not support UDP association relay - type: 5, - - // SOCKS 4 Specific: - - // UserId used when making a SOCKS 4/4a request. (Optional) - userid: "someuserid", - - // SOCKS 5 Specific: - - // Authentication used for SOCKS 5 (when it's required) (Optional) - authentication: { - username: "Josh", - password: "somepassword" - } - }, - - // Amount of time to wait for a connection to be established. (Optional) - // - defaults to 10000ms (10 seconds) - timeout: 10000 - }, - // NodeJS HTTP agents (used to proxy HTTP and Websocket requests in node) - // Populated with Socks.Agent if socksProxy is provided - httpAgent: {}, - httpsAgent: {} + // For WSS trackers this is always a http.Agent + // For UDP trackers this is an object of options for the Socks Connection + // For HTTP trackers this is either an undici Agent if using Node16 or later, or http.Agent if using versions prior to Node 16, ex: + // import Socks from 'socks' + // proxyOpts.socksProxy = new Socks.Agent(optionsObject, isHttps) + // or if using Node 16 or later + // import { socksDispatcher } from 'fetch-socks' + // proxyOpts.socksProxy = socksDispatcher(optionsObject) + socksProxy: new SocksProxy(socksOptionsObject), + // Populated with socksProxy if it's provided + httpAgent: new http.Agent(agentOptionsObject), + httpsAgent: new https.Agent(agentOptionsObject) }, } -var client = new Client(requiredOpts) +const client = new Client(requiredOpts) client.on('error', function (err) { // fatal client error! @@ -182,7 +159,7 @@ client.on('scrape', function (data) { To start a BitTorrent tracker server to track swarms of peers: ```js -const Server = require('bittorrent-tracker').Server +import { Server } from 'bittorrent-tracker' const server = new Server({ udp: true, // enable udp server? [default=true] @@ -289,7 +266,7 @@ The http server will handle requests for the following paths: `/announce`, `/scr Scraping multiple torrent info is possible with a static `Client.scrape` method: ```js -var Client = require('bittorrent-tracker') +import Client from 'bittorrent-tracker' Client.scrape({ announce: announceUrl, infoHash: [ infoHash1, infoHash2 ]}, function (err, results) { results[infoHash1].announce results[infoHash1].infoHash diff --git a/lib/client/http-tracker.js b/lib/client/http-tracker.js index 9eefd892..6297d2e2 100644 --- a/lib/client/http-tracker.js +++ b/lib/client/http-tracker.js @@ -1,9 +1,7 @@ import arrayRemove from 'unordered-array-remove' import bencode from 'bencode' -import clone from 'clone' import Debug from 'debug' -import get from 'simple-get' -import Socks from 'socks' +import fetch from 'cross-fetch-ponyfill' import { bin2hex, hex2bin, arr2text, text2arr, arr2hex } from 'uint8-util' import common from '../common.js' @@ -13,6 +11,14 @@ import compact2string from 'compact2string' const debug = Debug('bittorrent-tracker:http-tracker') const HTTP_SCRAPE_SUPPORT = /\/(announce)[^/]*$/ +function abortTimeout (ms) { + const controller = new AbortController() + setTimeout(() => { + controller.abort() + }, ms).unref?.() + return controller +} + /** * HTTP torrent tracker client (for an individual tracker) * @@ -112,70 +118,72 @@ class HTTPTracker extends Tracker { } } - _request (requestUrl, params, cb) { - const self = this + async _request (requestUrl, params, cb) { const parsedUrl = new URL(requestUrl + (requestUrl.indexOf('?') === -1 ? '?' : '&') + common.querystringStringify(params)) let agent if (this.client._proxyOpts) { agent = parsedUrl.protocol === 'https:' ? this.client._proxyOpts.httpsAgent : this.client._proxyOpts.httpAgent if (!agent && this.client._proxyOpts.socksProxy) { - agent = new Socks.Agent(clone(this.client._proxyOpts.socksProxy), (parsedUrl.protocol === 'https:')) + agent = this.client._proxyOpts.socksProxy } } - this.cleanupFns.push(cleanup) - - let request = get.concat({ - url: parsedUrl.toString(), - agent, - timeout: common.REQUEST_TIMEOUT, - headers: { - 'user-agent': this.client._userAgent || '' - } - }, onResponse) - - function cleanup () { - if (request) { - arrayRemove(self.cleanupFns, self.cleanupFns.indexOf(cleanup)) - request.abort() - request = null + const cleanup = () => { + if (!controller.signal.aborted) { + arrayRemove(this.cleanupFns, this.cleanupFns.indexOf(cleanup)) + controller.abort() + controller = null } - if (self.maybeDestroyCleanup) self.maybeDestroyCleanup() + if (this.maybeDestroyCleanup) this.maybeDestroyCleanup() } - function onResponse (err, res, data) { - cleanup() - if (self.destroyed) return + this.cleanupFns.push(cleanup) + let res + let controller = abortTimeout(common.REQUEST_TIMEOUT) + try { + res = await fetch(parsedUrl.toString(), { + agent, + signal: controller.signal, + dispatcher: agent, + headers: { + 'user-agent': this.client._userAgent || '' + } + }) + } catch (err) { if (err) return cb(err) - if (res.statusCode !== 200) { - return cb(new Error(`Non-200 response code ${res.statusCode} from ${self.announceUrl}`)) - } - if (!data || data.length === 0) { - return cb(new Error(`Invalid tracker response from${self.announceUrl}`)) - } - - try { - data = bencode.decode(data) - } catch (err) { - return cb(new Error(`Error decoding tracker response: ${err.message}`)) - } - const failure = data['failure reason'] && arr2text(data['failure reason']) - if (failure) { - debug(`failure from ${requestUrl} (${failure})`) - return cb(new Error(failure)) - } + } + let data = new Uint8Array(await res.arrayBuffer()) + cleanup() + if (this.destroyed) return - const warning = data['warning message'] && arr2text(data['warning message']) - if (warning) { - debug(`warning from ${requestUrl} (${warning})`) - self.client.emit('warning', new Error(warning)) - } + if (res.status !== 200) { + return cb(new Error(`Non-200 response code ${res.statusCode} from ${this.announceUrl}`)) + } + if (!data || data.length === 0) { + return cb(new Error(`Invalid tracker response from${this.announceUrl}`)) + } - debug(`response from ${requestUrl}`) + try { + data = bencode.decode(data) + } catch (err) { + return cb(new Error(`Error decoding tracker response: ${err.message}`)) + } + const failure = data['failure reason'] && arr2text(data['failure reason']) + if (failure) { + debug(`failure from ${requestUrl} (${failure})`) + return cb(new Error(failure)) + } - cb(null, data) + const warning = data['warning message'] && arr2text(data['warning message']) + if (warning) { + debug(`warning from ${requestUrl} (${warning})`) + this.client.emit('warning', new Error(warning)) } + + debug(`response from ${requestUrl}`) + + cb(null, data) } _onAnnounceResponse (data) { diff --git a/lib/client/websocket-tracker.js b/lib/client/websocket-tracker.js index bc9f29e0..c4e3e23d 100644 --- a/lib/client/websocket-tracker.js +++ b/lib/client/websocket-tracker.js @@ -1,8 +1,6 @@ -import clone from 'clone' import Debug from 'debug' import Peer from '@thaunknown/simple-peer/lite.js' import Socket from '@thaunknown/simple-websocket' -import Socks from 'socks' import { arr2text, arr2hex, hex2bin, bin2hex, randomBytes } from 'uint8-util' import common from '../common.js' @@ -185,7 +183,7 @@ class WebSocketTracker extends Tracker { if (this.client._proxyOpts) { agent = parsedUrl.protocol === 'wss:' ? this.client._proxyOpts.httpsAgent : this.client._proxyOpts.httpAgent if (!agent && this.client._proxyOpts.socksProxy) { - agent = new Socks.Agent(clone(this.client._proxyOpts.socksProxy), (parsedUrl.protocol === 'wss:')) + agent = this.client._proxyOpts.socksProxy } } this.socket = socketPool[this.announceUrl] = new Socket({ url: this.announceUrl, agent }) diff --git a/package.json b/package.json index 16294d41..1fed807c 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "chrome-dgram": "^3.0.6", "clone": "^2.0.0", "compact2string": "^1.4.1", + "cross-fetch-ponyfill": "^1.0.1", "debug": "^4.1.1", "ip": "^1.1.5", "lru": "^3.1.0", @@ -43,7 +44,6 @@ "random-iterate": "^1.0.1", "run-parallel": "^1.2.0", "run-series": "^1.1.9", - "simple-get": "^4.0.0", "socks": "^2.0.0", "string2compact": "^2.0.0", "uint8-util": "^2.1.9", @@ -57,6 +57,7 @@ "semantic-release": "21.1.2", "standard": "*", "tape": "5.7.2", + "undici": "^5.27.0", "webtorrent-fixtures": "2.0.2", "wrtc": "0.4.7" }, diff --git a/test/client.js b/test/client.js index c579058c..d81ee55f 100644 --- a/test/client.js +++ b/test/client.js @@ -4,6 +4,7 @@ import http from 'http' import fixtures from 'webtorrent-fixtures' import net from 'net' import test from 'tape' +import undici from 'undici' const peerId1 = Buffer.from('01234567890123456789') const peerId2 = Buffer.from('12345678901234567890') @@ -572,12 +573,29 @@ function testClientStartHttpAgent (t, serverType) { t.plan(5) common.createServer(t, serverType, function (server, announceUrl) { - const agent = new http.Agent() - let agentUsed = false - agent.createConnection = function (opts, fn) { - agentUsed = true - return net.createConnection(opts, fn) + let agent + if (global.fetch && serverType !== 'ws') { + const connector = undici.buildConnector({ rejectUnauthorized: false }) + agent = new undici.Agent({ + connect (opts, cb) { + agentUsed = true + connector(opts, (err, socket) => { + if (err) { + cb(err, null) + } else { + cb(null, socket) + } + }) + } + }) + } else { + agent = new http.Agent() + agent.createConnection = function (opts, fn) { + agentUsed = true + return net.createConnection(opts, fn) + } } + let agentUsed = false const client = new Client({ infoHash: fixtures.leaves.parsedTorrent.infoHash, announce: announceUrl, diff --git a/test/scrape.js b/test/scrape.js index 38af0a42..c0c101a5 100644 --- a/test/scrape.js +++ b/test/scrape.js @@ -3,7 +3,7 @@ import Client from '../index.js' import common from './common.js' import commonLib from '../lib/common.js' import fixtures from 'webtorrent-fixtures' -import get from 'simple-get' +import fetch from 'cross-fetch-ponyfill' import test from 'tape' import { hex2bin } from 'uint8-util' @@ -151,44 +151,47 @@ test('udp: MULTI scrape using Client.scrape static method', t => { }) test('server: multiple info_hash scrape (manual http request)', t => { - t.plan(13) + t.plan(12) const binaryInfoHash1 = hex2bin(fixtures.leaves.parsedTorrent.infoHash) const binaryInfoHash2 = hex2bin(fixtures.alice.parsedTorrent.infoHash) - common.createServer(t, 'http', (server, announceUrl) => { + common.createServer(t, 'http', async (server, announceUrl) => { const scrapeUrl = announceUrl.replace('/announce', '/scrape') const url = `${scrapeUrl}?${commonLib.querystringStringify({ info_hash: [binaryInfoHash1, binaryInfoHash2] })}` - - get.concat(url, (err, res, data) => { + let res + try { + res = await fetch(url) + } catch (err) { t.error(err) + } + let data = Buffer.from(await res.arrayBuffer()) - t.equal(res.statusCode, 200) + t.equal(res.status, 200) - data = bencode.decode(data) - t.ok(data.files) - t.equal(Object.keys(data.files).length, 2) + data = bencode.decode(data) + t.ok(data.files) + t.equal(Object.keys(data.files).length, 2) - t.ok(data.files[binaryInfoHash1]) - t.equal(typeof data.files[binaryInfoHash1].complete, 'number') - t.equal(typeof data.files[binaryInfoHash1].incomplete, 'number') - t.equal(typeof data.files[binaryInfoHash1].downloaded, 'number') + t.ok(data.files[binaryInfoHash1]) + t.equal(typeof data.files[binaryInfoHash1].complete, 'number') + t.equal(typeof data.files[binaryInfoHash1].incomplete, 'number') + t.equal(typeof data.files[binaryInfoHash1].downloaded, 'number') - t.ok(data.files[binaryInfoHash2]) - t.equal(typeof data.files[binaryInfoHash2].complete, 'number') - t.equal(typeof data.files[binaryInfoHash2].incomplete, 'number') - t.equal(typeof data.files[binaryInfoHash2].downloaded, 'number') + t.ok(data.files[binaryInfoHash2]) + t.equal(typeof data.files[binaryInfoHash2].complete, 'number') + t.equal(typeof data.files[binaryInfoHash2].incomplete, 'number') + t.equal(typeof data.files[binaryInfoHash2].downloaded, 'number') - server.close(() => { t.pass('server closed') }) - }) + server.close(() => { t.pass('server closed') }) }) }) test('server: all info_hash scrape (manual http request)', t => { - t.plan(10) + t.plan(9) const binaryInfoHash = hex2bin(fixtures.leaves.parsedTorrent.infoHash) @@ -207,24 +210,28 @@ test('server: all info_hash scrape (manual http request)', t => { client.start() - server.once('start', () => { + server.once('start', async () => { // now do a scrape of everything by omitting the info_hash param - get.concat(scrapeUrl, (err, res, data) => { + let res + try { + res = await fetch(scrapeUrl) + } catch (err) { t.error(err) + } + let data = Buffer.from(await res.arrayBuffer()) - t.equal(res.statusCode, 200) - data = bencode.decode(data) - t.ok(data.files) - t.equal(Object.keys(data.files).length, 1) + t.equal(res.status, 200) + data = bencode.decode(data) + t.ok(data.files) + t.equal(Object.keys(data.files).length, 1) - t.ok(data.files[binaryInfoHash]) - t.equal(typeof data.files[binaryInfoHash].complete, 'number') - t.equal(typeof data.files[binaryInfoHash].incomplete, 'number') - t.equal(typeof data.files[binaryInfoHash].downloaded, 'number') + t.ok(data.files[binaryInfoHash]) + t.equal(typeof data.files[binaryInfoHash].complete, 'number') + t.equal(typeof data.files[binaryInfoHash].incomplete, 'number') + t.equal(typeof data.files[binaryInfoHash].downloaded, 'number') - client.destroy(() => { t.pass('client destroyed') }) - server.close(() => { t.pass('server closed') }) - }) + client.destroy(() => { t.pass('client destroyed') }) + server.close(() => { t.pass('server closed') }) }) }) }) diff --git a/test/stats.js b/test/stats.js index 3ffa3fe3..7223da01 100644 --- a/test/stats.js +++ b/test/stats.js @@ -1,7 +1,7 @@ import Client from '../index.js' import commonTest from './common.js' import fixtures from 'webtorrent-fixtures' -import get from 'simple-get' +import fetch from 'cross-fetch-ponyfill' import test from 'tape' const peerId = Buffer.from('-WW0091-4ea5886ce160') @@ -30,89 +30,94 @@ function parseHtml (html) { } test('server: get empty stats', t => { - t.plan(11) + t.plan(10) - commonTest.createServer(t, 'http', (server, announceUrl) => { + commonTest.createServer(t, 'http', async (server, announceUrl) => { const url = announceUrl.replace('/announce', '/stats') - get.concat(url, (err, res, data) => { + let res + try { + res = await fetch(url) + } catch (err) { t.error(err) - - const stats = parseHtml(data.toString()) - t.equal(res.statusCode, 200) - t.equal(stats.torrents, 0) - t.equal(stats.activeTorrents, 0) - t.equal(stats.peersAll, 0) - t.equal(stats.peersSeederOnly, 0) - t.equal(stats.peersLeecherOnly, 0) - t.equal(stats.peersSeederAndLeecher, 0) - t.equal(stats.peersIPv4, 0) - t.equal(stats.peersIPv6, 0) - - server.close(() => { t.pass('server closed') }) - }) + } + const data = Buffer.from(await res.arrayBuffer()) + + const stats = parseHtml(data.toString()) + t.equal(res.status, 200) + t.equal(stats.torrents, 0) + t.equal(stats.activeTorrents, 0) + t.equal(stats.peersAll, 0) + t.equal(stats.peersSeederOnly, 0) + t.equal(stats.peersLeecherOnly, 0) + t.equal(stats.peersSeederAndLeecher, 0) + t.equal(stats.peersIPv4, 0) + t.equal(stats.peersIPv6, 0) + + server.close(() => { t.pass('server closed') }) }) }) test('server: get empty stats with json header', t => { - t.plan(11) + t.plan(10) - commonTest.createServer(t, 'http', (server, announceUrl) => { + commonTest.createServer(t, 'http', async (server, announceUrl) => { const opts = { url: announceUrl.replace('/announce', '/stats'), headers: { accept: 'application/json' - }, - json: true + } } - - get.concat(opts, (err, res, stats) => { + let res + try { + res = await fetch(announceUrl.replace('/announce', '/stats'), opts) + } catch (err) { t.error(err) - - t.equal(res.statusCode, 200) - t.equal(stats.torrents, 0) - t.equal(stats.activeTorrents, 0) - t.equal(stats.peersAll, 0) - t.equal(stats.peersSeederOnly, 0) - t.equal(stats.peersLeecherOnly, 0) - t.equal(stats.peersSeederAndLeecher, 0) - t.equal(stats.peersIPv4, 0) - t.equal(stats.peersIPv6, 0) - - server.close(() => { t.pass('server closed') }) - }) + } + const stats = await res.json() + + t.equal(res.status, 200) + t.equal(stats.torrents, 0) + t.equal(stats.activeTorrents, 0) + t.equal(stats.peersAll, 0) + t.equal(stats.peersSeederOnly, 0) + t.equal(stats.peersLeecherOnly, 0) + t.equal(stats.peersSeederAndLeecher, 0) + t.equal(stats.peersIPv4, 0) + t.equal(stats.peersIPv6, 0) + + server.close(() => { t.pass('server closed') }) }) }) test('server: get empty stats on stats.json', t => { - t.plan(11) + t.plan(10) - commonTest.createServer(t, 'http', (server, announceUrl) => { - const opts = { - url: announceUrl.replace('/announce', '/stats.json'), - json: true - } - - get.concat(opts, (err, res, stats) => { + commonTest.createServer(t, 'http', async (server, announceUrl) => { + let res + try { + res = await fetch(announceUrl.replace('/announce', '/stats.json')) + } catch (err) { t.error(err) - - t.equal(res.statusCode, 200) - t.equal(stats.torrents, 0) - t.equal(stats.activeTorrents, 0) - t.equal(stats.peersAll, 0) - t.equal(stats.peersSeederOnly, 0) - t.equal(stats.peersLeecherOnly, 0) - t.equal(stats.peersSeederAndLeecher, 0) - t.equal(stats.peersIPv4, 0) - t.equal(stats.peersIPv6, 0) - - server.close(() => { t.pass('server closed') }) - }) + } + const stats = await res.json() + + t.equal(res.status, 200) + t.equal(stats.torrents, 0) + t.equal(stats.activeTorrents, 0) + t.equal(stats.peersAll, 0) + t.equal(stats.peersSeederOnly, 0) + t.equal(stats.peersLeecherOnly, 0) + t.equal(stats.peersSeederAndLeecher, 0) + t.equal(stats.peersIPv4, 0) + t.equal(stats.peersIPv6, 0) + + server.close(() => { t.pass('server closed') }) }) }) test('server: get leecher stats.json', t => { - t.plan(11) + t.plan(10) commonTest.createServer(t, 'http', (server, announceUrl) => { // announce a torrent to the tracker @@ -127,33 +132,32 @@ test('server: get leecher stats.json', t => { client.start() - server.once('start', () => { - const opts = { - url: announceUrl.replace('/announce', '/stats.json'), - json: true + server.once('start', async () => { + let res + try { + res = await fetch(announceUrl.replace('/announce', '/stats.json')) + } catch (err) { + t.error(err) } + const stats = await res.json() - get.concat(opts, (err, res, stats) => { - t.error(err) + t.equal(res.status, 200) + t.equal(stats.torrents, 1) + t.equal(stats.activeTorrents, 1) + t.equal(stats.peersAll, 1) + t.equal(stats.peersSeederOnly, 0) + t.equal(stats.peersLeecherOnly, 1) + t.equal(stats.peersSeederAndLeecher, 0) + t.equal(stats.clients.WebTorrent['0.91'], 1) - t.equal(res.statusCode, 200) - t.equal(stats.torrents, 1) - t.equal(stats.activeTorrents, 1) - t.equal(stats.peersAll, 1) - t.equal(stats.peersSeederOnly, 0) - t.equal(stats.peersLeecherOnly, 1) - t.equal(stats.peersSeederAndLeecher, 0) - t.equal(stats.clients.WebTorrent['0.91'], 1) - - client.destroy(() => { t.pass('client destroyed') }) - server.close(() => { t.pass('server closed') }) - }) + client.destroy(() => { t.pass('client destroyed') }) + server.close(() => { t.pass('server closed') }) }) }) }) test('server: get leecher stats.json (unknown peerId)', t => { - t.plan(11) + t.plan(10) commonTest.createServer(t, 'http', (server, announceUrl) => { // announce a torrent to the tracker @@ -168,27 +172,26 @@ test('server: get leecher stats.json (unknown peerId)', t => { client.start() - server.once('start', () => { - const opts = { - url: announceUrl.replace('/announce', '/stats.json'), - json: true + server.once('start', async () => { + let res + try { + res = await fetch(announceUrl.replace('/announce', '/stats.json')) + } catch (err) { + t.error(err) } + const stats = await res.json() - get.concat(opts, (err, res, stats) => { - t.error(err) + t.equal(res.status, 200) + t.equal(stats.torrents, 1) + t.equal(stats.activeTorrents, 1) + t.equal(stats.peersAll, 1) + t.equal(stats.peersSeederOnly, 0) + t.equal(stats.peersLeecherOnly, 1) + t.equal(stats.peersSeederAndLeecher, 0) + t.equal(stats.clients.unknown['01234567'], 1) - t.equal(res.statusCode, 200) - t.equal(stats.torrents, 1) - t.equal(stats.activeTorrents, 1) - t.equal(stats.peersAll, 1) - t.equal(stats.peersSeederOnly, 0) - t.equal(stats.peersLeecherOnly, 1) - t.equal(stats.peersSeederAndLeecher, 0) - t.equal(stats.clients.unknown['01234567'], 1) - - client.destroy(() => { t.pass('client destroyed') }) - server.close(() => { t.pass('server closed') }) - }) + client.destroy(() => { t.pass('client destroyed') }) + server.close(() => { t.pass('server closed') }) }) }) }) From e44bfe827b8ad5fe5e36785df06c0ab1ff3b2719 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 31 Oct 2023 09:53:55 +0000 Subject: [PATCH 091/119] chore(release): 11.0.0 # [11.0.0](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.12...v11.0.0) (2023-10-31) ### Features * **major:** drop simple-get ([#443](https://github.com/webtorrent/bittorrent-tracker/issues/443)) ([bce64e1](https://github.com/webtorrent/bittorrent-tracker/commit/bce64e155df6ff9fa605898cbf7498bf76188d8b)) ### BREAKING CHANGES * **major:** drop simple-get * perf: drop simple-get * feat: undici agent and socks * fix: undici as dev dependency * feat: require user passed proxy objects for http and ws * chore: include undici for tests --- AUTHORS.md | 1 + CHANGELOG.md | 22 ++++++++++++++++++++++ package.json | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index 138681d6..2892a0c7 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -63,5 +63,6 @@ - Paul Sharypov (pavloniym@gmail.com) - Cas (6506529+ThaUnknown@users.noreply.github.com) - Tom Snelling (tomsnelling8@gmail.com) +- Cas_ (6506529+ThaUnknown@users.noreply.github.com) #### Generated by tools/update-authors.sh. diff --git a/CHANGELOG.md b/CHANGELOG.md index 43224a7b..5764a224 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,25 @@ +# [11.0.0](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.12...v11.0.0) (2023-10-31) + + +### Features + +* **major:** drop simple-get ([#443](https://github.com/webtorrent/bittorrent-tracker/issues/443)) ([bce64e1](https://github.com/webtorrent/bittorrent-tracker/commit/bce64e155df6ff9fa605898cbf7498bf76188d8b)) + + +### BREAKING CHANGES + +* **major:** drop simple-get + +* perf: drop simple-get + +* feat: undici agent and socks + +* fix: undici as dev dependency + +* feat: require user passed proxy objects for http and ws + +* chore: include undici for tests + ## [10.0.12](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.11...v10.0.12) (2023-08-09) diff --git a/package.json b/package.json index 1fed807c..dca6bb02 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.12", + "version": "11.0.0", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", From d9dacc869aea4a9894f97c6fd9681332b6ee0286 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 14 Jan 2024 06:57:09 +0000 Subject: [PATCH 092/119] chore(deps): update dependency tape to v5.7.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dca6bb02..49a46e16 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "magnet-uri": "7.0.5", "semantic-release": "21.1.2", "standard": "*", - "tape": "5.7.2", + "tape": "5.7.3", "undici": "^5.27.0", "webtorrent-fixtures": "2.0.2", "wrtc": "0.4.7" From 3f59b58a020ea8c0926be135471a6666fe8e8b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ars=C3=A8ne=20Fougerouse?= Date: Tue, 16 Jan 2024 13:31:45 +0100 Subject: [PATCH 093/119] fix: update build badge url (#506) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f3b83ba..2f0d99c1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # bittorrent-tracker [![ci][ci-image]][ci-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url] -[ci-image]: https://img.shields.io/github/workflow/status/webtorrent/bittorrent-tracker/ci/master +[ci-image]: https://img.shields.io/github/actions/workflow/status/webtorrent/bittorrent-tracker/ci.yml [ci-url]: https://github.com/webtorrent/bittorrent-tracker/actions [npm-image]: https://img.shields.io/npm/v/bittorrent-tracker.svg [npm-url]: https://npmjs.org/package/bittorrent-tracker From a96ea91a6a7d2feaf07a43b53add50d962974e48 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 16 Jan 2024 12:34:36 +0000 Subject: [PATCH 094/119] chore(release): 11.0.1 ## [11.0.1](https://github.com/webtorrent/bittorrent-tracker/compare/v11.0.0...v11.0.1) (2024-01-16) ### Bug Fixes * update build badge url ([#506](https://github.com/webtorrent/bittorrent-tracker/issues/506)) ([3f59b58](https://github.com/webtorrent/bittorrent-tracker/commit/3f59b58a020ea8c0926be135471a6666fe8e8b21)) --- AUTHORS.md | 1 + CHANGELOG.md | 7 +++++++ package.json | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index 2892a0c7..d314f4df 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -64,5 +64,6 @@ - Cas (6506529+ThaUnknown@users.noreply.github.com) - Tom Snelling (tomsnelling8@gmail.com) - Cas_ (6506529+ThaUnknown@users.noreply.github.com) +- Arsène Fougerouse (arsene582@gmail.com) #### Generated by tools/update-authors.sh. diff --git a/CHANGELOG.md b/CHANGELOG.md index 5764a224..3175bee9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [11.0.1](https://github.com/webtorrent/bittorrent-tracker/compare/v11.0.0...v11.0.1) (2024-01-16) + + +### Bug Fixes + +* update build badge url ([#506](https://github.com/webtorrent/bittorrent-tracker/issues/506)) ([3f59b58](https://github.com/webtorrent/bittorrent-tracker/commit/3f59b58a020ea8c0926be135471a6666fe8e8b21)) + # [11.0.0](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.12...v11.0.0) (2023-10-31) diff --git a/package.json b/package.json index 49a46e16..120195ee 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bittorrent-tracker", "description": "Simple, robust, BitTorrent tracker (client & server) implementation", - "version": "11.0.0", + "version": "11.0.1", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", From 5e2f59be629be0dec17e1278160875eb308f19fc Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 26 Jan 2024 06:46:09 +0000 Subject: [PATCH 095/119] chore(deps): update dependency tape to v5.7.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 120195ee..8b3fde75 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "magnet-uri": "7.0.5", "semantic-release": "21.1.2", "standard": "*", - "tape": "5.7.3", + "tape": "5.7.4", "undici": "^5.27.0", "webtorrent-fixtures": "2.0.2", "wrtc": "0.4.7" From ea1e78e1ded1d4a6e7bab9210a593a88fcff50ed Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 15 Feb 2024 22:47:54 +0000 Subject: [PATCH 096/119] chore(deps): update dependency tape to v5.7.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8b3fde75..1e9d4cc5 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "magnet-uri": "7.0.5", "semantic-release": "21.1.2", "standard": "*", - "tape": "5.7.4", + "tape": "5.7.5", "undici": "^5.27.0", "webtorrent-fixtures": "2.0.2", "wrtc": "0.4.7" From fe75272d51653e626583689081afb0b7aeadb84f Mon Sep 17 00:00:00 2001 From: Brad Marsden Date: Tue, 12 Mar 2024 17:40:46 +0000 Subject: [PATCH 097/119] fix(parse-http): ignore announcements from peers with invalid announcement ports. (#513) --- lib/server/parse-http.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/parse-http.js b/lib/server/parse-http.js index a6ba6a56..97b46e30 100644 --- a/lib/server/parse-http.js +++ b/lib/server/parse-http.js @@ -22,7 +22,7 @@ export default function (req, opts) { params.peer_id = bin2hex(params.peer_id) params.port = Number(params.port) - if (!params.port) throw new Error('invalid port') + if (!params.port || params.port <= 0 || params.port > 65535) throw new Error('invalid port') params.left = Number(params.left) if (Number.isNaN(params.left)) params.left = Infinity From a4f956e3cbc2534fb92bb9a8841cccb5224130e1 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 12 Mar 2024 17:43:38 +0000 Subject: [PATCH 098/119] chore(release): 11.0.2 ## [11.0.2](https://github.com/webtorrent/bittorrent-tracker/compare/v11.0.1...v11.0.2) (2024-03-12) ### Bug Fixes * **parse-http:** ignore announcements from peers with invalid announcement ports. ([#513](https://github.com/webtorrent/bittorrent-tracker/issues/513)) ([fe75272](https://github.com/webtorrent/bittorrent-tracker/commit/fe75272d51653e626583689081afb0b7aeadb84f)) --- AUTHORS.md | 1 + CHANGELOG.md | 7 +++++++ package.json | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index d314f4df..abe53c94 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -65,5 +65,6 @@ - Tom Snelling (tomsnelling8@gmail.com) - Cas_ (6506529+ThaUnknown@users.noreply.github.com) - Arsène Fougerouse (arsene582@gmail.com) +- Brad Marsden (silentbot1@gmail.com) #### Generated by tools/update-authors.sh. diff --git a/CHANGELOG.md b/CHANGELOG.md index 3175bee9..6db84216 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [11.0.2](https://github.com/webtorrent/bittorrent-tracker/compare/v11.0.1...v11.0.2) (2024-03-12) + + +### Bug Fixes + +* **parse-http:** ignore announcements from peers with invalid announcement ports. ([#513](https://github.com/webtorrent/bittorrent-tracker/issues/513)) ([fe75272](https://github.com/webtorrent/bittorrent-tracker/commit/fe75272d51653e626583689081afb0b7aeadb84f)) + ## [11.0.1](https://github.com/webtorrent/bittorrent-tracker/compare/v11.0.0...v11.0.1) (2024-01-16) diff --git a/package.json b/package.json index 1e9d4cc5..f04ef3dc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bittorrent-tracker", "description": "Simple, robust, BitTorrent tracker (client & server) implementation", - "version": "11.0.1", + "version": "11.0.2", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", From f6a7993e8411ebeef75a7a74386d18e3f35be77d Mon Sep 17 00:00:00 2001 From: krazak Date: Thu, 11 Apr 2024 15:19:03 -0700 Subject: [PATCH 099/119] Add event timestamp (#516) --- bin/cmd.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/bin/cmd.js b/bin/cmd.js index fb7e0653..c57eef55 100755 --- a/bin/cmd.js +++ b/bin/cmd.js @@ -86,22 +86,22 @@ const server = new Server({ }) server.on('error', err => { - if (!argv.silent) console.error(`ERROR: ${err.message}`) + if (!argv.silent) console.error(`${new Date().toISOString()} ERROR: ${err.message}`) }) server.on('warning', err => { - if (!argv.quiet) console.log(`WARNING: ${err.message}`) + if (!argv.quiet) console.log(`${new Date().toISOString()} WARNING: ${err.message}`) }) server.on('update', addr => { - if (!argv.quiet) console.log(`update: ${addr}`) + if (!argv.quiet) console.log(`${new Date().toISOString()} update: ${addr}`) }) server.on('complete', addr => { - if (!argv.quiet) console.log(`complete: ${addr}`) + if (!argv.quiet) console.log(`${new Date().toISOString()} complete: ${addr}`) }) server.on('start', addr => { - if (!argv.quiet) console.log(`start: ${addr}`) + if (!argv.quiet) console.log(`${new Date().toISOString()} start: ${addr}`) }) server.on('stop', addr => { - if (!argv.quiet) console.log(`stop: ${addr}`) + if (!argv.quiet) console.log(`${new Date().toISOString()} stop: ${addr}`) }) const hostname = { @@ -115,30 +115,30 @@ server.listen(argv.port, hostname, () => { const httpAddr = server.http.address() const httpHost = httpAddr.address !== '::' ? httpAddr.address : 'localhost' const httpPort = httpAddr.port - console.log(`HTTP tracker: http://${httpHost}:${httpPort}/announce`) + console.log(`${new Date().toISOString()} HTTP tracker: http://${httpHost}:${httpPort}/announce`) } if (server.udp && !argv.quiet) { const udpAddr = server.udp.address() const udpHost = udpAddr.address const udpPort = udpAddr.port - console.log(`UDP tracker: udp://${udpHost}:${udpPort}`) + console.log(`${new Date().toISOString()} UDP tracker: udp://${udpHost}:${udpPort}`) } if (server.udp6 && !argv.quiet) { const udp6Addr = server.udp6.address() const udp6Host = udp6Addr.address !== '::' ? udp6Addr.address : 'localhost' const udp6Port = udp6Addr.port - console.log(`UDP6 tracker: udp://${udp6Host}:${udp6Port}`) + console.log(`${new Date().toISOString()} UDP6 tracker: udp://${udp6Host}:${udp6Port}`) } if (server.ws && !argv.quiet) { const wsAddr = server.http.address() const wsHost = wsAddr.address !== '::' ? wsAddr.address : 'localhost' const wsPort = wsAddr.port - console.log(`WebSocket tracker: ws://${wsHost}:${wsPort}`) + console.log(`${new Date().toISOString()} WebSocket tracker: ws://${wsHost}:${wsPort}`) } if (server.http && argv.stats && !argv.quiet) { const statsAddr = server.http.address() const statsHost = statsAddr.address !== '::' ? statsAddr.address : 'localhost' const statsPort = statsAddr.port - console.log(`Tracker stats: http://${statsHost}:${statsPort}/stats`) + console.log(`${new Date().toISOString()} Tracker stats: http://${statsHost}:${statsPort}/stats`) } }) From 633d68a32c2c143fec0182317a9801dd1b64faef Mon Sep 17 00:00:00 2001 From: Cas_ <6506529+ThaUnknown@users.noreply.github.com> Date: Wed, 22 May 2024 23:51:48 +0200 Subject: [PATCH 100/119] feat: updated webrtc implementation (#519) * feat: update webrtc implementation * chore: update deps --- package.json | 37 ++++++++++++++++++------------------- test/evict.js | 2 +- test/server.js | 2 +- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index f04ef3dc..809488d9 100644 --- a/package.json +++ b/package.json @@ -27,42 +27,41 @@ }, "type": "module", "dependencies": { - "@thaunknown/simple-peer": "^9.12.1", - "@thaunknown/simple-websocket": "^9.1.0", + "@thaunknown/simple-peer": "^10.0.6", + "@thaunknown/simple-websocket": "^9.1.1", "bencode": "^4.0.0", - "bittorrent-peerid": "^1.3.3", + "bittorrent-peerid": "^1.3.6", "chrome-dgram": "^3.0.6", - "clone": "^2.0.0", + "clone": "^2.1.2", "compact2string": "^1.4.1", - "cross-fetch-ponyfill": "^1.0.1", - "debug": "^4.1.1", - "ip": "^1.1.5", + "cross-fetch-ponyfill": "^1.0.3", + "debug": "^4.3.4", + "ip": "^2.0.1", "lru": "^3.1.0", - "minimist": "^1.2.5", + "minimist": "^1.2.8", "once": "^1.4.0", "queue-microtask": "^1.2.3", "random-iterate": "^1.0.1", "run-parallel": "^1.2.0", "run-series": "^1.1.9", - "socks": "^2.0.0", - "string2compact": "^2.0.0", - "uint8-util": "^2.1.9", + "socks": "^2.8.3", + "string2compact": "^2.0.1", + "uint8-util": "^2.2.5", "unordered-array-remove": "^1.0.2", - "ws": "^8.0.0" + "ws": "^8.17.0" }, "devDependencies": { "@mapbox/node-pre-gyp": "1.0.11", "@webtorrent/semantic-release-config": "1.0.10", "magnet-uri": "7.0.5", - "semantic-release": "21.1.2", "standard": "*", "tape": "5.7.5", - "undici": "^5.27.0", - "webtorrent-fixtures": "2.0.2", - "wrtc": "0.4.7" + "undici": "^6.16.1", + "webrtc-polyfill": "^1.1.5", + "webtorrent-fixtures": "2.0.2" }, "engines": { - "node": ">=12.20.0" + "node": ">=16.0.0" }, "exports": { "import": "./index.js" @@ -80,8 +79,8 @@ "license": "MIT", "main": "index.js", "optionalDependencies": { - "bufferutil": "^4.0.3", - "utf-8-validate": "^5.0.5" + "bufferutil": "^4.0.8", + "utf-8-validate": "^6.0.4" }, "repository": { "type": "git", diff --git a/test/evict.js b/test/evict.js index 76967fd3..385fae2a 100644 --- a/test/evict.js +++ b/test/evict.js @@ -1,7 +1,7 @@ import Client from '../index.js' import common from './common.js' import test from 'tape' -import wrtc from 'wrtc' +import wrtc from 'webrtc-polyfill' const infoHash = '4cb67059ed6bd08362da625b3ae77f6f4a075705' const peerId = Buffer.from('01234567890123456789') diff --git a/test/server.js b/test/server.js index cb1095e1..d4cf493e 100644 --- a/test/server.js +++ b/test/server.js @@ -1,7 +1,7 @@ import Client from '../index.js' import common from './common.js' import test from 'tape' -import wrtc from 'wrtc' +import wrtc from 'webrtc-polyfill' const infoHash = '4cb67059ed6bd08362da625b3ae77f6f4a075705' const peerId = Buffer.from('01234567890123456789') From 428fb224f5666731332738032649f4448b2e1e4f Mon Sep 17 00:00:00 2001 From: Cas_ <6506529+ThaUnknown@users.noreply.github.com> Date: Wed, 22 May 2024 23:55:47 +0200 Subject: [PATCH 101/119] fix: semantic release (#520) --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 809488d9..f97e3217 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "@mapbox/node-pre-gyp": "1.0.11", "@webtorrent/semantic-release-config": "1.0.10", "magnet-uri": "7.0.5", + "semantic-release": "21.1.2", "standard": "*", "tape": "5.7.5", "undici": "^6.16.1", From 683fca88d69d9410d6608d0807fa45c3dc4caeb0 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 22 May 2024 21:58:44 +0000 Subject: [PATCH 102/119] chore(release): 11.1.0 # [11.1.0](https://github.com/webtorrent/bittorrent-tracker/compare/v11.0.2...v11.1.0) (2024-05-22) ### Bug Fixes * semantic release ([#520](https://github.com/webtorrent/bittorrent-tracker/issues/520)) ([428fb22](https://github.com/webtorrent/bittorrent-tracker/commit/428fb224f5666731332738032649f4448b2e1e4f)) ### Features * updated webrtc implementation ([#519](https://github.com/webtorrent/bittorrent-tracker/issues/519)) ([633d68a](https://github.com/webtorrent/bittorrent-tracker/commit/633d68a32c2c143fec0182317a9801dd1b64faef)) --- AUTHORS.md | 1 + CHANGELOG.md | 12 ++++++++++++ package.json | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index abe53c94..86740739 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -66,5 +66,6 @@ - Cas_ (6506529+ThaUnknown@users.noreply.github.com) - Arsène Fougerouse (arsene582@gmail.com) - Brad Marsden (silentbot1@gmail.com) +- krazak (krazak@vt.edu) #### Generated by tools/update-authors.sh. diff --git a/CHANGELOG.md b/CHANGELOG.md index 6db84216..02410224 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +# [11.1.0](https://github.com/webtorrent/bittorrent-tracker/compare/v11.0.2...v11.1.0) (2024-05-22) + + +### Bug Fixes + +* semantic release ([#520](https://github.com/webtorrent/bittorrent-tracker/issues/520)) ([428fb22](https://github.com/webtorrent/bittorrent-tracker/commit/428fb224f5666731332738032649f4448b2e1e4f)) + + +### Features + +* updated webrtc implementation ([#519](https://github.com/webtorrent/bittorrent-tracker/issues/519)) ([633d68a](https://github.com/webtorrent/bittorrent-tracker/commit/633d68a32c2c143fec0182317a9801dd1b64faef)) + ## [11.0.2](https://github.com/webtorrent/bittorrent-tracker/compare/v11.0.1...v11.0.2) (2024-03-12) diff --git a/package.json b/package.json index f97e3217..a190be68 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bittorrent-tracker", "description": "Simple, robust, BitTorrent tracker (client & server) implementation", - "version": "11.0.2", + "version": "11.1.0", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", From ed57d0c78a2fa6292fd4b04e650502fbc3a0da23 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 16 Jun 2024 03:02:54 +0000 Subject: [PATCH 103/119] chore(deps): update dependency tape to v5.8.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a190be68..d853ba3d 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "magnet-uri": "7.0.5", "semantic-release": "21.1.2", "standard": "*", - "tape": "5.7.5", + "tape": "5.8.0", "undici": "^6.16.1", "webrtc-polyfill": "^1.1.5", "webtorrent-fixtures": "2.0.2" From b21a6a5d0aa27014656b0490b4e34c94d045f87c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 19:31:22 +0000 Subject: [PATCH 104/119] chore(deps): update dependency tape to v5.8.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d853ba3d..6d419276 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "magnet-uri": "7.0.5", "semantic-release": "21.1.2", "standard": "*", - "tape": "5.8.0", + "tape": "5.8.1", "undici": "^6.16.1", "webrtc-polyfill": "^1.1.5", "webtorrent-fixtures": "2.0.2" From 83a24ce77fb1a96b7fe4c383ce92d7c28fc165a7 Mon Sep 17 00:00:00 2001 From: Cas_ <6506529+ThaUnknown@users.noreply.github.com> Date: Mon, 1 Jul 2024 19:23:38 +0200 Subject: [PATCH 105/119] perf: drop clone (#523) --- lib/client/udp-tracker.js | 4 +++- package.json | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/client/udp-tracker.js b/lib/client/udp-tracker.js index 3a3ad42a..b4ac4bdb 100644 --- a/lib/client/udp-tracker.js +++ b/lib/client/udp-tracker.js @@ -1,5 +1,4 @@ import arrayRemove from 'unordered-array-remove' -import clone from 'clone' import Debug from 'debug' import dgram from 'dgram' import Socks from 'socks' @@ -11,6 +10,9 @@ import compact2string from 'compact2string' const debug = Debug('bittorrent-tracker:udp-tracker') +// this was done some many years ago to fix "prevent Socks instances concurrency", and used some bloated package, no clue if it's needed, but this is simpler, #356 +const clone = obj => JSON.parse(JSON.stringify(obj)) + /** * UDP torrent tracker client (for an individual tracker) * diff --git a/package.json b/package.json index 6d419276..77be4b5e 100644 --- a/package.json +++ b/package.json @@ -27,12 +27,11 @@ }, "type": "module", "dependencies": { - "@thaunknown/simple-peer": "^10.0.6", - "@thaunknown/simple-websocket": "^9.1.1", + "@thaunknown/simple-peer": "^10.0.8", + "@thaunknown/simple-websocket": "^9.1.3", "bencode": "^4.0.0", "bittorrent-peerid": "^1.3.6", "chrome-dgram": "^3.0.6", - "clone": "^2.1.2", "compact2string": "^1.4.1", "cross-fetch-ponyfill": "^1.0.3", "debug": "^4.3.4", From 6a6280a03ce77b123df84f20f0f8b1172d8c193e Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 1 Jul 2024 17:27:05 +0000 Subject: [PATCH 106/119] chore(release): 11.1.1 ## [11.1.1](https://github.com/webtorrent/bittorrent-tracker/compare/v11.1.0...v11.1.1) (2024-07-01) ### Performance Improvements * drop clone ([#523](https://github.com/webtorrent/bittorrent-tracker/issues/523)) ([83a24ce](https://github.com/webtorrent/bittorrent-tracker/commit/83a24ce77fb1a96b7fe4c383ce92d7c28fc165a7)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02410224..0f7e29d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [11.1.1](https://github.com/webtorrent/bittorrent-tracker/compare/v11.1.0...v11.1.1) (2024-07-01) + + +### Performance Improvements + +* drop clone ([#523](https://github.com/webtorrent/bittorrent-tracker/issues/523)) ([83a24ce](https://github.com/webtorrent/bittorrent-tracker/commit/83a24ce77fb1a96b7fe4c383ce92d7c28fc165a7)) + # [11.1.0](https://github.com/webtorrent/bittorrent-tracker/compare/v11.0.2...v11.1.0) (2024-05-22) diff --git a/package.json b/package.json index 77be4b5e..71e0fb3d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bittorrent-tracker", "description": "Simple, robust, BitTorrent tracker (client & server) implementation", - "version": "11.1.0", + "version": "11.1.1", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", From e9d8f8cd754ba26d86f32f9b8da0c0c4a3dcd646 Mon Sep 17 00:00:00 2001 From: Cas_ <6506529+ThaUnknown@users.noreply.github.com> Date: Tue, 13 Aug 2024 23:38:01 +0200 Subject: [PATCH 107/119] fix: statuscode (#526) --- lib/client/http-tracker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/http-tracker.js b/lib/client/http-tracker.js index 6297d2e2..a31fb604 100644 --- a/lib/client/http-tracker.js +++ b/lib/client/http-tracker.js @@ -158,7 +158,7 @@ class HTTPTracker extends Tracker { if (this.destroyed) return if (res.status !== 200) { - return cb(new Error(`Non-200 response code ${res.statusCode} from ${this.announceUrl}`)) + return cb(new Error(`Non-200 response code ${res.status} from ${this.announceUrl}`)) } if (!data || data.length === 0) { return cb(new Error(`Invalid tracker response from${this.announceUrl}`)) From fd5ea54559e52b9c94e6f5dfd4ea3dc2bc8ef45b Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 13 Aug 2024 21:40:59 +0000 Subject: [PATCH 108/119] chore(release): 11.1.2 ## [11.1.2](https://github.com/webtorrent/bittorrent-tracker/compare/v11.1.1...v11.1.2) (2024-08-13) ### Bug Fixes * statuscode ([#526](https://github.com/webtorrent/bittorrent-tracker/issues/526)) ([e9d8f8c](https://github.com/webtorrent/bittorrent-tracker/commit/e9d8f8cd754ba26d86f32f9b8da0c0c4a3dcd646)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f7e29d3..8992459f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [11.1.2](https://github.com/webtorrent/bittorrent-tracker/compare/v11.1.1...v11.1.2) (2024-08-13) + + +### Bug Fixes + +* statuscode ([#526](https://github.com/webtorrent/bittorrent-tracker/issues/526)) ([e9d8f8c](https://github.com/webtorrent/bittorrent-tracker/commit/e9d8f8cd754ba26d86f32f9b8da0c0c4a3dcd646)) + ## [11.1.1](https://github.com/webtorrent/bittorrent-tracker/compare/v11.1.0...v11.1.1) (2024-07-01) diff --git a/package.json b/package.json index 71e0fb3d..2906140c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bittorrent-tracker", "description": "Simple, robust, BitTorrent tracker (client & server) implementation", - "version": "11.1.1", + "version": "11.1.2", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", From 8b02864b510cd1082179dc88315a0a33c2097e7d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 17 Sep 2024 01:30:41 +0000 Subject: [PATCH 109/119] chore(deps): update dependency tape to v5.9.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2906140c..982272d3 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "magnet-uri": "7.0.5", "semantic-release": "21.1.2", "standard": "*", - "tape": "5.8.1", + "tape": "5.9.0", "undici": "^6.16.1", "webrtc-polyfill": "^1.1.5", "webtorrent-fixtures": "2.0.2" From f2f4990501f918bf6ab0106a03f9c7a1d0d1bbc8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 7 Nov 2024 19:00:51 +0100 Subject: [PATCH 110/119] Add subpath import for client and server (#535) --- README.md | 3 +++ package.json | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2f0d99c1..db0eba16 100644 --- a/README.md +++ b/README.md @@ -160,6 +160,7 @@ To start a BitTorrent tracker server to track swarms of peers: ```js import { Server } from 'bittorrent-tracker' +// Or import Server from 'bittorrent-tracker/server' const server = new Server({ udp: true, // enable udp server? [default=true] @@ -267,6 +268,8 @@ Scraping multiple torrent info is possible with a static `Client.scrape` method: ```js import Client from 'bittorrent-tracker' +// Or import Client from 'bittorrent-tracker/client' + Client.scrape({ announce: announceUrl, infoHash: [ infoHash1, infoHash2 ]}, function (err, results) { results[infoHash1].announce results[infoHash1].infoHash diff --git a/package.json b/package.json index 982272d3..8984180a 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,15 @@ "node": ">=16.0.0" }, "exports": { - "import": "./index.js" + ".": { + "import": "./index.js" + }, + "./client": { + "import": "./client.js" + }, + "./server": { + "import": "./server.js" + } }, "keywords": [ "bittorrent", From e45516d73a1ca546f7eeaf75d93e9b32ca3ca00f Mon Sep 17 00:00:00 2001 From: uriva Date: Fri, 29 Nov 2024 11:53:40 +0200 Subject: [PATCH 111/119] Bugfix - when using AbortController, errors on resulting stream must be caught (#539) * use-native-fetch * Bugfix: `res.body` should handle errors according to https://github.com/nodejs/undici/issues/3353#issuecomment-2184635954 * Revert "use-native-fetch" This reverts commit d65460319ea116fb28defc677af878cec42e8d43. * fix-quotes * some-build-targets-return-different-output --- lib/client/http-tracker.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/client/http-tracker.js b/lib/client/http-tracker.js index a31fb604..678f7a26 100644 --- a/lib/client/http-tracker.js +++ b/lib/client/http-tracker.js @@ -150,6 +150,7 @@ class HTTPTracker extends Tracker { 'user-agent': this.client._userAgent || '' } }) + if (res.body.on) res.body.on('error', cb) } catch (err) { if (err) return cb(err) } From 7c963a6f5e7664d7d12d44ca5bac61b910e7bd8f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 28 Dec 2024 12:45:50 +0000 Subject: [PATCH 112/119] chore(deps): update actions/cache action to v4 (#543) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 037e5acf..61c6902c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: with: node-version: 18 - name: Cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.npm key: ${{ runner.os }}-npm-${{ hashFiles('**/package.json') }} From e7de90c0cbcfb41c9c53c5caf69cc37c6d3ef1e8 Mon Sep 17 00:00:00 2001 From: Brad Marsden Date: Sat, 28 Dec 2024 13:16:20 +0000 Subject: [PATCH 113/119] feat: release #539 and #535 (#544) From 980919508807d76c52a7236ea90c94e25f9d5d8b Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Sat, 28 Dec 2024 13:19:22 +0000 Subject: [PATCH 114/119] chore(release): 11.2.0 # [11.2.0](https://github.com/webtorrent/bittorrent-tracker/compare/v11.1.2...v11.2.0) (2024-12-28) ### Features * release [#539](https://github.com/webtorrent/bittorrent-tracker/issues/539) and [#535](https://github.com/webtorrent/bittorrent-tracker/issues/535) ([#544](https://github.com/webtorrent/bittorrent-tracker/issues/544)) ([e7de90c](https://github.com/webtorrent/bittorrent-tracker/commit/e7de90c0cbcfb41c9c53c5caf69cc37c6d3ef1e8)) --- AUTHORS.md | 2 ++ CHANGELOG.md | 7 +++++++ package.json | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index 86740739..50d9f2f4 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -67,5 +67,7 @@ - Arsène Fougerouse (arsene582@gmail.com) - Brad Marsden (silentbot1@gmail.com) - krazak (krazak@vt.edu) +- Chocobozzz (chocobozzz@cpy.re) +- uriva (uriva@users.noreply.github.com) #### Generated by tools/update-authors.sh. diff --git a/CHANGELOG.md b/CHANGELOG.md index 8992459f..84c04d73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [11.2.0](https://github.com/webtorrent/bittorrent-tracker/compare/v11.1.2...v11.2.0) (2024-12-28) + + +### Features + +* release [#539](https://github.com/webtorrent/bittorrent-tracker/issues/539) and [#535](https://github.com/webtorrent/bittorrent-tracker/issues/535) ([#544](https://github.com/webtorrent/bittorrent-tracker/issues/544)) ([e7de90c](https://github.com/webtorrent/bittorrent-tracker/commit/e7de90c0cbcfb41c9c53c5caf69cc37c6d3ef1e8)) + ## [11.1.2](https://github.com/webtorrent/bittorrent-tracker/compare/v11.1.1...v11.1.2) (2024-08-13) diff --git a/package.json b/package.json index 8984180a..4cb56fcd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bittorrent-tracker", "description": "Simple, robust, BitTorrent tracker (client & server) implementation", - "version": "11.1.2", + "version": "11.2.0", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", From 934dc1bafc440146e3522eb39402cca222a102cb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 4 Jan 2025 16:46:56 +0000 Subject: [PATCH 115/119] chore(deps): update dependency magnet-uri to v7.0.7 (#545) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4cb56fcd..071d7730 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "devDependencies": { "@mapbox/node-pre-gyp": "1.0.11", "@webtorrent/semantic-release-config": "1.0.10", - "magnet-uri": "7.0.5", + "magnet-uri": "7.0.7", "semantic-release": "21.1.2", "standard": "*", "tape": "5.9.0", From 3cd77f3e6f5b52f5d58adaf004b333cd2061a4da Mon Sep 17 00:00:00 2001 From: Cas_ <6506529+ThaUnknown@users.noreply.github.com> Date: Sun, 19 Jan 2025 23:33:16 +0100 Subject: [PATCH 116/119] fix: http announce no left (#548) * fix: http announce no left * fix: proper left check --- lib/client/http-tracker.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/client/http-tracker.js b/lib/client/http-tracker.js index 678f7a26..43464e8e 100644 --- a/lib/client/http-tracker.js +++ b/lib/client/http-tracker.js @@ -55,6 +55,8 @@ class HTTPTracker extends Tracker { peer_id: this.client._peerIdBinary, port: this.client._port }) + + if (params.left !== 0 && !params.left) params.left = 16384 if (this._trackerId) params.trackerid = this._trackerId this._request(this.announceUrl, params, (err, data) => { From b4557a7f65635f6ae8100828d51f257ed1a6d0b6 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Sun, 19 Jan 2025 22:36:07 +0000 Subject: [PATCH 117/119] chore(release): 11.2.1 ## [11.2.1](https://github.com/webtorrent/bittorrent-tracker/compare/v11.2.0...v11.2.1) (2025-01-19) ### Bug Fixes * http announce no left ([#548](https://github.com/webtorrent/bittorrent-tracker/issues/548)) ([3cd77f3](https://github.com/webtorrent/bittorrent-tracker/commit/3cd77f3e6f5b52f5d58adaf004b333cd2061a4da)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84c04d73..7f21349d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [11.2.1](https://github.com/webtorrent/bittorrent-tracker/compare/v11.2.0...v11.2.1) (2025-01-19) + + +### Bug Fixes + +* http announce no left ([#548](https://github.com/webtorrent/bittorrent-tracker/issues/548)) ([3cd77f3](https://github.com/webtorrent/bittorrent-tracker/commit/3cd77f3e6f5b52f5d58adaf004b333cd2061a4da)) + # [11.2.0](https://github.com/webtorrent/bittorrent-tracker/compare/v11.1.2...v11.2.0) (2024-12-28) diff --git a/package.json b/package.json index 071d7730..1593e197 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bittorrent-tracker", "description": "Simple, robust, BitTorrent tracker (client & server) implementation", - "version": "11.2.0", + "version": "11.2.1", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io", From 15715518decfed77d7888ba21d6ab592fa91cc85 Mon Sep 17 00:00:00 2001 From: Subin Siby Date: Sat, 6 Sep 2025 17:55:35 +0530 Subject: [PATCH 118/119] fix: export WebSocketTracker (#558) --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 1593e197..f0166623 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,9 @@ }, "./server": { "import": "./server.js" + }, + "./websocket-tracker": { + "import": "./lib/client/websocket-tracker.js" } }, "keywords": [ From 295c69ab61719a61952a342b04390abfa9e9ac08 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Sat, 6 Sep 2025 12:28:37 +0000 Subject: [PATCH 119/119] chore(release): 11.2.2 ## [11.2.2](https://github.com/webtorrent/bittorrent-tracker/compare/v11.2.1...v11.2.2) (2025-09-06) ### Bug Fixes * export WebSocketTracker ([#558](https://github.com/webtorrent/bittorrent-tracker/issues/558)) ([1571551](https://github.com/webtorrent/bittorrent-tracker/commit/15715518decfed77d7888ba21d6ab592fa91cc85)) --- AUTHORS.md | 1 + CHANGELOG.md | 7 +++++++ package.json | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index 50d9f2f4..3b930ae6 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -69,5 +69,6 @@ - krazak (krazak@vt.edu) - Chocobozzz (chocobozzz@cpy.re) - uriva (uriva@users.noreply.github.com) +- Subin Siby (mail@subinsb.com) #### Generated by tools/update-authors.sh. diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f21349d..6b00b4dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [11.2.2](https://github.com/webtorrent/bittorrent-tracker/compare/v11.2.1...v11.2.2) (2025-09-06) + + +### Bug Fixes + +* export WebSocketTracker ([#558](https://github.com/webtorrent/bittorrent-tracker/issues/558)) ([1571551](https://github.com/webtorrent/bittorrent-tracker/commit/15715518decfed77d7888ba21d6ab592fa91cc85)) + ## [11.2.1](https://github.com/webtorrent/bittorrent-tracker/compare/v11.2.0...v11.2.1) (2025-01-19) diff --git a/package.json b/package.json index f0166623..ca9cebd6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bittorrent-tracker", "description": "Simple, robust, BitTorrent tracker (client & server) implementation", - "version": "11.2.1", + "version": "11.2.2", "author": { "name": "WebTorrent LLC", "email": "feross@webtorrent.io",