Commit Graph

80 Commits

Author SHA1 Message Date
Cas_
bce64e155d
feat(major): drop simple-get (#443)
BREAKING CHANGE: drop simple-get

* perf: drop simple-get

* feat: undici agent and socks

* fix: undici as dev dependency

* feat: require user passed proxy objects for http and ws

* chore: include undici for tests
2023-10-31 10:51:04 +01:00
Cas
7c845f030d
perf: use peer/lite (#474) 2023-06-16 23:05:28 +02:00
Cas
a12022ac2c
fix: imports (#471) 2023-06-05 22:56:44 +01:00
Cas
3b2dedb415
fix: replace simple-peer with maintained one (#466) 2023-05-27 18:14:52 +01:00
Cas
c99eb89208
fix: drop buffer (#465) 2023-05-26 17:54:30 +01:00
Cas
3f01c29122
perf: replace simple websocket with maintained one (#464) 2023-05-25 18:18:36 +01:00
Cas
e6d3189edf
feat: esm (#431)
BREAKING CHANGE: ESM only

* feat: esm

* fix: linter oops
2022-12-05 23:06:54 +01:00
Diego Rodríguez Baquero
8d54938f16
fix: revert #420 2022-05-10 19:56:27 -05:00
Lookis
f7928cfcc6
fix: connection leaks (#420) 2022-03-25 11:43:36 +03: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
Feross Aboukhadijeh
dd02cddcb8 ensure that 'peer' is emitted before 'connect' event fires
This is just a defensive code change to ensure that if signal() were somehow able to cause the peer to synchronously emit the 'connect' event that we won't cause the 'error' listener to be unregistered before 'peer' is emitted and the user has a chance to register their own 'error' listener
2021-04-12 16:13:35 -07:00
Feross Aboukhadijeh
ce8ea41f27 Lower the max number of WebRTC peers in an announce to 5 2021-04-12 15:54:01 -07: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
Feross Aboukhadijeh
eb69f8d7ab standard 2020-10-21 13:47:38 -10:00
Diego Rodríguez Baquero
51db46f4b2
increase reconnect variance and maximum 2020-03-29 13:34:50 -05:00
Eric Guan
fc2f84ad60 Check if socket is already connected in _openSocket(). Fixes https://github.com/webtorrent/webtorrent/issues/1245. 2019-08-14 14:20:18 -07:00
Diego Rodríguez Baquero
d410c6c088
Merge branch 'master' into modernize_lib_client 2018-11-22 11:00:48 -05:00
Diego Rodríguez Baquero
f7d3e9b7c0
Lower reconnect min and increase variance
This will allow servers to "breathe" when lots of peers are reconnecting.
2018-11-22 10:59:34 -05: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
Jimmy Wärting
65b2bdc804 removed xtend 2018-10-02 15:09:02 +02:00
John Hiesey
7ac0e9539a Expose WebSocketTracker socket pool
This is necessary for the Internet Archive superpeer implementation.
2018-08-09 15:28:13 -07:00
Feross Aboukhadijeh
63c953cbea dry some code 2017-04-07 18:24:16 -07:00
Feross Aboukhadijeh
48d0ea42ad Handle peer 'error' events correctly
Handle peer 'error' events that are fired *before* the peer is emitted
in a 'peer' event. Once the peer is emitted in a 'peer' event, then
it's the consumer's responsibility to listen for errors.

This fixes the most common error in WebTorrent Desktop according to our
telemetry.
2017-04-07 17:34:08 -07:00
Feross Aboukhadijeh
f65983e466 do not filter out extra keys from 'update' events 2017-03-10 13:38:04 -08:00
Yoann Ciabaud
8482c3af0a Add extra data on ws annouce event 2017-03-09 11:19:46 +01:00
Feross Aboukhadijeh
1dd1cc32da Revert "client: socketPool should not be shared across clients"
This reverts commit 3f3db7deb1.
2017-02-28 15:41:52 -08:00
Feross Aboukhadijeh
3f3db7deb1 client: socketPool should not be shared across clients
Caught this issue because of the new eviction tests. Essentially, this
change moves the socketPool into the client instance instead of a
reused variable at the module level.

When a client sends stop (or is evicted) the server will close the
websocket connection if that client is not in any other swarms (based
on peerId). However, if we are using a single socket for multiple
clients (as was the case before this commit), then other clients will
have their sockets unintentionally closed by the server.
2017-02-08 13:20:41 -08:00
Feross Aboukhadijeh
30b6f176b1 ws client: Don't include offers with 'completed' event
It's not necessary to include webrtc offers because the client is not
really looking for more peers when it has just completed the torrent.

Fewer WebRTC offers = less resource usage
2017-02-02 16:59:36 -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
b2cbfafae7 use 'once' on some event handlers 2016-09-16 07:49:29 -07:00
Feross Aboukhadijeh
a35f1f8178 replace hat with randombytes 2016-08-20 19:37:36 -07:00
Yoann Ciabaud
fa0b3e4535 Double default for webrtc trackers (now Chrome 51 is released) #152 2016-06-07 18:50:06 +02:00
Feross Aboukhadijeh
4431ae14ab Ensure client.destroy() callback is called when websocket pool used
Fixes #141
2016-03-31 21:49:18 -07:00
Feross Aboukhadijeh
c92b1714db Remove all Function.bind calls
For https://github.com/feross/webtorrent-desktop/issues/256
2016-03-28 23:38:23 -07:00
Feross Aboukhadijeh
721a7bea7c make server and client always send { action: 'announce' } 2016-03-23 22:04:07 -07:00
Feross Aboukhadijeh
4159d35cfc ws client: drop support for old tracker servers
Old tracker server versions don’t send data.action === ‘announce’
2016-03-23 21:26:52 -07:00
Feross Aboukhadijeh
89b9fb7f40 prevent two reconnect timers for running at same time 2016-03-18 23:14:48 -07:00
Feross Aboukhadijeh
49025c1320 reset self.peers = {} after destroy
Supersedes PR #135
2016-03-18 23:12:54 -07:00
Feross Aboukhadijeh
db868cac78 guard against self.socket being null 2016-03-18 23:12:28 -07:00
Feross Aboukhadijeh
51e2439333 Lower generated offer number to 5
Temporary mitigation for leak issue
2016-03-16 18:06:42 -07:00
Feross Aboukhadijeh
c181020937 client: Do not include WebRTC offers with 'stopped' announce event (fix #132) 2016-03-16 18:04:56 -07:00
Feross Aboukhadijeh
2c23ae7f00 client: websocket: Unref peer.trackerTimeout 2016-03-16 17:59:01 -07:00
Feross Aboukhadijeh
d079171044 Fixes for PR #129 2016-03-16 17:58:47 -07:00
Yoann Ciabaud
5127aad052 Make electron webrtc working in headless and stabdard fix 2016-03-16 17:33:07 -07:00
Yoann Ciabaud
d4c34c344e Destroy peers and tracker timeouts on destroy 2016-03-16 17:33:07 -07:00
Yoann Ciabaud
3252070328 Clear reconnect timeout on destroy 2016-03-16 17:33:06 -07:00