diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c860a9..3963fce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Change Log All notable changes to this project will be documented in this file. +## [v2.0.1] - 2024-08-31 +### Changed + ## [v2.0.0] - 2024-08-30 ### Added - API diff --git a/internal/arp/arpscan.go b/internal/arp/arpscan.go index 62ae931..7e03130 100644 --- a/internal/arp/arpscan.go +++ b/internal/arp/arpscan.go @@ -16,7 +16,7 @@ func scanIface(iface string) string { var cmd *exec.Cmd if arpArgs != "" { - cmd = exec.Command("arp-scan", arpArgs, "-I", iface) + cmd = exec.Command("arp-scan", "-glNx", arpArgs, "-I", iface) } else { cmd = exec.Command("arp-scan", "-glNx", "-I", iface) } @@ -29,6 +29,20 @@ func scanIface(iface string) string { return string(out) } +func scanStr(str string) string { + + args := strings.Split(str, " ") + cmd := exec.Command("arp-scan", args...) + + out, err := cmd.Output() + slog.Debug(cmd.String()) + + if check.IfError(err) { + return string("") + } + return string(out) +} + func parseOutput(text, iface string) []models.Host { var foundHosts = []models.Host{} @@ -52,7 +66,7 @@ func parseOutput(text, iface string) []models.Host { } // Scan all interfaces -func Scan(ifaces, args string) []models.Host { +func Scan(ifaces, args string, strs []string) []models.Host { var text string var foundHosts = []models.Host{} arpArgs = args @@ -67,5 +81,13 @@ func Scan(ifaces, args string) []models.Host { foundHosts = append(foundHosts, parseOutput(text, iface)...) } + for _, s := range strs { + slog.Debug("Scanning string " + s) + text = scanStr(s) + slog.Debug("Found IPs: \n" + text) + + foundHosts = append(foundHosts, parseOutput(text, "")...) + } + return foundHosts } diff --git a/internal/conf/getconfig.go b/internal/conf/getconfig.go index e5953cb..7f405dd 100644 --- a/internal/conf/getconfig.go +++ b/internal/conf/getconfig.go @@ -42,6 +42,7 @@ func Get(path string) (config models.Conf) { config.NodePath = viper.Get("NODEPATH").(string) config.LogLevel = viper.Get("LOG_LEVEL").(string) config.ArpArgs = viper.Get("ARP_ARGS").(string) + config.ArpStrs = viper.GetStringSlice("ARP_STRS") config.Ifaces = viper.Get("IFACES").(string) config.Timeout = viper.GetInt("TIMEOUT") config.TrimHist = viper.GetInt("TRIM_HIST") @@ -74,6 +75,7 @@ func Write(config models.Conf) { viper.Set("NODEPATH", config.NodePath) viper.Set("LOG_LEVEL", config.LogLevel) viper.Set("ARP_ARGS", config.ArpArgs) + viper.Set("ARP_STRS", config.ArpStrs) viper.Set("IFACES", config.Ifaces) viper.Set("TIMEOUT", config.Timeout) viper.Set("TRIM_HIST", config.TrimHist) diff --git a/internal/models/models.go b/internal/models/models.go index d5405bd..8069c72 100644 --- a/internal/models/models.go +++ b/internal/models/models.go @@ -13,6 +13,7 @@ type Conf struct { LogLevel string Ifaces string ArpArgs string + ArpStrs []string Timeout int TrimHist int HistInDB bool diff --git a/internal/web/public/version b/internal/web/public/version index de0e66e..c579b50 100644 --- a/internal/web/public/version +++ b/internal/web/public/version @@ -1 +1 @@ -VERSION=2.0.0 \ No newline at end of file +VERSION=2.0.1 \ No newline at end of file diff --git a/internal/web/scan-routine.go b/internal/web/scan-routine.go index d3b0c22..fc105c5 100644 --- a/internal/web/scan-routine.go +++ b/internal/web/scan-routine.go @@ -26,7 +26,7 @@ func startScan(quit chan bool) { if nowDate.After(plusDate) { - foundHosts = arp.Scan(appConfig.Ifaces, appConfig.ArpArgs) + foundHosts = arp.Scan(appConfig.Ifaces, appConfig.ArpArgs, appConfig.ArpStrs) compareHosts(foundHosts) allHosts = db.Select("now")