mirror of
https://github.com/fosrl/newt.git
synced 2026-03-04 09:46:44 +00:00
Resolve some basic comments
This commit is contained in:
@@ -75,7 +75,6 @@ func IsWithinHostNetwork(socketPath string, targetAddress string, targetPort int
|
|||||||
// Always enforce network validation
|
// Always enforce network validation
|
||||||
containers, err := ListContainers(socketPath, true)
|
containers, err := ListContainers(socketPath, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +141,7 @@ func ListContainers(socketPath string, enforceNetworkValidation bool) ([]Contain
|
|||||||
|
|
||||||
hostContainer, err := getHostContainer(ctx, cli)
|
hostContainer, err := getHostContainer(ctx, cli)
|
||||||
if enforceNetworkValidation && err != nil {
|
if enforceNetworkValidation && err != nil {
|
||||||
return nil, fmt.Errorf("network validation enforced, cannot validate due to: %v", err)
|
return nil, fmt.Errorf("network validation enforced, cannot validate due to: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We may not be able to get back host container in scenarios like running the container in network mode 'host'
|
// We may not be able to get back host container in scenarios like running the container in network mode 'host'
|
||||||
|
|||||||
8
main.go
8
main.go
@@ -792,7 +792,11 @@ func updateTargets(pm *proxy.ProxyManager, action string, tunnelIP string, proto
|
|||||||
|
|
||||||
if action == "add" {
|
if action == "add" {
|
||||||
targetAddress := parts[1]
|
targetAddress := parts[1]
|
||||||
targetPort, _ := strconv.Atoi(parts[2])
|
targetPort, err := strconv.Atoi(parts[2])
|
||||||
|
if err != nil {
|
||||||
|
logger.Info("Invalid target port: %s", parts[2])
|
||||||
|
continue
|
||||||
|
}
|
||||||
combinedAddress := targetAddress + ":" + parts[2]
|
combinedAddress := targetAddress + ":" + parts[2]
|
||||||
|
|
||||||
// Call updown script if provided
|
// Call updown script if provided
|
||||||
@@ -807,7 +811,7 @@ func updateTargets(pm *proxy.ProxyManager, action string, tunnelIP string, proto
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only remove the specific target if it exists
|
// Only remove the specific target if it exists
|
||||||
err := pm.RemoveTarget(proto, tunnelIP, port)
|
err = pm.RemoveTarget(proto, tunnelIP, port)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Ignore "target not found" errors as this is expected for new targets
|
// Ignore "target not found" errors as this is expected for new targets
|
||||||
if !strings.Contains(err.Error(), "target not found") {
|
if !strings.Contains(err.Error(), "target not found") {
|
||||||
|
|||||||
Reference in New Issue
Block a user