Commit Graph

7 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
Neil Alexander
fd46eab3b9 Linter update & fixes 2026-01-18 14:51:52 +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
361b9fd6fc Update WebSocket dependency to new import path 2024-09-22 16:54:58 +01:00
Neil Alexander
b1283e15f6 Link state tracking tweaks and improved shutdown 2024-08-11 10:42:25 +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