Commit Graph

185 Commits

Author SHA1 Message Date
Ascii Moth
2cc8e7506e Allow WebSocket listeners to configure browser origins (#1342)
Adds an `origin` query option for `ws://` listener URLs so peer
operators can
explicitly allow browser-hosted WebSocket clients.

- `ws://host:port` keeps the existing same-origin behavior
- `ws://host:port?origin=demo.example.org` allows that origin host
- `ws://host:port?origin=https://demo.example.org` allows that scheme
and host
- repeated `origin=` parameters allow multiple origin patterns
- `origin=*` intentionally disables origin verification for public
WebSocket
  peer endpoints

## Problem
I've implemented a WASM based browser demo yggdrasil node to found that
it
cannot directly dial any existing public `ws://` or `wss://` peers.

Browsers always include an `Origin` header in WebSocket handshakes, and
the
JavaScript `WebSocket()` constructor does not allow applications to
override or
remove arbitrary handshake headers.  
This means a browser demo served from an origin such as
`http://127.0.0.1:8000` cannot connect to a public peer whose WebSocket
server
only accepts same-origin handshakes.
2026-05-12 21:40:59 +01:00
Alex Melan
bc72b106b7 fix: reject malformed network input in parsers (#1340)
## Summary
- validate handshake metadata field lengths before fixed-size reads
- reject truncated multicast advertisements before slicing the hash
payload
- add regression tests for malformed and truncated input

## Why
Both parsers currently trust length information from the incoming
payload a bit too much. Malformed network input can reach fixed-size
reads/slices and panic the process instead of being rejected cleanly.

## Testing
- go test ./...
2026-04-11 12:04:12 +01:00
Neil Alexander
82df3ea9a5 Prevent adding empty peers at runtime
Fixes #1182
2026-02-23 22:55:06 +00:00
Andrei Tregubov
9184cd23e5 Fix outbound link-local connections on mobile (#1300) 2026-01-18 19:12:31 +00:00
Neil Alexander
9e781cc912 Fix lint error 2026-01-18 15:04:28 +00:00
Neil Alexander
fd46eab3b9 Linter update & fixes 2026-01-18 14:51:52 +00:00
Neil Alexander
24482b7dbe Run go fix, corrects mostly build tags 2026-01-18 14:47:18 +00:00
Sergey Alirzaev
33831f606f core: removed unused addPeerTimer code
Resolves #1279
2026-01-18 11:57:27 +00:00
Neil Alexander
b43e213c32 Don't re-attempt connections when detecting a connection to self
Closes #1286.
2025-11-11 23:18:56 +00:00
Neil Alexander
56044b822b Fix build issues from QUIC dependency update 2025-11-10 19:48:01 +00:00
Neil Alexander
ffc0dc92e0 Reduce minimum maxbackoff to 5 seconds 2025-06-22 16:37:34 +01:00
Neil Alexander
69451fe969 Specify TLS 1.2-TLS 1.3 supported range for client connections
Should fix #1208.
2024-12-12 19:07:55 +00:00
Neil Alexander
d3b4de46ea Improvements to how link shutdowns are handled 2024-11-23 13:43:34 +00:00
Neil Alexander
b98f98318f Tweaks to link handling 2024-11-22 09:44:30 +00:00
Neil
9398cae230 Expose download/upload rate per peer (#1206) 2024-11-19 08:42:27 +00:00
Neil Alexander
67ec5a92b3 Fix some lint issues 2024-11-17 21:29:26 +00:00
Neil Alexander
42873be09b Reusable peer lookup/dial logic 2024-11-17 21:14:54 +00:00
Neil Alexander
eef613993f Raise link error when SNI supplied on unsupported link type
Closes #1196
2024-10-27 21:06:56 +00:00
Neil Alexander
6d5243bd9a Add unit test for AllowedPublicKeys 2024-09-29 22:04:41 +01:00
Neil Alexander
377bc664c9 The AllowedPublicKeys option should not apply to multicast listeners
Another fix for #1141.
2024-09-29 21:38:56 +01:00
Neil Alexander
d1b849588f Fix bug where ephemeral links would try to reconnect in a fast loop
Helps #1141, although not a complete solution.
2024-09-29 21:24:39 +01:00
Neil Alexander
c00779c7d3 Multicast interface detection and shutdown tweaks
May help with #1173.
2024-09-29 20:58:10 +01:00
Neil Alexander
e138fa679c Fix link panic when shutting down (closes #1168) 2024-09-22 17:05:25 +01:00
Neil Alexander
361b9fd6fc Update WebSocket dependency to new import path 2024-09-22 16:54:58 +01:00
Neil
c4b29b735c Link costing based on average RTT (#1171)
This PR updates Ironwood to include the new RTT-based link costing and
updates `yggdrasilctl` to report the cost in `getPeers`.

Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
2024-09-21 22:05:23 +00:00
Neil Alexander
b1283e15f6 Link state tracking tweaks and improved shutdown 2024-08-11 10:42:25 +01:00
Neil Alexander
9950d1225d Improve link and handshake errors 2024-08-01 21:53:48 +01:00
Vasyl Gello
5ea16e63a1 Implement websocket (ws:// and wss://) links (#1152)
ws:// can be listened and dialed
wss:// is a convenience link for ws:// that supports dialing to ws://
peer.

---------

Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
2024-07-23 22:58:11 +01:00
Neil Alexander
04c0acf71b Various clean-ups 2024-07-20 12:31:58 +01:00
Neil Alexander
8ecc402d7c Allow multiple connections to the same link-local address
Note that this may mean that currently we end up with two links to each multicast-discovered peer, one incoming and one outgoing
2024-07-20 11:31:08 +01:00
Neil
f788a18bef Measure RTT, report in getPeers (#1143)
Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
2024-05-30 22:46:06 +01:00
Paul Donald
f56f9c124c Minor Fixes (#1107)
* Minor comment fixes.

* Optimize PeerEntry for memory efficiency

* Improve NodeConfig for memory alignment
2024-05-27 21:57:28 +01:00
Arceliar
6cbe56adfe fix incorrect pool use 2024-05-25 06:15:36 -05:00
Neil
180d7bf499 Adjust default backoff max to just over 1 hour, add ?maxbackoff= peer option (#1124)
Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
2024-01-15 23:09:07 +00:00
Neil Alexander
1e9a59edf9 Update behaviour in QUIC listener handler 2024-01-05 11:45:20 +00:00
Neil Alexander
3dfa6d0cc9 Validate public key lengths on debug_ API endpoints (fixes #1113) 2023-12-03 17:55:12 +00:00
Neil Alexander
6b6cd0bed5 Fix PPROFLISTEN 2023-11-28 13:24:54 +00:00
Neil Alexander
fef553ed18 Tweak logging 2023-11-26 16:28:48 +00:00
Neil Alexander
39c4b24395 Don't use 0-RTT for QUIC 2023-11-26 16:19:00 +00:00
Neil Alexander
a0b3897278 Cap link backoff at roughly 4.5 hours 2023-11-21 23:54:27 +00:00
Neil Alexander
7aca869170 Tweak backoff success handling 2023-11-21 10:35:17 +00:00
Neil
0346af46da Don't panic when connect returns nil (fixes #1086) (#1089)
* Don't panic when connect returns `nil` (fixes #1086)

It isn't clear to me why this would happen but let's guard the condition anyway.

* Log inconsistent error state

---------

Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
2023-11-04 18:42:42 +00:00
Neil
93a5adfd18 Add sockstls:// (#1090)
Closes #1087.

Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
2023-11-04 17:57:15 +00:00
Neil
ddb75700a0 Report errors during handshake stage (#1091)
Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
2023-11-04 17:57:04 +00:00
Neil Alexander
e41b838d8f Don't panic at startup when duplicate peers are configured
Fixes #1077
2023-10-28 21:34:15 +01:00
Neil Alexander
094f80f39c Fix RetryPeersNow, move startup logging, don't set TUN address if not available 2023-10-22 15:51:30 +01:00
Neil Alexander
955aa4af79 Remove unnecessary pprof log line 2023-10-22 10:29:19 +01:00
Neil Alexander
73c6c25bd9 Restore removePeer method 2023-10-22 10:27:41 +01:00
Neil Alexander
80e56eafcd Allow PPROFLISTEN on all builds 2023-10-21 21:36:28 +01:00
Neil Alexander
bcd80b043f Don't tightloop when a listener can no longer accept connections 2023-10-17 21:41:21 +01:00