[PR #112] feat: websocket relay #289

Open
opened 2026-04-19 18:29:39 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/fosrl/olm/pull/112
Author: @nicholasliverett
Created: 4/11/2026
Status: 🔄 Open

Base: devHead: feature-websocket-relay


📝 Commits (10+)

  • 9b870b6 Add WebSocket relay bind and relay handling
  • 9e08286 Add TCP fallback timers and websocket relay switch
  • f487680 Working jit with chain ids
  • cc18a9e Handle canceling sends for relay
  • d5ce777 Make chainId in relay message bckwd compat
  • baf01c3 Alias jit handler
  • 9927402 Handle no chainId case
  • f4adafd Add WebSocket relay bind and relay handling
  • cc6ad2d Add TCP fallback timers and websocket relay switch
  • 8ae1d09 Add WebSocket relay configuration and handling

📊 Changes

12 files changed (+830 additions, -57 deletions)

View changed files

📝 config.go (+16 -0)
📝 main.go (+1 -0)
📝 olm/connect.go (+33 -3)
📝 olm/olm.go (+71 -12)
📝 olm/peer.go (+90 -3)
olm/relay_switch.go (+208 -0)
📝 olm/types.go (+1 -0)
olm/ws_relay_bind.go (+261 -0)
📝 peers/manager.go (+93 -17)
📝 peers/monitor/monitor.go (+9 -3)
📝 peers/types.go (+1 -0)
📝 websocket/client.go (+46 -19)

📄 Description

Community Contribution License Agreement

By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.

What does this PR do?

You can read about the discussion related to this topic here: Transport flexiblity
As discussed, in more restrictive networks UDP connections may be completely blocked and clients are unable to connect to resources. To get around this we use a commonly allowed protocol: HTTPS, or more specifically websockets.

Description

OLM will try its normal direct UDP/hole punch and UDP relay. If OLM receives a relayEndpointWss (sent with relay info) it starts an 8s timer. Once that timer is up it switches from the shared UDP bind to a websocket bind. Traffic then flows OLM-(wss)->Pangolin-(tcp relay port)->Gerbil->Newt. Now since we are using a websocket the RTT is more than just raw wireguard, and it might be something to look into.

Also added a --websocket-relay flag to use the websocket relay without the timer or trying UDP. So it forces the websocket relay at first connect.

Note: the only thing changed is olm's connection to the gerbil relay, to newt nothing changes.

How to test?

Setup Pangolin, Gerbil, and Olm from companion PRs mentioned below and regular newt. Have to spin up pangolin, gerbil, newt, and olm to test this. Ideally checking, regular connections, restricted networks, and the force relay flag

Companion PRs

Gerbil: fosrl/gerbil#77
Pangolin: fosrl/pangolin#2831


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/fosrl/olm/pull/112 **Author:** [@nicholasliverett](https://github.com/nicholasliverett) **Created:** 4/11/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `feature-websocket-relay` --- ### 📝 Commits (10+) - [`9b870b6`](https://github.com/fosrl/olm/commit/9b870b689488fb78a39f3295b96b2c0c2aa0e809) Add WebSocket relay bind and relay handling - [`9e08286`](https://github.com/fosrl/olm/commit/9e082861be62493477c77019cbc50e6b390e386b) Add TCP fallback timers and websocket relay switch - [`f487680`](https://github.com/fosrl/olm/commit/f4876809a1593835c96f1712f38853761ca0dbdd) Working jit with chain ids - [`cc18a9e`](https://github.com/fosrl/olm/commit/cc18a9ef6c5945221e77286c35d67033cd177197) Handle canceling sends for relay - [`d5ce777`](https://github.com/fosrl/olm/commit/d5ce7779b98bd9591e14dc7c4fde5250084e33fb) Make chainId in relay message bckwd compat - [`baf01c3`](https://github.com/fosrl/olm/commit/baf01c371334c5005f3e65778ff40ec924397b06) Alias jit handler - [`9927402`](https://github.com/fosrl/olm/commit/9927402f2912b128908fca1d0f3debf156a1add6) Handle no chainId case - [`f4adafd`](https://github.com/fosrl/olm/commit/f4adafd90b759ca0d4adaabd01129bb153cbb3f4) Add WebSocket relay bind and relay handling - [`cc6ad2d`](https://github.com/fosrl/olm/commit/cc6ad2de47f3fb94e54e5295bc0e0249b435899d) Add TCP fallback timers and websocket relay switch - [`8ae1d09`](https://github.com/fosrl/olm/commit/8ae1d09b86343fbcdbed9265aaf8853fc22323f9) Add WebSocket relay configuration and handling ### 📊 Changes **12 files changed** (+830 additions, -57 deletions) <details> <summary>View changed files</summary> 📝 `config.go` (+16 -0) 📝 `main.go` (+1 -0) 📝 `olm/connect.go` (+33 -3) 📝 `olm/olm.go` (+71 -12) 📝 `olm/peer.go` (+90 -3) ➕ `olm/relay_switch.go` (+208 -0) 📝 `olm/types.go` (+1 -0) ➕ `olm/ws_relay_bind.go` (+261 -0) 📝 `peers/manager.go` (+93 -17) 📝 `peers/monitor/monitor.go` (+9 -3) 📝 `peers/types.go` (+1 -0) 📝 `websocket/client.go` (+46 -19) </details> ### 📄 Description ## Community Contribution License Agreement By creating this pull request, I grant the project maintainers an unlimited, perpetual license to use, modify, and redistribute these contributions under any terms they choose, including both the AGPLv3 and the Fossorial Commercial license terms. I represent that I have the right to grant this license for all contributed content. ## What does this PR do? You can read about the discussion related to this topic here: [Transport flexiblity](https://github.com/orgs/fosrl/discussions/2076) As discussed, in more restrictive networks UDP connections may be completely blocked and clients are unable to connect to resources. To get around this we use a commonly allowed protocol: HTTPS, or more specifically websockets. ## Description OLM will try its normal direct UDP/hole punch and UDP relay. If OLM receives a relayEndpointWss (sent with relay info) it starts an 8s timer. Once that timer is up it switches from the shared UDP bind to a websocket bind. Traffic then flows OLM-(wss)->Pangolin-(tcp relay port)->Gerbil->Newt. Now since we are using a websocket the RTT is more than just raw wireguard, and it might be something to look into. Also added a `--websocket-relay` flag to use the websocket relay without the timer or trying UDP. So it forces the websocket relay at first connect. Note: the only thing changed is olm's connection to the gerbil relay, to newt nothing changes. ## How to test? Setup Pangolin, Gerbil, and Olm from companion PRs mentioned below and regular newt. Have to spin up pangolin, gerbil, newt, and olm to test this. Ideally checking, regular connections, restricted networks, and the force relay flag ## Companion PRs **Gerbil**: [fosrl/gerbil#77](https://github.com/fosrl/gerbil/pull/77) **Pangolin**: [fosrl/pangolin#2831](https://github.com/fosrl/pangolin/pull/2831) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-19 18:29:39 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/olm#289