From 71c23e989308e9e6246c36479e5c504a5825d20d Mon Sep 17 00:00:00 2001 From: Shinebayar Gansukh <3091558+shinebayar-g@users.noreply.github.com> Date: Wed, 16 Nov 2022 00:51:31 -0800 Subject: [PATCH] explicitly state inbound, outbound rules in logs --- ufwhandler/create.go | 6 +++--- ufwhandler/delete.go | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ufwhandler/create.go b/ufwhandler/create.go index 97f7c78..162b2d4 100644 --- a/ufwhandler/create.go +++ b/ufwhandler/create.go @@ -88,7 +88,7 @@ func CreateUfwRule(ch <-chan *types.ContainerJSON, c *cache.Cache) { for _, rule := range ufwRules { cmd := exec.Command("sudo", "ufw", "route", "allow", "proto", rule.Proto, "from", rule.CIDR, "to", containerIP, "port", rule.Port, "comment", containerName+":"+containerID+rule.Comment) - log.Println("ufw-docker-automated: Adding rule:", cmd) + log.Println("ufw-docker-automated: Adding inbound rule:", cmd) var stdout, stderr bytes.Buffer cmd.Stdout = &stdout @@ -154,7 +154,7 @@ func CreateUfwRule(ch <-chan *types.ContainerJSON, c *cache.Cache) { } else { cmd = exec.Command("sudo", "ufw", "route", "allow", "from", containerIP, "to", rule.CIDR, "port", rule.Port, "comment", containerName+":"+containerID+rule.Comment) } - log.Println("ufw-docker-automated: Adding rule:", cmd) + log.Println("ufw-docker-automated: Adding outbound rule:", cmd) var stdout, stderr bytes.Buffer cmd.Stdout = &stdout @@ -173,7 +173,7 @@ func CreateUfwRule(ch <-chan *types.ContainerJSON, c *cache.Cache) { // Handle deny all out cmd := exec.Command("sudo", "ufw", "route", "deny", "from", containerIP, "to", "any", "comment", containerName+":"+containerID) - log.Println("ufw-docker-automated: Adding rule:", cmd) + log.Println("ufw-docker-automated: Adding outbound rule:", cmd) var stdout, stderr bytes.Buffer cmd.Stdout = &stdout diff --git a/ufwhandler/delete.go b/ufwhandler/delete.go index 4f66e75..70b05fb 100644 --- a/ufwhandler/delete.go +++ b/ufwhandler/delete.go @@ -16,7 +16,7 @@ func DeleteUfwRule(containerID <-chan string, c *cache.Cache) { // Handle inbound rules for _, rule := range container.UfwInboundRules { cmd := exec.Command("sudo", "ufw", "route", "delete", "allow", "proto", rule.Proto, "from", rule.CIDR, "to", container.IPAddress, "port", rule.Port, "comment", container.Name+":"+id+rule.Comment) - log.Println("ufw-docker-automated: Deleting rule:", cmd) + log.Println("ufw-docker-automated: Deleting inbound rule:", cmd) var stdout, stderr bytes.Buffer cmd.Stdout = &stdout @@ -37,7 +37,7 @@ func DeleteUfwRule(containerID <-chan string, c *cache.Cache) { } else { cmd = exec.Command("sudo", "ufw", "route", "delete", "allow", "from", container.IPAddress, "to", rule.CIDR, "port", rule.Port, "comment", container.Name+":"+id+rule.Comment) } - log.Println("ufw-docker-automated: Deleting rule:", cmd) + log.Println("ufw-docker-automated: Deleting outbound rule:", cmd) var stdout, stderr bytes.Buffer cmd.Stdout = &stdout @@ -52,7 +52,7 @@ func DeleteUfwRule(containerID <-chan string, c *cache.Cache) { } // Handle deny all out cmd := exec.Command("sudo", "ufw", "route", "delete", "deny", "from", container.IPAddress, "to", "any", "comment", container.Name+":"+id) - log.Println("ufw-docker-automated: Deleting rule:", cmd) + log.Println("ufw-docker-automated: Deleting outbound rule:", cmd) var stdout, stderr bytes.Buffer cmd.Stdout = &stdout @@ -65,7 +65,7 @@ func DeleteUfwRule(containerID <-chan string, c *cache.Cache) { log.Println("ufw:", stdout.String()) } } else { - log.Println("ufw-docker-automated: Container information not found") + log.Println("ufw-docker-automated: Container information not found in cache.") continue } }