Commit Graph

39 Commits

Author SHA1 Message Date
Cas
d7061f73b2
fix: bigInt (#472) 2023-06-07 17:44:34 +01:00
Cas
c99eb89208
fix: drop buffer (#465) 2023-05-26 17:54:30 +01:00
Cas
e6d3189edf
feat: esm (#431)
BREAKING CHANGE: ESM only

* feat: esm

* fix: linter oops
2022-12-05 23:06:54 +01:00
Linus Unnebäck
8222ccd1d6
style: use object shorthand for properties (#400) 2021-10-29 09:36:47 -05:00
Alex
ad64dc3a68
feat: add proxy support for tracker clients (#356)
* Add a httpAgent options to http and websocket client trackers.

* Add a socks proxy to udp client trackers.

* Update http agent mock to node 5+

* Bugfix in socks configuration

* Use new socket to connect to the proxy relay and slice the proxy header from the message

* Add documentation for proxy

* Provide http and https agents for proxy.
Change proxy options structure and auto populate socks HTTP agents.

* Update documentation

* Check socks version for UDP proxy

* Clone proxy settings to prevent Socks instances concurrency

* Generate socks http agents on the fly (reuse is not working)

* Use clone to deepcopy socks opts

* Dont create agent for now since we cannot reuse it between requests.

* Removed unused require

* Add .gitignore

* Fix merge conflict

* Fix URL toString

* Fix new Socket constructor

Co-authored-by: Yoann Ciabaud <yoann@sonora.io>
2021-08-20 16:08:36 -05:00
Diego Rodriguez Baquero
e5994d2ebd
fix: modernize 2021-06-14 20:54:41 -05:00
Alex
8e24a8c97b fix: UDP url parsing 2021-05-20 21:38:51 +02:00
Feross Aboukhadijeh
2a828292b8 standard 2020-10-29 10:25:57 -10:00
Feross Aboukhadijeh
c88bbb4a62 standard 2020-10-28 18:57:47 -10:00
Diego Rodríguez Baquero
e5df6fc2fc
fix: error param 2020-03-29 12:22:44 -05:00
Koushik Dutta
29d2e6b1b3
Error.message is read only on some platforms.
This causes another Error to be thrown.
2020-02-03 15:52:37 -08:00
Feross Aboukhadijeh
ddee6b96b5 Fix URL constructor on udp:// urls in Chrome App environment
For: https://github.com/brave/brave-browser/issues/5604

`bittorrent-tracker` is broken when run in a Chrome App environment.

The issue is that the `URL` constructor is buggy Chromium. https://bugs.chromium.org/p/chromium/issues/detail?id=734880

We switched to `URL` from `require('url')` in `bittorrent-tracker@9.13.0`. Commit: 93b41391a9

This code path was not exercised by `bittorrent-tracker`'s tests because UDP trackers are normally only used in a Node.js environment. Braves run the code in a Chrome extension environment which we don't test.
2019-08-08 20:04:41 -07:00
Feross Aboukhadijeh
d6751dac41 remove safe-buffer 2019-08-06 17:58:05 -07:00
Feross Aboukhadijeh
93b41391a9 BREAKING: drop Node 8 support 2019-08-05 14:54:20 -07:00
Feross Aboukhadijeh
1a075bd159 standard 2019-07-05 14:36:14 -07:00
Feross Aboukhadijeh
85e7a606a6 standard 2019-07-04 21:58:13 -07:00
Diego Rodríguez Baquero
dd861404e2
Leave default case without brackets 2018-12-20 15:03:15 -05:00
Justin Kalland
dc79834f77 Use blocks with brackets 2018-12-20 12:59:53 -07:00
Justin Kalland
bc861ef10a Revert "Remove declarations from inside switch statements"
This reverts commit d1b9047c03.
2018-12-20 12:52:05 -07:00
Justin Kalland
d1b9047c03 Remove declarations from inside switch statements 2018-12-20 12:36:54 -07:00
Jimmy Wärting
c8ceaee306 replace self with this 2018-10-03 15:06:38 +02:00
Jimmy Wärting
386e0a5fbe lebab lib/client 2018-10-03 14:44:11 +02:00
Feross Aboukhadijeh
7d2318dce6 Use unordered-array-remove for better performance! 2017-02-13 17:30:22 -08:00
Feross Aboukhadijeh
0aadcc1cbb Wait up to 1s for pending requests before destroy()
If the user calls:

client.stop()
client.destroy()

We should ensure that the final 'stopped' message reaches the tracker
server, even though the client will not get the response (because they
destroyed the client and no more events will be emitted).

If there are pending requests when destroy() is called, then a 1s timer
is set after which point all requests are forcibly cleaned up. If the
requests complete before the 1s timer fires, then cleanup happens right
away (so we're not stuck waiting for the 1s timer).

So, destroy() can happen one of three ways:

- immediately, if no pending requests exist
- after exactly 1s, if pending requests exist and they don't complete
within 1s
- less than 1s, if pending requests exist and they all complete before
the 1s timer fires
2017-01-20 18:41:28 -08:00
Feross Aboukhadijeh
a35f1f8178 replace hat with randombytes 2016-08-20 19:37:36 -07:00
Feross Aboukhadijeh
2959c2cea6 Use safe-buffer
Use the new Buffer APIs from Node v6 for added security. For example,
`Buffer.from()` will throw if passed a number, unlike `Buffer()` which
allocated UNINITIALIZED memory in that case.

Use the `safe-buffer` package for compatibility with previous versions
of
Node.js, including v4.x, v0.12, and v0.10.

https://github.com/feross/safe-buffer
2016-05-29 23:12:23 -07:00
Feross Aboukhadijeh
2966165a8f BREAKING: Client() takes single opts object now
To use the client, you used to pass in four arguments:

`new Client(peerId, port, parsedTorrent, opts)`

Now, passing in the torrent is no longer required, just the `announce`
and `infoHash` properties. This decouples this package from
`parse-torrent`.

All options get passed in together now:

new Client({
infoHash: '', // hex string or Buffer
peerId: '', // hex string or Buffer
announce: [], // list of tracker server urls
port: 6881 // torrent client port, (in browser, optional)
})

All the normal optional arguments (rtcConfig, wrtc, etc.) can still be
passed in with the rest of these options.

Fixes #118. Fixes #115.

Added ws tests for scrape.
2016-03-31 21:37:51 -07:00
Feross Aboukhadijeh
6df64ffe06 Fixes for PR #126 2016-03-14 19:16:00 -07:00
Autarc
09e2b55e42 invoke callbacks of destroyed trackers 2016-03-14 17:13:34 +01:00
Feross Aboukhadijeh
b34fc100a1 fixes for PR #107 2016-02-29 12:34:06 -08:00
Yoann Ciabaud
f1669a506e Provide a way to give updated announce opts via callback on setInterval 2016-02-03 08:28:38 +01:00
Feross Aboukhadijeh
177171b82c expose client.peerId and client.peerIdBuffer 2015-12-02 22:33:15 -08:00
Feross Aboukhadijeh
d344537766 expose client.infoHash and client.infoHashBuffer 2015-12-02 15:46:41 -08:00
Feross Aboukhadijeh
38a80093a1 Fix UDP scrape returning invalid info hashes (Fix #97) 2015-12-02 15:35:42 -08:00
Feross Aboukhadijeh
e9322a32d6 code style 2015-12-02 15:31:20 -08:00
Aram Drevekenin
ab3482fc4f Changed infoHash to always be hex 2015-11-29 16:02:29 +02:00
Feross Aboukhadijeh
f5d2810c89 Announce to websocket tracker every 30 seconds (for #338) 2015-07-29 02:12:14 -07:00
Feross Aboukhadijeh
9db28c2fad massive cleanup 2015-07-29 01:47:09 -07:00
Feross Aboukhadijeh
3746c05d79 restructure folders 2015-07-29 00:26:44 -07:00