Fix remove target error

This commit is contained in:
Owen Schwartz 2024-11-23 16:52:31 -05:00
parent 94a94613eb
commit 4df89c208b
No known key found for this signature in database
GPG key ID: 8271FDFFD9E0CCBD
2 changed files with 3 additions and 4 deletions

View file

@ -348,11 +348,10 @@ func updateTargets(pm *proxy.ProxyManager, action string, tunnelIP string, proto
if action == "add" {
target := parts[1] + ":" + parts[2]
pm.RemoveTarget(proto, tunnelIP, port) // remove it first incase this is an update. we are kind of using the internal port as the "targetId" in the proxy
pm.RemoveTarget(proto, tunnelIP, port) // remove it first in case this is an update. we are kind of using the internal port as the "targetId" in the proxy
pm.AddTarget(proto, tunnelIP, port, target)
// log the target
log.Printf("Added target: %s:%d -> %s", tunnelIP, port, target)
} else if action == "remove" {
log.Printf("Removing target with port %d", port)
pm.RemoveTarget(proto, tunnelIP, port)
}
}

View file

@ -46,7 +46,7 @@ func (pm *ProxyManager) RemoveTarget(protocol, listen string, port int) error {
target.Port == port &&
strings.ToLower(target.Protocol) == protocol {
// Signal the serving goroutine to stop
close(target.cancel)
// close(target.cancel)
// Close the appropriate listener/connection based on protocol
target.Lock()