Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@danohn
Copy link
Contributor

@danohn danohn commented Aug 29, 2025

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!
    

@danohn danohn changed the base branch from main to dev August 29, 2025 06:33
@oschwartz10612 oschwartz10612 merged commit 456c66e into fosrl:dev Aug 30, 2025
1 check passed
@oschwartz10612
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Olm fails to establish direct connection due to UDP port conflict during NAT holepunching on macOS

2 participants