Skip to content

Commit 33ff67d

Browse files
authored
Merge branch 'webtorrent:master' into master
2 parents 8249db5 + ad00e13 commit 33ff67d

34 files changed

+451
-287
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
os:
1313
- ubuntu-latest
1414
node:
15-
- '14'
15+
- '18'
1616
steps:
1717
- uses: actions/checkout@v3
1818
- uses: actions/setup-node@v3

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
- name: Setup Node.js
1818
uses: actions/setup-node@v3
1919
with:
20-
node-version: 14
20+
node-version: 18
2121
- name: Cache
22-
uses: actions/cache@v2
22+
uses: actions/cache@v3
2323
with:
2424
path: ~/.npm
2525
key: ${{ runner.os }}-npm-${{ hashFiles('**/package.json') }}

.github/workflows/stale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
pull-requests: write
1313

1414
steps:
15-
- uses: actions/stale@v5
15+
- uses: actions/stale@v8
1616
with:
1717
repo-token: ${{ secrets.GITHUB_TOKEN }}
1818
stale-issue-message: 'Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?'

AUTHORS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,9 @@
5959
- Jocelyn Liu ([email protected])
6060
- Bruce Hopkins ([email protected])
6161
- Ryan Finnie ([email protected])
62+
63+
- Paul Sharypov ([email protected])
64+
65+
- Tom Snelling ([email protected])
6266

6367
#### Generated by tools/update-authors.sh.

CHANGELOG.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,125 @@
1+
## [10.0.12](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.11...v10.0.12) (2023-08-09)
2+
3+
4+
### Bug Fixes
5+
6+
* **deps:** update dependency bencode to v4 ([#487](https://github.com/webtorrent/bittorrent-tracker/issues/487)) ([aeccf9c](https://github.com/webtorrent/bittorrent-tracker/commit/aeccf9c1c4b9115fd23b4fe1a0ab990b5add0f17))
7+
8+
## [10.0.11](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.10...v10.0.11) (2023-08-01)
9+
10+
11+
### Bug Fixes
12+
13+
* mangled scrape infohashes ([#486](https://github.com/webtorrent/bittorrent-tracker/issues/486)) ([11cce83](https://github.com/webtorrent/bittorrent-tracker/commit/11cce83ddd858813f5684da8a116de4bee6e518b))
14+
15+
## [10.0.10](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.9...v10.0.10) (2023-06-16)
16+
17+
18+
### Performance Improvements
19+
20+
* use simple-peer/lite ([#475](https://github.com/webtorrent/bittorrent-tracker/issues/475)) ([5b8db06](https://github.com/webtorrent/bittorrent-tracker/commit/5b8db067e48cc81796728ff538d7ff6efafc59b8))
21+
22+
## [10.0.9](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.8...v10.0.9) (2023-06-16)
23+
24+
25+
### Performance Improvements
26+
27+
* use peer/lite ([#474](https://github.com/webtorrent/bittorrent-tracker/issues/474)) ([7c845f0](https://github.com/webtorrent/bittorrent-tracker/commit/7c845f030d07b1bf7060ab880b790ee85a8c7ac0))
28+
29+
## [10.0.8](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.7...v10.0.8) (2023-06-07)
30+
31+
32+
### Bug Fixes
33+
34+
* bigInt ([#472](https://github.com/webtorrent/bittorrent-tracker/issues/472)) ([d7061f7](https://github.com/webtorrent/bittorrent-tracker/commit/d7061f73b2ebff072e064971a5960749a7335bae))
35+
36+
## [10.0.7](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.6...v10.0.7) (2023-06-05)
37+
38+
39+
### Bug Fixes
40+
41+
* imports ([#471](https://github.com/webtorrent/bittorrent-tracker/issues/471)) ([a12022a](https://github.com/webtorrent/bittorrent-tracker/commit/a12022ac2c81d7fa3ecb81163852161e64199cf4))
42+
43+
## [10.0.6](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.5...v10.0.6) (2023-05-27)
44+
45+
46+
### Bug Fixes
47+
48+
* replace simple-peer with maintained one ([#466](https://github.com/webtorrent/bittorrent-tracker/issues/466)) ([3b2dedb](https://github.com/webtorrent/bittorrent-tracker/commit/3b2dedb4151615831ca12d3d0a830354b1c04e68))
49+
50+
## [10.0.5](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.4...v10.0.5) (2023-05-27)
51+
52+
53+
### Bug Fixes
54+
55+
* only stringify views ([#467](https://github.com/webtorrent/bittorrent-tracker/issues/467)) ([52f5502](https://github.com/webtorrent/bittorrent-tracker/commit/52f55020f38894e4d45e12c87184540d8b0acad3))
56+
57+
## [10.0.4](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.3...v10.0.4) (2023-05-26)
58+
59+
60+
### Bug Fixes
61+
62+
* drop buffer ([#465](https://github.com/webtorrent/bittorrent-tracker/issues/465)) ([c99eb89](https://github.com/webtorrent/bittorrent-tracker/commit/c99eb892088ef3c67ea5bf014dfdd86799251a7e))
63+
64+
## [10.0.3](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.2...v10.0.3) (2023-05-25)
65+
66+
67+
### Performance Improvements
68+
69+
* replace simple websocket with maintained one ([#464](https://github.com/webtorrent/bittorrent-tracker/issues/464)) ([3f01c29](https://github.com/webtorrent/bittorrent-tracker/commit/3f01c29122efd726d805673da82f43ce5592b793))
70+
71+
## [10.0.2](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.1...v10.0.2) (2023-02-01)
72+
73+
74+
### Bug Fixes
75+
76+
* **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)
77+
78+
## [10.0.1](https://github.com/webtorrent/bittorrent-tracker/compare/v10.0.0...v10.0.1) (2022-12-07)
79+
80+
81+
### Bug Fixes
82+
83+
* **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))
84+
* **deps:** update dependency string2compact to v2 ([#437](https://github.com/webtorrent/bittorrent-tracker/issues/437)) ([9be843c](https://github.com/webtorrent/bittorrent-tracker/commit/9be843c5e46ac2ab518187bf0d348e1e69e8633d))
85+
86+
# [10.0.0](https://github.com/webtorrent/bittorrent-tracker/compare/v9.19.0...v10.0.0) (2022-12-05)
87+
88+
89+
### Features
90+
91+
* esm ([#431](https://github.com/webtorrent/bittorrent-tracker/issues/431)) ([e6d3189](https://github.com/webtorrent/bittorrent-tracker/commit/e6d3189edf1a170197a799b97d84c632692b394f))
92+
93+
94+
### BREAKING CHANGES
95+
96+
* ESM only
97+
98+
* feat: esm
99+
100+
* fix: linter oops
101+
102+
# [9.19.0](https://github.com/webtorrent/bittorrent-tracker/compare/v9.18.6...v9.19.0) (2022-06-01)
103+
104+
105+
### Features
106+
107+
* **events:** Support of `paused` client event ([#411](https://github.com/webtorrent/bittorrent-tracker/issues/411)) ([ef76b3f](https://github.com/webtorrent/bittorrent-tracker/commit/ef76b3f3b6beee87f57d74addd0ca2ef2c517b6d))
108+
109+
## [9.18.6](https://github.com/webtorrent/bittorrent-tracker/compare/v9.18.5...v9.18.6) (2022-05-11)
110+
111+
112+
### Bug Fixes
113+
114+
* revert [#420](https://github.com/webtorrent/bittorrent-tracker/issues/420) ([8d54938](https://github.com/webtorrent/bittorrent-tracker/commit/8d54938f164347d57a7991268d191e44b752de7f))
115+
116+
## [9.18.5](https://github.com/webtorrent/bittorrent-tracker/compare/v9.18.4...v9.18.5) (2022-03-25)
117+
118+
119+
### Bug Fixes
120+
121+
* connection leaks ([#420](https://github.com/webtorrent/bittorrent-tracker/issues/420)) ([f7928cf](https://github.com/webtorrent/bittorrent-tracker/commit/f7928cfcc646cd95556549b64e61228892314682))
122+
1123
## [9.18.4](https://github.com/webtorrent/bittorrent-tracker/compare/v9.18.3...v9.18.4) (2022-03-06)
2124

3125

bin/cmd.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22

3-
const minimist = require('minimist')
4-
const Server = require('../').Server
3+
import minimist from 'minimist'
4+
import { Server } from '../index.js'
55

66
const argv = minimist(process.argv.slice(2), {
77
alias: {

client.js

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
1-
const debug = require('debug')('bittorrent-tracker:client')
2-
const EventEmitter = require('events')
3-
const once = require('once')
4-
const parallel = require('run-parallel')
5-
const Peer = require('simple-peer')
6-
const queueMicrotask = require('queue-microtask')
7-
8-
const common = require('./lib/common')
9-
const HTTPTracker = require('./lib/client/http-tracker') // empty object in browser
10-
const UDPTracker = require('./lib/client/udp-tracker') // empty object in browser
11-
const WebSocketTracker = require('./lib/client/websocket-tracker')
1+
import Debug from 'debug'
2+
import EventEmitter from 'events'
3+
import once from 'once'
4+
import parallel from 'run-parallel'
5+
import Peer from '@thaunknown/simple-peer/lite.js'
6+
import queueMicrotask from 'queue-microtask'
7+
import { hex2arr, hex2bin, text2arr, arr2hex, arr2text } from 'uint8-util'
8+
9+
import common from './lib/common.js'
10+
import HTTPTracker from './lib/client/http-tracker.js' // empty object in browser
11+
import UDPTracker from './lib/client/udp-tracker.js' // empty object in browser
12+
import WebSocketTracker from './lib/client/websocket-tracker.js'
13+
14+
const debug = Debug('bittorrent-tracker:client')
1215

1316
/**
1417
* BitTorrent tracker client.
1518
*
1619
* Find torrent peers, to help a torrent client participate in a torrent swarm.
1720
*
1821
* @param {Object} opts options object
19-
* @param {string|Buffer} opts.infoHash torrent info hash
20-
* @param {string|Buffer} opts.peerId peer id
22+
* @param {string|Uint8Array} opts.infoHash torrent info hash
23+
* @param {string|Uint8Array} opts.peerId peer id
2124
* @param {string|Array.<string>} opts.announce announce
2225
* @param {number} opts.port torrent client listening port
2326
* @param {function} opts.getAnnounceOpts callback to provide data to tracker
@@ -37,15 +40,15 @@ class Client extends EventEmitter {
3740

3841
this.peerId = typeof opts.peerId === 'string'
3942
? opts.peerId
40-
: opts.peerId.toString('hex')
41-
this._peerIdBuffer = Buffer.from(this.peerId, 'hex')
42-
this._peerIdBinary = this._peerIdBuffer.toString('binary')
43+
: arr2hex(opts.peerId)
44+
this._peerIdBuffer = hex2arr(this.peerId)
45+
this._peerIdBinary = hex2bin(this.peerId)
4346

4447
this.infoHash = typeof opts.infoHash === 'string'
4548
? opts.infoHash.toLowerCase()
46-
: opts.infoHash.toString('hex')
47-
this._infoHashBuffer = Buffer.from(this.infoHash, 'hex')
48-
this._infoHashBinary = this._infoHashBuffer.toString('binary')
49+
: arr2hex(opts.infoHash)
50+
this._infoHashBuffer = hex2arr(this.infoHash)
51+
this._infoHashBinary = hex2bin(this.infoHash)
4952

5053
debug('new client %s', this.infoHash)
5154

@@ -67,7 +70,7 @@ class Client extends EventEmitter {
6770

6871
// Remove trailing slash from trackers to catch duplicates
6972
announce = announce.map(announceUrl => {
70-
announceUrl = announceUrl.toString()
73+
if (ArrayBuffer.isView(announceUrl)) announceUrl = arr2text(announceUrl)
7174
if (announceUrl[announceUrl.length - 1] === '/') {
7275
announceUrl = announceUrl.substring(0, announceUrl.length - 1)
7376
}
@@ -258,7 +261,7 @@ Client.scrape = (opts, cb) => {
258261

259262
const clientOpts = Object.assign({}, opts, {
260263
infoHash: Array.isArray(opts.infoHash) ? opts.infoHash[0] : opts.infoHash,
261-
peerId: Buffer.from('01234567890123456789'), // dummy value
264+
peerId: text2arr('01234567890123456789'), // dummy value
262265
port: 6881 // dummy value
263266
})
264267

@@ -282,11 +285,8 @@ Client.scrape = (opts, cb) => {
282285
}
283286
})
284287

285-
opts.infoHash = Array.isArray(opts.infoHash)
286-
? opts.infoHash.map(infoHash => Buffer.from(infoHash, 'hex'))
287-
: Buffer.from(opts.infoHash, 'hex')
288288
client.scrape({ infoHash: opts.infoHash })
289289
return client
290290
}
291291

292-
module.exports = Client
292+
export default Client

examples/express-embed/server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22

3-
const Server = require('../..').Server
4-
const express = require('express')
3+
import { Server } from '../../index.js'
4+
import express from 'express'
55
const app = express()
66

77
// https://wiki.theory.org/BitTorrentSpecification#peer_id

index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/*! bittorrent-tracker. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */
2-
const Client = require('./client')
3-
const Server = require('./server')
2+
import Client from './client.js'
3+
import Server from './server.js'
44

5-
module.exports = Client
6-
module.exports.Client = Client
7-
module.exports.Server = Server
5+
export default Client
6+
export { Client, Server }

0 commit comments

Comments
 (0)