Skip to content

Commit

Permalink
Readd functionality for checking routes
Browse files Browse the repository at this point in the history
  • Loading branch information
NHAS committed Oct 31, 2024
1 parent d214440 commit bed7aa9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 1 addition & 3 deletions adminui/diagnostics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 5 additions & 3 deletions internal/router/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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

}

Expand Down

0 comments on commit bed7aa9

Please sign in to comment.