mirror of
https://github.com/fosrl/newt.git
synced 2025-05-13 05:30:39 +01:00
Fix remove target error
This commit is contained in:
parent
94a94613eb
commit
4df89c208b
2 changed files with 3 additions and 4 deletions
5
main.go
5
main.go
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue