feat: add logging to Docker and iptables operations, fix iptables path
continuous-integration/drone/push Build is passing

- Create /var/log/network-go directory in Dockerfile for log storage
- Add comprehensive logging to Docker client creation, network management, and container operations
- Add logging to iptables rule management (list, delete, etc.)
- Fix iptables executable path resolution in deleteMatchingLinesInContainer to use configured binary path
This commit is contained in:
gyurix
2026-06-15 17:05:53 +02:00
parent 3172023254
commit 27607d1a2e
8 changed files with 401 additions and 66 deletions
+7 -6
View File
@@ -3,9 +3,10 @@ package watcher
import (
"crypto/md5"
"fmt"
"log"
"os"
"time"
"firewall_containers/network-go/logger"
)
// FileWatcher periodically checks a file for changes using MD5 hash
@@ -42,7 +43,7 @@ func (fw *FileWatcher) Start() {
// Compute initial hash
hash, err := fw.hashFile()
if err != nil {
log.Printf("WATCHER: initial hash computation failed for %s: %v", fw.path, err)
logger.Warn("WATCHER: initial hash computation failed for %s: %v", fw.path, err)
} else {
fw.lastHash = hash
}
@@ -51,22 +52,22 @@ func (fw *FileWatcher) Start() {
ticker := time.NewTicker(fw.period)
defer ticker.Stop()
log.Printf("WATCHER: started watching %s every %s", fw.path, fw.period)
logger.Info("WATCHER: started watching %s every %s", fw.path, fw.period)
for {
select {
case <-fw.stopCh:
log.Printf("WATCHER: stopped watching %s", fw.path)
logger.Info("WATCHER: stopped watching %s", fw.path)
return
case <-ticker.C:
hash, err := fw.hashFile()
if err != nil {
log.Printf("WATCHER: failed to hash %s: %v", fw.path, err)
logger.Warn("WATCHER: failed to hash %s: %v", fw.path, err)
continue
}
if hash != fw.lastHash {
log.Printf("WATCHER: detected change in %s", fw.path)
logger.Info("WATCHER: detected change in %s", fw.path)
fw.lastHash = hash
if fw.onChange != nil {
fw.onChange()