[PR #17] [MERGED] Fix UDP port conflict during NAT holepunching on macOS #31

Closed
opened 2025-11-19 07:04:36 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/fosrl/olm/pull/17
Author: @danohn
Created: 8/29/2025
Status: Merged
Merged: 8/30/2025
Merged by: @oschwartz10612

Base: devHead: main


📝 Commits (2)

  • 0765b4d Update wait timer to 200ms
  • 07d5ebd Update wait time to 500ms

📊 Changes

1 file changed (+2 additions, -1 deletions)

View changed files

📝 main.go (+2 -1)

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

Description

Fixes #16 - UDP port conflict during NAT holepunching on macOS

This PR resolves a race condition where the holepunch goroutine was still holding a UDP port when WireGuard attempted to bind to it, causing "address already in use" errors and forcing unnecessary fallbacks to relay mode.

The fix increases the delay after close(stopHolepunch) from 10ms to 500ms in main.go, giving macOS sufficient time to release the UDP port before WireGuard initialization.

How to test?

  1. Run olm with holepunch enabled on macOS:

    sudo -E olm --holepunch
    
  2. Check the logs - you should see successful connection without port errors:

    INFO: WireGuard device created.
    INFO: Peer 1 is now connected (RTT: ~70ms)
    
  3. Verify direct connection (not relay) with:

    sudo wg show
    

    The endpoint should show the peer's actual IP (e.g., 1.2.3.4:65456) not the relay server IP.

  4. Without this fix, you would see:

    ERROR: Failed to bring up WireGuard device: listen udp4 :XXXXX: bind: address already in use
    INFO: Adjusted peer 1 to point to relay!
    

🔄 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/17 **Author:** [@danohn](https://github.com/danohn) **Created:** 8/29/2025 **Status:** ✅ Merged **Merged:** 8/30/2025 **Merged by:** [@oschwartz10612](https://github.com/oschwartz10612) **Base:** `dev` ← **Head:** `main` --- ### 📝 Commits (2) - [`0765b4d`](https://github.com/fosrl/olm/commit/0765b4daca70bef576d154e6f293f5c7908bc755) Update wait timer to 200ms - [`07d5ebd`](https://github.com/fosrl/olm/commit/07d5ebdde1128702b8e6bd82b949b498fc569328) Update wait time to 500ms ### 📊 Changes **1 file changed** (+2 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `main.go` (+2 -1) </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. ## Description Fixes #16 - UDP port conflict during NAT holepunching on macOS This PR resolves a race condition where the holepunch goroutine was still holding a UDP port when WireGuard attempted to bind to it, causing "address already in use" errors and forcing unnecessary fallbacks to relay mode. The fix increases the delay after `close(stopHolepunch)` from 10ms to 500ms in `main.go`, giving macOS sufficient time to release the UDP port before WireGuard initialization. ## How to test? 1. Run olm with holepunch enabled on macOS: ```bash sudo -E olm --holepunch ``` 2. Check the logs - you should see successful connection without port errors: ``` INFO: WireGuard device created. INFO: Peer 1 is now connected (RTT: ~70ms) ``` 3. Verify direct connection (not relay) with: ```bash sudo wg show ``` The endpoint should show the peer's actual IP (e.g., `1.2.3.4:65456`) not the relay server IP. 4. Without this fix, you would see: ``` ERROR: Failed to bring up WireGuard device: listen udp4 :XXXXX: bind: address already in use INFO: Adjusted peer 1 to point to relay! ``` --- <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 2025-11-19 07:04:36 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/olm#31