[PR #122] [CLOSED] Always re-register on WebSocket reconnect #2088

Closed
opened 2026-06-17 03:01:29 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/fosrl/olm/pull/122
Author: @rinseaid
Created: 5/14/2026
Status: Closed

Base: mainHead: fix/re-register-on-reconnect


📝 Commits (1)

  • 7f8a10b Always re-register on WebSocket reconnect

📊 Changes

1 file changed (+22 additions, -24 deletions)

View changed files

📝 olm/olm.go (+22 -24)

📄 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.

Preface

This PR was developed with Claude Code (claude-opus-4-6). I identified the bug through live debugging of a broken Olm tunnel after a Pangolin server restart, traced the root cause through the code, and directed the fix. Claude wrote the patch. I reviewed and validated all changes.

Description

After a Pangolin server restart (or any WebSocket disconnect/reconnect cycle), Olm clients fail to re-register with the server, leaving the WireGuard tunnel broken. The user must manually disconnect and reconnect to restore connectivity.

Root cause: The OnConnect callback in StartTunnel checks o.registered and returns early if it is true. However, o.registered is only reset to false by StopTunnel(). When the WebSocket reconnects (server restart, network interruption), the callback fires again but o.registered is still true from the previous connection, so registration is skipped entirely.

The server has lost all in-memory state (including clientConfigVersions and the client's WireGuard peer entry), so the client must re-register to restore the tunnel. Skipping registration leaves the client in a state where it believes it is registered but the server has no record of it.

Fix: Remove the o.registered early-return guard and always re-register on reconnect. Cancel any in-flight SendMessageInterval from a previous connection before starting a new one.

Related issues: #7, #72, #108

Companion PR: fosrl/pangolin#3068

How to test?

  1. Connect an Olm client to a Pangolin server with at least one site configured.
  2. Verify the tunnel works (access a resource through the tunnel).
  3. Restart the Pangolin server (docker restart pangolin).
  4. Wait for the Olm client to reconnect (watch logs for "Websocket Connected").
  5. Before fix: Client logs "Already registered, skipping registration" and the tunnel is broken.
  6. After fix: Client re-registers, receives site configurations, and the tunnel recovers automatically.

🔄 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/122 **Author:** [@rinseaid](https://github.com/rinseaid) **Created:** 5/14/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/re-register-on-reconnect` --- ### 📝 Commits (1) - [`7f8a10b`](https://github.com/fosrl/olm/commit/7f8a10bb42ce36343c254afab63e6dca84217f8b) Always re-register on WebSocket reconnect ### 📊 Changes **1 file changed** (+22 additions, -24 deletions) <details> <summary>View changed files</summary> 📝 `olm/olm.go` (+22 -24) </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. ### Preface This PR was developed with Claude Code (claude-opus-4-6). I identified the bug through live debugging of a broken Olm tunnel after a Pangolin server restart, traced the root cause through the code, and directed the fix. Claude wrote the patch. I reviewed and validated all changes. ## Description After a Pangolin server restart (or any WebSocket disconnect/reconnect cycle), Olm clients fail to re-register with the server, leaving the WireGuard tunnel broken. The user must manually disconnect and reconnect to restore connectivity. **Root cause:** The `OnConnect` callback in `StartTunnel` checks `o.registered` and returns early if it is `true`. However, `o.registered` is only reset to `false` by `StopTunnel()`. When the WebSocket reconnects (server restart, network interruption), the callback fires again but `o.registered` is still `true` from the previous connection, so registration is skipped entirely. The server has lost all in-memory state (including `clientConfigVersions` and the client's WireGuard peer entry), so the client *must* re-register to restore the tunnel. Skipping registration leaves the client in a state where it believes it is registered but the server has no record of it. **Fix:** Remove the `o.registered` early-return guard and always re-register on reconnect. Cancel any in-flight `SendMessageInterval` from a previous connection before starting a new one. Related issues: #7, #72, #108 Companion PR: fosrl/pangolin#3068 ## How to test? 1. Connect an Olm client to a Pangolin server with at least one site configured. 2. Verify the tunnel works (access a resource through the tunnel). 3. Restart the Pangolin server (`docker restart pangolin`). 4. Wait for the Olm client to reconnect (watch logs for "Websocket Connected"). 5. **Before fix:** Client logs "Already registered, skipping registration" and the tunnel is broken. 6. **After fix:** Client re-registers, receives site configurations, and the tunnel recovers automatically. --- <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-06-17 03:01:29 -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#2088