From 795a46fd3ce47d63617479f35ca42ba8ffd04513 Mon Sep 17 00:00:00 2001 From: aceberg <1502200+aceberg@users.noreply.github.com> Date: Sun, 1 Sep 2024 21:53:19 +0700 Subject: [PATCH] Arp Strings --- internal/arp/arpscan.go | 11 ++++++----- internal/web/config.go | 9 +++++++++ internal/web/templates/config.html | 9 ++++++++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/internal/arp/arpscan.go b/internal/arp/arpscan.go index 7e03130..72360de 100644 --- a/internal/arp/arpscan.go +++ b/internal/arp/arpscan.go @@ -46,9 +46,9 @@ func scanStr(str string) string { func parseOutput(text, iface string) []models.Host { var foundHosts = []models.Host{} - perString := strings.Split(text, "\n") + p := strings.Split(text, "\n") - for _, host := range perString { + for _, host := range p { if host != "" { var oneHost models.Host p := strings.Split(host, " ") @@ -71,9 +71,9 @@ func Scan(ifaces, args string, strs []string) []models.Host { var foundHosts = []models.Host{} arpArgs = args - perString := strings.Split(ifaces, " ") + p := strings.Split(ifaces, " ") - for _, iface := range perString { + for _, iface := range p { slog.Debug("Scanning interface " + iface) text = scanIface(iface) slog.Debug("Found IPs: \n" + text) @@ -85,8 +85,9 @@ func Scan(ifaces, args string, strs []string) []models.Host { slog.Debug("Scanning string " + s) text = scanStr(s) slog.Debug("Found IPs: \n" + text) + p = strings.Split(s, " ") - foundHosts = append(foundHosts, parseOutput(text, "")...) + foundHosts = append(foundHosts, parseOutput(text, p[len(p)-1])...) } return foundHosts diff --git a/internal/web/config.go b/internal/web/config.go index 2312224..9cf8b0e 100644 --- a/internal/web/config.go +++ b/internal/web/config.go @@ -65,8 +65,17 @@ func saveSettingsHandler(c *gin.Context) { appConfig.HistInDB = false } + arpStrs := c.PostFormArray("arpstrs") + appConfig.ArpStrs = []string{} + for _, s := range arpStrs { + if s != "" { + appConfig.ArpStrs = append(appConfig.ArpStrs, s) + } + } + conf.Write(appConfig) + slog.Debug("ARP_STRS", "", appConfig.ArpArgs) slog.Info("Writing new config to " + appConfig.ConfPath) updateRoutines() // routines-upd.go diff --git a/internal/web/templates/config.html b/internal/web/templates/config.html index b73762e..746b7d4 100644 --- a/internal/web/templates/config.html +++ b/internal/web/templates/config.html @@ -1,5 +1,5 @@ {{ define "config.html" }} - +
@@ -70,6 +70,13 @@ Args for arp-scan + + Arp Strings + {{ range .Config.ArpStrs }} + {{ end }} + + + Log level