Skip to content

Commit 432e0e3

Browse files
committed
Move hole punch to dedicated port 51941, separate from WireGuard 51940
Hole punch (NAT traversal signaling) and WireGuard (encrypted tunnel) serve distinct roles and need separate sockets. HolePunch on 51941 collects client source ports for peer-to-peer NAT hole punching. WireGuard on 51940 handles encrypted tunnel traffic.
1 parent 030aa03 commit 432e0e3

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

projects/LemonadeNexus/src/main.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -633,18 +633,11 @@ int main(int argc, char* argv[]) {
633633
}
634634

635635
// ========================================================================
636-
// UDP Hole Punch
637-
// ========================================================================
638-
// HolePunch shares the UDP port with WireGuard. If WG is active on the
639-
// same port, WG handles the UDP socket — skip the standalone HolePunch bind.
640-
std::optional<nexus::network::HolePunchService> hole_punch;
641-
if (tunnel_bind_ip.empty()) {
642-
// No WG interface — start standalone HolePunch on the UDP port
643-
hole_punch.emplace(coordinator.io_context(), udp_port);
644-
hole_punch->start();
645-
} else {
646-
spdlog::info("HolePunch: WireGuard active on :{} — hole punch via WG keepalive", udp_port);
647-
}
636+
// UDP Hole Punch (separate port from WireGuard)
637+
// ========================================================================
638+
const uint16_t hole_punch_port = 51941;
639+
nexus::network::HolePunchService hole_punch{coordinator.io_context(), hole_punch_port};
640+
hole_punch.start();
648641

649642
// ========================================================================
650643
// Run -- blocks until SIGINT/SIGTERM
@@ -771,7 +764,7 @@ int main(int argc, char* argv[]) {
771764
if (acme_renewal_thread.joinable()) {
772765
acme_renewal_thread.join();
773766
}
774-
if (hole_punch) hole_punch->stop();
767+
hole_punch.stop();
775768
wireguard_service.stop();
776769
if (private_http_server) {
777770
private_http_server->stop();

0 commit comments

Comments
 (0)