Skip to content

Commit

Permalink
Arp Strings
Browse files Browse the repository at this point in the history
  • Loading branch information
aceberg committed Sep 1, 2024
1 parent 01323c6 commit 795a46f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
11 changes: 6 additions & 5 deletions internal/arp/arpscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, " ")
Expand All @@ -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)
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions internal/web/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion internal/web/templates/config.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ define "config.html" }}

<script src="/fs/public/js/config.js"></script>
<body>
<div class="container-lg">
<div class="row">
Expand Down Expand Up @@ -70,6 +70,13 @@
<td>Args for arp-scan</td>
<td><input name="arpargs" type="text" class="form-control" value="{{ .Config.ArpArgs }}"></td>
</tr>
<tr>
<td>Arp Strings</td>
<td>{{ range .Config.ArpStrs }}
<input name="arpstrs" type="text" class="form-control" value="{{ . }}">{{ end }}
<input name="arpstrs" type="text" class="form-control">
</td>
</tr>
<tr>
<td>Log level</td>
<td><select name="log" class="form-select">
Expand Down

0 comments on commit 795a46f

Please sign in to comment.