Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
3eafbbe
chore(git): add gitignore
alxhotel May 20, 2021
7658a1b
Merge branch 'master' of ssh://github.com/webtorrent/bittorrent-track…
alxhotel May 20, 2021
afd4c39
Remove package-lock.json
alxhotel May 21, 2021
71fa7d3
Add renovate.json
renovate-bot May 24, 2021
160f490
chore(deps): update dependency bufferutil to ^4.0.3
renovate-bot May 24, 2021
9614c2f
chore(deps): update dependency wrtc to ^0.4.7
renovate-bot May 24, 2021
a82aaaa
fix(deps): update dependency chrome-dgram to ^3.0.6
renovate-bot May 24, 2021
fa2c33f
fix(deps): update dependency run-series to ^1.1.9
renovate-bot May 24, 2021
505f3ee
chore(deps): update dependency tape to ^5.2.2
renovate-bot May 24, 2021
fcf25ed
fix(deps): update dependency run-parallel to ^1.2.0
renovate-bot May 24, 2021
6ad7ead
fix(deps): update dependency ws to ^7.4.5
renovate-bot May 24, 2021
1e8d47d
fix(deps): update webtorrent
renovate-bot May 24, 2021
96fedbd
fix(deps): update dependency simple-websocket to ^9.1.0
renovate-bot May 24, 2021
002c392
chore(deps): update dependency magnet-uri to v6
renovate-bot May 24, 2021
27fcaca
Merge pull request #370 from webtorrent/renovate_run-series-1.x
alxhotel May 24, 2021
54a9cb7
Merge branch 'master' into renovate_run-parallel-1.x
alxhotel May 24, 2021
67b8321
Merge pull request #374 from webtorrent/renovate_run-parallel-1.x
alxhotel May 24, 2021
ab977d6
Merge pull request #375 from webtorrent/renovate_simple-websocket-9.x
alxhotel May 24, 2021
baaa581
Merge pull request #372 from webtorrent/renovate_tape-5.x
alxhotel May 24, 2021
ce22cc3
Merge pull request #376 from webtorrent/renovate_ws-7.x
alxhotel May 24, 2021
a6181b1
Merge pull request #369 from webtorrent/renovate_chrome-dgram-3.x
alxhotel May 24, 2021
bba0ab4
Merge pull request #368 from webtorrent/renovate_wrtc-0.x
alxhotel May 24, 2021
30f154e
Merge pull request #361 from webtorrent/add_gitignore
alxhotel May 24, 2021
2d36e4a
fix(deps): update dependency bn.js to ^5.2.0
renovate-bot May 24, 2021
36fe118
Merge pull request #373 from webtorrent/renovate_bn.js-5.x
alxhotel May 24, 2021
42d10bc
Merge pull request #377 from webtorrent/renovate_magnet-uri-6.x
DiegoRBaquero May 24, 2021
2dabe62
Merge pull request #365 from webtorrent/renovate_bufferutil-4.x
DiegoRBaquero May 24, 2021
df18c34
chore: create package-lock
DiegoRBaquero May 24, 2021
5ef498b
chore(deps): update dependency utf-8-validate to ^5.0.5
renovate-bot May 24, 2021
56e2f0c
Merge pull request #364 from webtorrent/renovate/configure
DiegoRBaquero May 24, 2021
d86d370
Delete renovate.json
DiegoRBaquero May 24, 2021
c3ae739
Merge pull request #366 from webtorrent/renovate_utf-8-validate-5.x
DiegoRBaquero May 24, 2021
d29770f
chore: update renovate config
DiegoRBaquero May 24, 2021
30209d1
chore: stale config
DiegoRBaquero May 24, 2021
0e486b0
fix: add package-lock
May 24, 2021
dfe1c2a
chore(deps): lock file maintenance
renovate-bot May 31, 2021
b8213a7
chore(deps): pin dependencies
renovate-bot May 31, 2021
fd6d61b
Merge pull request #378 from webtorrent/renovate_pin-dependencies
DiegoRBaquero May 31, 2021
13808da
chore: delete package-lock.json
DiegoRBaquero Jun 4, 2021
dff15e4
chore: delete .npmrc
DiegoRBaquero Jun 4, 2021
07beac4
chore: ignore package-lock.json
DiegoRBaquero Jun 4, 2021
401fdcd
ci: add release
Jun 15, 2021
8a97b7e
chore(release): 9.17.1
semantic-release-bot Jun 15, 2021
e5994d2
fix: modernize
Jun 15, 2021
ff20a05
chore(release): 9.17.2
semantic-release-bot Jun 15, 2021
b5ffc70
fix: auto update authors on version
DiegoRBaquero Jul 2, 2021
ba33a5c
chore(release): 9.17.3
semantic-release-bot Jul 2, 2021
ab706d2
chore(deps): update dependency semantic-release to v17.4.4 (#382)
renovate[bot] Jul 8, 2021
8a23ccd
Delete stale.yml
DiegoRBaquero Jul 22, 2021
4699cc2
chore: add stale
DiegoRBaquero Jul 22, 2021
ca88435
fix: if websocket closed, don't produce a response
Jul 22, 2021
22acc4d
chore(release): 9.17.4
semantic-release-bot Jul 22, 2021
7235970
chore(deps): update dependency webtorrent-fixtures to v1.7.4
renovate-bot Jul 23, 2021
79effef
chore(deps): update dependency webtorrent-fixtures to v1.7.5
renovate-bot Jul 30, 2021
3778c10
chore(deps): update dependency tape to v5.3.0 (#386)
renovate[bot] Aug 3, 2021
49e5ddf
chore(deps): update dependency tape to v5.3.1
renovate-bot Aug 7, 2021
71deb99
chore(deps): update dependency semantic-release to v17.4.5
renovate-bot Aug 16, 2021
ad64dc3
feat: add proxy support for tracker clients (#356)
alxhotel Aug 20, 2021
5cf534d
chore(release): 9.18.0
semantic-release-bot Aug 20, 2021
dae6716
chore(deps): update dependency @webtorrent/semantic-release-config to…
renovate-bot Aug 20, 2021
08f2242
chore(deps): update dependency semantic-release to v17.4.6
renovate-bot Aug 23, 2021
88fbbbe
chore(deps): update dependency semantic-release to v17.4.7
renovate-bot Aug 25, 2021
7fd5877
fix: disable socks in chromeapp (#398)
yrliou Sep 1, 2021
c00074a
chore(release): 9.18.1
semantic-release-bot Sep 1, 2021
353e1f4
fix(deps): update dependency socks to v2 (#394)
renovate[bot] Sep 2, 2021
fe0df46
chore(release): 9.18.2
semantic-release-bot Sep 2, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Release

on:
push:
branches:
- master

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 14
- name: Cache
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Install dependencies
run: npm i
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
23 changes: 23 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Mark stale issues and pull requests

on:
schedule:
- cron: '0 12 * * *'

jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write

steps:
- uses: actions/stale@v4
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?'
stale-pr-message: 'Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?'
exempt-issue-labels: accepted,blocked,bug,dependency,enhancement,'help wanted',question,security,meta
exempt-pr-labels: accepted,blocked,bug,dependency,enhancement,'help wanted',question,security,meta
stale-issue-label: 'stale'
stale-pr-label: 'stale'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
package-lock.json
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

7 changes: 7 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,12 @@
- Koushik Dutta ([email protected])
- KayleePop ([email protected])
- Diego Rodriguez Baquero ([email protected])
- Diego Rodríguez Baquero ([email protected])
- Renovate Bot ([email protected])
- Diego Rodríguez Baquero ([email protected])
- Diego Rodriguez Baquero ([email protected])
- semantic-release-bot ([email protected])
- renovate[bot] (29139614+renovate[bot]@users.noreply.github.com)
- Jocelyn Liu ([email protected])

#### Generated by tools/update-authors.sh.
56 changes: 56 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
## [9.18.2](https://github.com/webtorrent/bittorrent-tracker/compare/v9.18.1...v9.18.2) (2021-09-02)


### Bug Fixes

* **deps:** update dependency socks to v2 ([#394](https://github.com/webtorrent/bittorrent-tracker/issues/394)) ([353e1f4](https://github.com/webtorrent/bittorrent-tracker/commit/353e1f40093a5e74cb54219abbae8ef0cc3d9e0b))

## [9.18.1](https://github.com/webtorrent/bittorrent-tracker/compare/v9.18.0...v9.18.1) (2021-09-01)


### Bug Fixes

* disable socks in chromeapp ([#398](https://github.com/webtorrent/bittorrent-tracker/issues/398)) ([7fd5877](https://github.com/webtorrent/bittorrent-tracker/commit/7fd587789548453a852ea01e54900a5e9155db67))

# [9.18.0](https://github.com/webtorrent/bittorrent-tracker/compare/v9.17.4...v9.18.0) (2021-08-20)


### Features

* add proxy support for tracker clients ([#356](https://github.com/webtorrent/bittorrent-tracker/issues/356)) ([ad64dc3](https://github.com/webtorrent/bittorrent-tracker/commit/ad64dc3a68cddccc2c1f05d0d8bb833f2c4860b2))

## [9.17.4](https://github.com/webtorrent/bittorrent-tracker/compare/v9.17.3...v9.17.4) (2021-07-22)


### Bug Fixes

* if websocket closed, don't produce a response ([ca88435](https://github.com/webtorrent/bittorrent-tracker/commit/ca88435617e59714a456031c75b3a329897d97bd))

## [9.17.3](https://github.com/webtorrent/bittorrent-tracker/compare/v9.17.2...v9.17.3) (2021-07-02)


### Bug Fixes

* auto update authors on version ([b5ffc70](https://github.com/webtorrent/bittorrent-tracker/commit/b5ffc708ada0bef66e7fa0cd1872527ea6dd8d53))

## [9.17.2](https://github.com/webtorrent/bittorrent-tracker/compare/v9.17.1...v9.17.2) (2021-06-15)


### Bug Fixes

* modernize ([e5994d2](https://github.com/webtorrent/bittorrent-tracker/commit/e5994d2ebdec10fe2165e31f5b498382eeeaaf5f))

## [9.17.1](https://github.com/webtorrent/bittorrent-tracker/compare/v9.17.0...v9.17.1) (2021-06-15)


### Bug Fixes

* add package-lock ([0e486b0](https://github.com/webtorrent/bittorrent-tracker/commit/0e486b09d80d30e1c13d4624e29c4251000d4092))
* **deps:** update dependency bn.js to ^5.2.0 ([2d36e4a](https://github.com/webtorrent/bittorrent-tracker/commit/2d36e4ae60b1bac51773f2dca81c1a158b51cb28))
* **deps:** update dependency chrome-dgram to ^3.0.6 ([a82aaaa](https://github.com/webtorrent/bittorrent-tracker/commit/a82aaaa31963a0d9adb640166f417142c5d7b970))
* **deps:** update dependency run-parallel to ^1.2.0 ([fcf25ed](https://github.com/webtorrent/bittorrent-tracker/commit/fcf25ed40e1fd64e630b10a0281bc09604b901d3))
* **deps:** update dependency run-series to ^1.1.9 ([fa2c33f](https://github.com/webtorrent/bittorrent-tracker/commit/fa2c33fc91f8ef0a47d0f40b7a046ae179ee328a))
* **deps:** update dependency simple-websocket to ^9.1.0 ([96fedbd](https://github.com/webtorrent/bittorrent-tracker/commit/96fedbdf56ddcf6627eb373a33589db885cb4fb7))
* **deps:** update dependency ws to ^7.4.5 ([6ad7ead](https://github.com/webtorrent/bittorrent-tracker/commit/6ad7ead994e5cb99980a406aea908e4b9ff6151c))
* **deps:** update webtorrent ([1e8d47d](https://github.com/webtorrent/bittorrent-tracker/commit/1e8d47dcd8f5f53b42aa75265a129f950d16feef))
* UDP url parsing ([8e24a8c](https://github.com/webtorrent/bittorrent-tracker/commit/8e24a8c97b55bbaaf2c92a496d1cd30b0c008934))
50 changes: 44 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ var requiredOpts = {
}

var optionalOpts = {
// RTCPeerConnection config object (only used in browser)
rtcConfig: {},
// User-Agent header for http requests
userAgent: '',
// Custom webrtc impl, useful in node to specify [wrtc](https://npmjs.com/package/wrtc)
wrtc: {},
getAnnounceOpts: function () {
// Provide a callback that will be called whenever announce() is called
// internally (on timer), or by the user
Expand All @@ -75,12 +81,44 @@ var optionalOpts = {
customParam: 'blah' // custom parameters supported
}
},
// RTCPeerConnection config object (only used in browser)
rtcConfig: {},
// User-Agent header for http requests
userAgent: '',
// Custom webrtc impl, useful in node to specify [wrtc](https://npmjs.com/package/wrtc)
wrtc: {},
// Proxy config object
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: {}
},
}

var client = new Client(requiredOpts)
Expand Down
40 changes: 20 additions & 20 deletions bin/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if (argv.version) {
}

if (argv.help) {
console.log(function () {
console.log((() => {
/*
bittorrent-tracker - Start a bittorrent tracker server

Expand All @@ -64,7 +64,7 @@ if (argv.help) {
-v, --version print the current version

*/
}.toString().split(/\n/).slice(2, -2).join('\n'))
}).toString().split(/\n/).slice(2, -2).join('\n'))
process.exit(0)
}

Expand All @@ -85,23 +85,23 @@ const server = new Server({
ws: argv.ws
})

server.on('error', function (err) {
if (!argv.silent) console.error('ERROR: ' + err.message)
server.on('error', err => {
if (!argv.silent) console.error(`ERROR: ${err.message}`)
})
server.on('warning', function (err) {
if (!argv.quiet) console.log('WARNING: ' + err.message)
server.on('warning', err => {
if (!argv.quiet) console.log(`WARNING: ${err.message}`)
})
server.on('update', function (addr) {
if (!argv.quiet) console.log('update: ' + addr)
server.on('update', addr => {
if (!argv.quiet) console.log(`update: ${addr}`)
})
server.on('complete', function (addr) {
if (!argv.quiet) console.log('complete: ' + addr)
server.on('complete', addr => {
if (!argv.quiet) console.log(`complete: ${addr}`)
})
server.on('start', function (addr) {
if (!argv.quiet) console.log('start: ' + addr)
server.on('start', addr => {
if (!argv.quiet) console.log(`start: ${addr}`)
})
server.on('stop', function (addr) {
if (!argv.quiet) console.log('stop: ' + addr)
server.on('stop', addr => {
if (!argv.quiet) console.log(`stop: ${addr}`)
})

const hostname = {
Expand All @@ -110,35 +110,35 @@ const hostname = {
udp6: argv['udp6-hostname']
}

server.listen(argv.port, hostname, function () {
server.listen(argv.port, hostname, () => {
if (server.http && argv.http && !argv.quiet) {
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(`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(`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(`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(`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(`Tracker stats: http://${statsHost}:${statsPort}/stats`)
}
})
6 changes: 3 additions & 3 deletions client.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const WebSocketTracker = require('./lib/client/websocket-tracker')
* @param {number} opts.rtcConfig RTCPeerConnection configuration object
* @param {number} opts.userAgent User-Agent header for http requests
* @param {number} opts.wrtc custom webrtc impl (useful in node.js)
* @param {object} opts.proxyOpts proxy options (useful in node.js)
*/
class Client extends EventEmitter {
constructor (opts = {}) {
Expand Down Expand Up @@ -54,6 +55,7 @@ class Client extends EventEmitter {
this._getAnnounceOpts = opts.getAnnounceOpts
this._rtcConfig = opts.rtcConfig
this._userAgent = opts.userAgent
this._proxyOpts = opts.proxyOpts

// Support lazy 'wrtc' module initialization
// See: https://github.com/webtorrent/webtorrent-hybrid/issues/46
Expand Down Expand Up @@ -281,9 +283,7 @@ Client.scrape = (opts, cb) => {
})

opts.infoHash = Array.isArray(opts.infoHash)
? opts.infoHash.map(infoHash => {
return Buffer.from(infoHash, 'hex')
})
? opts.infoHash.map(infoHash => Buffer.from(infoHash, 'hex'))
: Buffer.from(opts.infoHash, 'hex')
client.scrape({ infoHash: opts.infoHash })
return client
Expand Down
2 changes: 1 addition & 1 deletion examples/express-embed/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const server = new Server({
http: false, // we do our own
udp: false, // not interested
ws: false, // not interested
filter: function (params) {
filter (params) {
// black/whitelist for disallowing/allowing specific clients [default=allow all]
// this example only allows the uTorrent client
const client = params.peer_id[1] + params.peer_id[2]
Expand Down
21 changes: 14 additions & 7 deletions lib/client/http-tracker.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
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')
Expand All @@ -17,7 +19,7 @@ const HTTP_SCRAPE_SUPPORT = /\/(announce)[^/]*$/
* @param {Object} opts options object
*/
class HTTPTracker extends Tracker {
constructor (client, announceUrl, opts) {
constructor (client, announceUrl) {
super(client, announceUrl)

debug('new http tracker %s', announceUrl)
Expand Down Expand Up @@ -62,9 +64,7 @@ class HTTPTracker extends Tracker {
}

const infoHashes = (Array.isArray(opts.infoHash) && opts.infoHash.length > 0)
? opts.infoHash.map(infoHash => {
return infoHash.toString('binary')
})
? opts.infoHash.map(infoHash => infoHash.toString('binary'))
: (opts.infoHash && opts.infoHash.toString('binary')) || this.client._infoHashBinary
const params = {
info_hash: infoHashes
Expand Down Expand Up @@ -112,13 +112,20 @@ class HTTPTracker extends Tracker {

_request (requestUrl, params, cb) {
const self = this
const u = requestUrl + (!requestUrl.includes('?') ? '?' : '&') +
common.querystringStringify(params)
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:'))
}
}

this.cleanupFns.push(cleanup)

let request = get.concat({
url: u,
url: parsedUrl.toString(),
agent: agent,
timeout: common.REQUEST_TIMEOUT,
headers: {
'user-agent': this.client._userAgent || ''
Expand Down
Loading