Skip to content

Commit 83d5515

Browse files
authored
Merge branch 'webtorrent:master' into master
2 parents 5af58b7 + 4df0120 commit 83d5515

33 files changed

+924
-575
lines changed

.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'

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
package-lock.json

AUTHORS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,12 @@
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)
59+
- Jocelyn Liu ([email protected])
5360

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

CHANGELOG.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
## [9.18.3](https://github.com/webtorrent/bittorrent-tracker/compare/v9.18.2...v9.18.3) (2021-10-29)
2+
3+
4+
### Bug Fixes
5+
6+
* **deps:** update dependency clone to v2 ([#393](https://github.com/webtorrent/bittorrent-tracker/issues/393)) ([dc6f796](https://github.com/webtorrent/bittorrent-tracker/commit/dc6f7966844216c39491d6623dd412d5ca65d4c4))
7+
8+
## [9.18.2](https://github.com/webtorrent/bittorrent-tracker/compare/v9.18.1...v9.18.2) (2021-09-02)
9+
10+
11+
### Bug Fixes
12+
13+
* **deps:** update dependency socks to v2 ([#394](https://github.com/webtorrent/bittorrent-tracker/issues/394)) ([353e1f4](https://github.com/webtorrent/bittorrent-tracker/commit/353e1f40093a5e74cb54219abbae8ef0cc3d9e0b))
14+
15+
## [9.18.1](https://github.com/webtorrent/bittorrent-tracker/compare/v9.18.0...v9.18.1) (2021-09-01)
16+
17+
18+
### Bug Fixes
19+
20+
* disable socks in chromeapp ([#398](https://github.com/webtorrent/bittorrent-tracker/issues/398)) ([7fd5877](https://github.com/webtorrent/bittorrent-tracker/commit/7fd587789548453a852ea01e54900a5e9155db67))
21+
22+
# [9.18.0](https://github.com/webtorrent/bittorrent-tracker/compare/v9.17.4...v9.18.0) (2021-08-20)
23+
24+
25+
### Features
26+
27+
* add proxy support for tracker clients ([#356](https://github.com/webtorrent/bittorrent-tracker/issues/356)) ([ad64dc3](https://github.com/webtorrent/bittorrent-tracker/commit/ad64dc3a68cddccc2c1f05d0d8bb833f2c4860b2))
28+
29+
## [9.17.4](https://github.com/webtorrent/bittorrent-tracker/compare/v9.17.3...v9.17.4) (2021-07-22)
30+
31+
32+
### Bug Fixes
33+
34+
* if websocket closed, don't produce a response ([ca88435](https://github.com/webtorrent/bittorrent-tracker/commit/ca88435617e59714a456031c75b3a329897d97bd))
35+
36+
## [9.17.3](https://github.com/webtorrent/bittorrent-tracker/compare/v9.17.2...v9.17.3) (2021-07-02)
37+
38+
39+
### Bug Fixes
40+
41+
* auto update authors on version ([b5ffc70](https://github.com/webtorrent/bittorrent-tracker/commit/b5ffc708ada0bef66e7fa0cd1872527ea6dd8d53))
42+
43+
## [9.17.2](https://github.com/webtorrent/bittorrent-tracker/compare/v9.17.1...v9.17.2) (2021-06-15)
44+
45+
46+
### Bug Fixes
47+
48+
* modernize ([e5994d2](https://github.com/webtorrent/bittorrent-tracker/commit/e5994d2ebdec10fe2165e31f5b498382eeeaaf5f))
49+
50+
## [9.17.1](https://github.com/webtorrent/bittorrent-tracker/compare/v9.17.0...v9.17.1) (2021-06-15)
51+
52+
53+
### Bug Fixes
54+
55+
* add package-lock ([0e486b0](https://github.com/webtorrent/bittorrent-tracker/commit/0e486b09d80d30e1c13d4624e29c4251000d4092))
56+
* **deps:** update dependency bn.js to ^5.2.0 ([2d36e4a](https://github.com/webtorrent/bittorrent-tracker/commit/2d36e4ae60b1bac51773f2dca81c1a158b51cb28))
57+
* **deps:** update dependency chrome-dgram to ^3.0.6 ([a82aaaa](https://github.com/webtorrent/bittorrent-tracker/commit/a82aaaa31963a0d9adb640166f417142c5d7b970))
58+
* **deps:** update dependency run-parallel to ^1.2.0 ([fcf25ed](https://github.com/webtorrent/bittorrent-tracker/commit/fcf25ed40e1fd64e630b10a0281bc09604b901d3))
59+
* **deps:** update dependency run-series to ^1.1.9 ([fa2c33f](https://github.com/webtorrent/bittorrent-tracker/commit/fa2c33fc91f8ef0a47d0f40b7a046ae179ee328a))
60+
* **deps:** update dependency simple-websocket to ^9.1.0 ([96fedbd](https://github.com/webtorrent/bittorrent-tracker/commit/96fedbdf56ddcf6627eb373a33589db885cb4fb7))
61+
* **deps:** update dependency ws to ^7.4.5 ([6ad7ead](https://github.com/webtorrent/bittorrent-tracker/commit/6ad7ead994e5cb99980a406aea908e4b9ff6151c))
62+
* **deps:** update webtorrent ([1e8d47d](https://github.com/webtorrent/bittorrent-tracker/commit/1e8d47dcd8f5f53b42aa75265a129f950d16feef))
63+
* UDP url parsing ([8e24a8c](https://github.com/webtorrent/bittorrent-tracker/commit/8e24a8c97b55bbaaf2c92a496d1cd30b0c008934))

README.md

Lines changed: 73 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ var requiredOpts = {
6767
}
6868

6969
var optionalOpts = {
70+
// RTCPeerConnection config object (only used in browser)
71+
rtcConfig: {},
72+
// User-Agent header for http requests
73+
userAgent: '',
74+
// Custom webrtc impl, useful in node to specify [wrtc](https://npmjs.com/package/wrtc)
75+
wrtc: {},
7076
getAnnounceOpts: function () {
7177
// Provide a callback that will be called whenever announce() is called
7278
// internally (on timer), or by the user
@@ -77,12 +83,44 @@ var optionalOpts = {
7783
customParam: 'blah' // custom parameters supported
7884
}
7985
},
80-
// RTCPeerConnection config object (only used in browser)
81-
rtcConfig: {},
82-
// User-Agent header for http requests
83-
userAgent: '',
84-
// Custom webrtc impl, useful in node to specify [wrtc](https://npmjs.com/package/wrtc)
85-
wrtc: {},
86+
// Proxy config object
87+
proxyOpts: {
88+
// Socks proxy options (used to proxy requests in node)
89+
socksProxy: {
90+
// Configuration from socks module (https://github.com/JoshGlazebrook/socks)
91+
proxy: {
92+
// IP Address of Proxy (Required)
93+
ipaddress: "1.2.3.4",
94+
// TCP Port of Proxy (Required)
95+
port: 1080,
96+
// Proxy Type [4, 5] (Required)
97+
// Note: 4 works for both 4 and 4a.
98+
// Type 4 does not support UDP association relay
99+
type: 5,
100+
101+
// SOCKS 4 Specific:
102+
103+
// UserId used when making a SOCKS 4/4a request. (Optional)
104+
userid: "someuserid",
105+
106+
// SOCKS 5 Specific:
107+
108+
// Authentication used for SOCKS 5 (when it's required) (Optional)
109+
authentication: {
110+
username: "Josh",
111+
password: "somepassword"
112+
}
113+
},
114+
115+
// Amount of time to wait for a connection to be established. (Optional)
116+
// - defaults to 10000ms (10 seconds)
117+
timeout: 10000
118+
},
119+
// NodeJS HTTP agents (used to proxy HTTP and Websocket requests in node)
120+
// Populated with Socks.Agent if socksProxy is provided
121+
httpAgent: {},
122+
httpsAgent: {}
123+
},
86124
}
87125

88126
var client = new Client(requiredOpts)
@@ -146,13 +184,14 @@ client.on('scrape', function (data) {
146184
To start a BitTorrent tracker server to track swarms of peers:
147185

148186
```js
149-
var Server = require('bittorrent-tracker').Server
187+
const Server = require('bittorrent-tracker').Server
150188

151-
var server = new Server({
189+
const server = new Server({
152190
udp: true, // enable udp server? [default=true]
153191
http: true, // enable http server? [default=true]
154192
ws: true, // enable websocket server? [default=true]
155193
stats: true, // enable web-based statistics? [default=true]
194+
trustProxy: false, // enable trusting x-forwarded-for header for remote IP [default=false]
156195
filter: function (infoHash, params, cb) {
157196
// Blacklist/whitelist function for allowing/disallowing torrents. If this option is
158197
// omitted, all torrents are allowed. It is possible to interface with a database or
@@ -164,7 +203,7 @@ var server = new Server({
164203

165204
// This example only allows one torrent.
166205

167-
var allowed = (infoHash === 'aaa67059ed6bd08362da625b3ae77f6f4a075aaa')
206+
const allowed = (infoHash === 'aaa67059ed6bd08362da625b3ae77f6f4a075aaa')
168207
if (allowed) {
169208
// If the callback is passed `null`, the torrent will be allowed.
170209
cb(null)
@@ -193,12 +232,34 @@ server.on('warning', function (err) {
193232

194233
server.on('listening', function () {
195234
// fired when all requested servers are listening
196-
console.log('listening on http port:' + server.http.address().port)
197-
console.log('listening on udp port:' + server.udp.address().port)
235+
236+
// HTTP
237+
const httpAddr = server.http.address()
238+
const httpHost = httpAddr.address !== '::' ? httpAddr.address : 'localhost'
239+
const httpPort = httpAddr.port
240+
console.log(`HTTP tracker: http://${httpHost}:${httpPort}/announce`)
241+
242+
// UDP
243+
const udpAddr = server.udp.address()
244+
const udpHost = udpAddr.address
245+
const udpPort = udpAddr.port
246+
console.log(`UDP tracker: udp://${udpHost}:${udpPort}`)
247+
248+
// WS
249+
const wsAddr = server.http.address()
250+
const wsHost = wsAddr.address !== '::' ? wsAddr.address : 'localhost'
251+
const wsPort = wsAddr.port
252+
console.log(`WebSocket tracker: ws://${wsHost}:${wsPort}`)
253+
198254
})
199255

256+
200257
// start tracker server listening! Use 0 to listen on a random free port.
201-
server.listen(port, hostname, onlistening)
258+
const port = 0
259+
const hostname = "localhost"
260+
server.listen(port, hostname, () => {
261+
// Do something on listening...
262+
})
202263

203264
// listen for individual tracker messages from peers:
204265

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
})

0 commit comments

Comments
 (0)