From bed7aa97773ab054f5b1e7c0d9fff8f7a84969b0 Mon Sep 17 00:00:00 2001 From: nhas Date: Fri, 1 Nov 2024 02:34:39 +1300 Subject: [PATCH] Readd functionality for checking routes --- adminui/diagnostics.go | 4 +--- internal/router/debug.go | 8 +++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/adminui/diagnostics.go b/adminui/diagnostics.go index 26ac47a2..8b1134c2 100644 --- a/adminui/diagnostics.go +++ b/adminui/diagnostics.go @@ -9,8 +9,6 @@ import ( "net/http" "strconv" "time" - - "github.com/NHAS/wag/internal/router" ) func (au *AdminUI) firewallDiagnositicsUI(w http.ResponseWriter, r *http.Request) { @@ -193,7 +191,7 @@ func (au *AdminUI) firewallCheckTest(w http.ResponseWriter, r *http.Request) { var decision string if len(inputErrors) == 0 { - checkerDecision, err := router.CheckRoute(address, targetIP, proto, port) + checkerDecision, err := au.firewall.CheckRoute(address, targetIP, proto, port) if err != nil { decision = err.Error() } else { diff --git a/internal/router/debug.go b/internal/router/debug.go index befa93de..e3bc264f 100644 --- a/internal/router/debug.go +++ b/internal/router/debug.go @@ -10,7 +10,7 @@ import ( "golang.org/x/net/ipv4" ) -func CheckRoute(device string, ip net.IP, proto string, port int) (decision string, err error) { +func (f *Firewall) CheckRoute(device string, ip net.IP, proto string, port int) (decision string, err error) { deviceIP := net.ParseIP(device) @@ -23,9 +23,11 @@ func CheckRoute(device string, ip net.IP, proto string, port int) (decision stri port = 0 } - createPacket(deviceIP, ip, pro, port) + if f.Test(createPacket(deviceIP, ip, pro, port)) { + return "passed", nil + } - return "unknown", nil + return "dropped", nil }