Skip to content

Commit 2392e76

Browse files
authored
Merge branch 'master' into proxy
2 parents 1349961 + 7235970 commit 2392e76

35 files changed

+730
-579
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: ci
2+
'on':
3+
- push
4+
- pull_request
5+
jobs:
6+
test:
7+
name: Node ${{ matrix.node }} / ${{ matrix.os }}
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
os:
13+
- ubuntu-latest
14+
node:
15+
- '14'
16+
steps:
17+
- uses: actions/checkout@v2
18+
- uses: actions/setup-node@v2
19+
with:
20+
node-version: ${{ matrix.node }}
21+
- run: npm install
22+
- run: npm run build --if-present
23+
- run: npm test

.github/workflows/release.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
release:
10+
name: Release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
with:
16+
persist-credentials: false
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v2
19+
with:
20+
node-version: 14
21+
- name: Cache
22+
uses: actions/cache@v2
23+
with:
24+
path: ~/.npm
25+
key: ${{ runner.os }}-npm-${{ hashFiles('**/package.json') }}
26+
restore-keys: |
27+
${{ runner.os }}-npm-
28+
- name: Install dependencies
29+
run: npm i
30+
env:
31+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
32+
- name: Release
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
35+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
36+
run: npx semantic-release

.github/workflows/stale.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Mark stale issues and pull requests
2+
3+
on:
4+
schedule:
5+
- cron: '0 12 * * *'
6+
7+
jobs:
8+
stale:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
issues: write
12+
pull-requests: write
13+
14+
steps:
15+
- uses: actions/stale@v4
16+
with:
17+
repo-token: ${{ secrets.GITHUB_TOKEN }}
18+
stale-issue-message: 'Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?'
19+
stale-pr-message: 'Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?'
20+
exempt-issue-labels: accepted,blocked,bug,dependency,enhancement,'help wanted',question,security,meta
21+
exempt-pr-labels: accepted,blocked,bug,dependency,enhancement,'help wanted',question,security,meta
22+
stale-issue-label: 'stale'
23+
stale-pr-label: 'stale'

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
.travis.yml
21
CONTRIBUTING.md
32
examples/
43
img/
54
test/
65
tools/
6+
.github/

.travis.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

AUTHORS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,11 @@
5050
- Koushik Dutta ([email protected])
5151
- KayleePop ([email protected])
5252
- Diego Rodriguez Baquero ([email protected])
53+
- Diego Rodríguez Baquero ([email protected])
54+
- Renovate Bot ([email protected])
55+
- Diego Rodríguez Baquero ([email protected])
56+
- Diego Rodriguez Baquero ([email protected])
57+
- semantic-release-bot ([email protected])
58+
- renovate[bot] (29139614+renovate[bot]@users.noreply.github.com)
5359

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

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
## [9.17.4](https://github.com/webtorrent/bittorrent-tracker/compare/v9.17.3...v9.17.4) (2021-07-22)
2+
3+
4+
### Bug Fixes
5+
6+
* if websocket closed, don't produce a response ([ca88435](https://github.com/webtorrent/bittorrent-tracker/commit/ca88435617e59714a456031c75b3a329897d97bd))
7+
8+
## [9.17.3](https://github.com/webtorrent/bittorrent-tracker/compare/v9.17.2...v9.17.3) (2021-07-02)
9+
10+
11+
### Bug Fixes
12+
13+
* auto update authors on version ([b5ffc70](https://github.com/webtorrent/bittorrent-tracker/commit/b5ffc708ada0bef66e7fa0cd1872527ea6dd8d53))
14+
15+
## [9.17.2](https://github.com/webtorrent/bittorrent-tracker/compare/v9.17.1...v9.17.2) (2021-06-15)
16+
17+
18+
### Bug Fixes
19+
20+
* modernize ([e5994d2](https://github.com/webtorrent/bittorrent-tracker/commit/e5994d2ebdec10fe2165e31f5b498382eeeaaf5f))
21+
22+
## [9.17.1](https://github.com/webtorrent/bittorrent-tracker/compare/v9.17.0...v9.17.1) (2021-06-15)
23+
24+
25+
### Bug Fixes
26+
27+
* add package-lock ([0e486b0](https://github.com/webtorrent/bittorrent-tracker/commit/0e486b09d80d30e1c13d4624e29c4251000d4092))
28+
* **deps:** update dependency bn.js to ^5.2.0 ([2d36e4a](https://github.com/webtorrent/bittorrent-tracker/commit/2d36e4ae60b1bac51773f2dca81c1a158b51cb28))
29+
* **deps:** update dependency chrome-dgram to ^3.0.6 ([a82aaaa](https://github.com/webtorrent/bittorrent-tracker/commit/a82aaaa31963a0d9adb640166f417142c5d7b970))
30+
* **deps:** update dependency run-parallel to ^1.2.0 ([fcf25ed](https://github.com/webtorrent/bittorrent-tracker/commit/fcf25ed40e1fd64e630b10a0281bc09604b901d3))
31+
* **deps:** update dependency run-series to ^1.1.9 ([fa2c33f](https://github.com/webtorrent/bittorrent-tracker/commit/fa2c33fc91f8ef0a47d0f40b7a046ae179ee328a))
32+
* **deps:** update dependency simple-websocket to ^9.1.0 ([96fedbd](https://github.com/webtorrent/bittorrent-tracker/commit/96fedbdf56ddcf6627eb373a33589db885cb4fb7))
33+
* **deps:** update dependency ws to ^7.4.5 ([6ad7ead](https://github.com/webtorrent/bittorrent-tracker/commit/6ad7ead994e5cb99980a406aea908e4b9ff6151c))
34+
* **deps:** update webtorrent ([1e8d47d](https://github.com/webtorrent/bittorrent-tracker/commit/1e8d47dcd8f5f53b42aa75265a129f950d16feef))
35+
* UDP url parsing ([8e24a8c](https://github.com/webtorrent/bittorrent-tracker/commit/8e24a8c97b55bbaaf2c92a496d1cd30b0c008934))

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# bittorrent-tracker [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
1+
# bittorrent-tracker [![ci][ci-image]][ci-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
22

3-
[travis-image]: https://img.shields.io/travis/webtorrent/bittorrent-tracker/master.svg
4-
[travis-url]: https://travis-ci.org/webtorrent/bittorrent-tracker
3+
[ci-image]: https://img.shields.io/github/workflow/status/webtorrent/bittorrent-tracker/ci/master
4+
[ci-url]: https://github.com/webtorrent/bittorrent-tracker/actions
55
[npm-image]: https://img.shields.io/npm/v/bittorrent-tracker.svg
66
[npm-url]: https://npmjs.org/package/bittorrent-tracker
77
[downloads-image]: https://img.shields.io/npm/dm/bittorrent-tracker.svg

bin/cmd.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ if (argv.version) {
3939
}
4040

4141
if (argv.help) {
42-
console.log(function () {
42+
console.log((() => {
4343
/*
4444
bittorrent-tracker - Start a bittorrent tracker server
4545
@@ -64,7 +64,7 @@ if (argv.help) {
6464
-v, --version print the current version
6565
6666
*/
67-
}.toString().split(/\n/).slice(2, -2).join('\n'))
67+
}).toString().split(/\n/).slice(2, -2).join('\n'))
6868
process.exit(0)
6969
}
7070

@@ -85,23 +85,23 @@ const server = new Server({
8585
ws: argv.ws
8686
})
8787

88-
server.on('error', function (err) {
89-
if (!argv.silent) console.error('ERROR: ' + err.message)
88+
server.on('error', err => {
89+
if (!argv.silent) console.error(`ERROR: ${err.message}`)
9090
})
91-
server.on('warning', function (err) {
92-
if (!argv.quiet) console.log('WARNING: ' + err.message)
91+
server.on('warning', err => {
92+
if (!argv.quiet) console.log(`WARNING: ${err.message}`)
9393
})
94-
server.on('update', function (addr) {
95-
if (!argv.quiet) console.log('update: ' + addr)
94+
server.on('update', addr => {
95+
if (!argv.quiet) console.log(`update: ${addr}`)
9696
})
97-
server.on('complete', function (addr) {
98-
if (!argv.quiet) console.log('complete: ' + addr)
97+
server.on('complete', addr => {
98+
if (!argv.quiet) console.log(`complete: ${addr}`)
9999
})
100-
server.on('start', function (addr) {
101-
if (!argv.quiet) console.log('start: ' + addr)
100+
server.on('start', addr => {
101+
if (!argv.quiet) console.log(`start: ${addr}`)
102102
})
103-
server.on('stop', function (addr) {
104-
if (!argv.quiet) console.log('stop: ' + addr)
103+
server.on('stop', addr => {
104+
if (!argv.quiet) console.log(`stop: ${addr}`)
105105
})
106106

107107
const hostname = {
@@ -110,35 +110,35 @@ const hostname = {
110110
udp6: argv['udp6-hostname']
111111
}
112112

113-
server.listen(argv.port, hostname, function () {
113+
server.listen(argv.port, hostname, () => {
114114
if (server.http && argv.http && !argv.quiet) {
115115
const httpAddr = server.http.address()
116116
const httpHost = httpAddr.address !== '::' ? httpAddr.address : 'localhost'
117117
const httpPort = httpAddr.port
118-
console.log('HTTP tracker: http://' + httpHost + ':' + httpPort + '/announce')
118+
console.log(`HTTP tracker: http://${httpHost}:${httpPort}/announce`)
119119
}
120120
if (server.udp && !argv.quiet) {
121121
const udpAddr = server.udp.address()
122122
const udpHost = udpAddr.address
123123
const udpPort = udpAddr.port
124-
console.log('UDP tracker: udp://' + udpHost + ':' + udpPort)
124+
console.log(`UDP tracker: udp://${udpHost}:${udpPort}`)
125125
}
126126
if (server.udp6 && !argv.quiet) {
127127
const udp6Addr = server.udp6.address()
128128
const udp6Host = udp6Addr.address !== '::' ? udp6Addr.address : 'localhost'
129129
const udp6Port = udp6Addr.port
130-
console.log('UDP6 tracker: udp://' + udp6Host + ':' + udp6Port)
130+
console.log(`UDP6 tracker: udp://${udp6Host}:${udp6Port}`)
131131
}
132132
if (server.ws && !argv.quiet) {
133133
const wsAddr = server.http.address()
134134
const wsHost = wsAddr.address !== '::' ? wsAddr.address : 'localhost'
135135
const wsPort = wsAddr.port
136-
console.log('WebSocket tracker: ws://' + wsHost + ':' + wsPort)
136+
console.log(`WebSocket tracker: ws://${wsHost}:${wsPort}`)
137137
}
138138
if (server.http && argv.stats && !argv.quiet) {
139139
const statsAddr = server.http.address()
140140
const statsHost = statsAddr.address !== '::' ? statsAddr.address : 'localhost'
141141
const statsPort = statsAddr.port
142-
console.log('Tracker stats: http://' + statsHost + ':' + statsPort + '/stats')
142+
console.log(`Tracker stats: http://${statsHost}:${statsPort}/stats`)
143143
}
144144
})

client.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const EventEmitter = require('events')
33
const once = require('once')
44
const parallel = require('run-parallel')
55
const Peer = require('simple-peer')
6+
const queueMicrotask = require('queue-microtask')
67

78
const common = require('./lib/common')
89
const HTTPTracker = require('./lib/client/http-tracker') // empty object in browser
@@ -78,7 +79,7 @@ class Client extends EventEmitter {
7879
const webrtcSupport = this._wrtc !== false && (!!this._wrtc || Peer.WEBRTC_SUPPORT)
7980

8081
const nextTickWarn = err => {
81-
process.nextTick(() => {
82+
queueMicrotask(() => {
8283
this.emit('warning', err)
8384
})
8485
}
@@ -87,7 +88,7 @@ class Client extends EventEmitter {
8788
.map(announceUrl => {
8889
let parsedUrl
8990
try {
90-
parsedUrl = new URL(announceUrl)
91+
parsedUrl = common.parseUrl(announceUrl)
9192
} catch (err) {
9293
nextTickWarn(new Error(`Invalid tracker URL: ${announceUrl}`))
9394
return null
@@ -282,9 +283,7 @@ Client.scrape = (opts, cb) => {
282283
})
283284

284285
opts.infoHash = Array.isArray(opts.infoHash)
285-
? opts.infoHash.map(infoHash => {
286-
return Buffer.from(infoHash, 'hex')
287-
})
286+
? opts.infoHash.map(infoHash => Buffer.from(infoHash, 'hex'))
288287
: Buffer.from(opts.infoHash, 'hex')
289288
client.scrape({ infoHash: opts.infoHash })
290289
return client

0 commit comments

Comments
 (0)