Clear out the hp manager

Former-commit-id: 5af1b63558
This commit is contained in:
Owen
2025-11-18 21:16:42 -05:00
parent d7345c7dbd
commit 930bf7e0f2

View File

@@ -273,7 +273,6 @@ func StartTunnel(config TunnelConfig) {
} }
// Create shared UDP socket for both holepunch and WireGuard // Create shared UDP socket for both holepunch and WireGuard
if sharedBind == nil {
sourcePort, err := util.FindAvailableUDPPort(49152, 65535) sourcePort, err := util.FindAvailableUDPPort(49152, 65535)
if err != nil { if err != nil {
logger.Error("Error finding available port: %v", err) logger.Error("Error finding available port: %v", err)
@@ -302,12 +301,9 @@ func StartTunnel(config TunnelConfig) {
sharedBind.AddRef() sharedBind.AddRef()
logger.Info("Created shared UDP socket on port %d (refcount: %d)", sourcePort, sharedBind.GetRefCount()) logger.Info("Created shared UDP socket on port %d (refcount: %d)", sourcePort, sharedBind.GetRefCount())
}
// Create the holepunch manager // Create the holepunch manager
if holePunchManager == nil {
holePunchManager = holepunch.NewManager(sharedBind, id, "olm") holePunchManager = holepunch.NewManager(sharedBind, id, "olm")
}
olm.RegisterHandler("olm/wg/holepunch/all", func(msg websocket.WSMessage) { olm.RegisterHandler("olm/wg/holepunch/all", func(msg websocket.WSMessage) {
logger.Debug("Received message: %v", msg.Data) logger.Debug("Received message: %v", msg.Data)
@@ -828,6 +824,7 @@ func Close() {
// Stop hole punch manager // Stop hole punch manager
if holePunchManager != nil { if holePunchManager != nil {
holePunchManager.Stop() holePunchManager.Stop()
holePunchManager = nil
} }
if stopPing != nil { if stopPing != nil {
@@ -853,10 +850,12 @@ func Close() {
uapiListener.Close() uapiListener.Close()
uapiListener = nil uapiListener = nil
} }
if dev != nil { if dev != nil {
dev.Close() // This will call sharedBind.Close() which releases WireGuard's reference dev.Close() // This will call sharedBind.Close() which releases WireGuard's reference
dev = nil dev = nil
} }
// Close TUN device // Close TUN device
if tdev != nil { if tdev != nil {
tdev.Close() tdev.Close()