From 961d6d76c44792602ff8fc6387a96b6ddf9c1de5 Mon Sep 17 00:00:00 2001 From: arindy Date: Sun, 4 Oct 2026 16:38:22 +0200 Subject: [PATCH] uses arp-scan for networking devices --- apis/networking/main.go | 8 ++++---- main.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apis/networking/main.go b/apis/networking/main.go index 0e9c937..44ec32f 100644 --- a/apis/networking/main.go +++ b/apis/networking/main.go @@ -85,7 +85,7 @@ func knownDevices() map[string]Device { func arpDevices() map[string]Device { exec.Command("ip", "n", "show") - arp := exec.Command("arp", "-a") + arp := exec.Command("arp-scan", "--localnet", "--plain", "--format=${ip}|${mac}|${vendor}") var out bytes.Buffer arp.Stdout = &out if err := arp.Run(); err != nil { @@ -95,9 +95,9 @@ func arpDevices() map[string]Device { lines := strings.Split(res, "\n") devices := make(map[string]Device) for l := range lines { - entry := strings.Fields(lines[l]) - if len(entry) > 6 { - devices[entry[3]] = Device{Name: entry[0], IP: strings.ReplaceAll(strings.ReplaceAll(entry[1], "(", ""), ")", ""), Interface: entry[6]} + entry := strings.Split(lines[l], "|") + if len(entry) >= 3 { + devices[entry[1]] = Device{Name: entry[2], IP: entry[0]} } } return devices diff --git a/main.go b/main.go index 98777f0..9c6ca2a 100644 --- a/main.go +++ b/main.go @@ -40,7 +40,7 @@ func initWidgets(ctx context.Context, term *tcell.Terminal) { widgets.New("Weather", widgets.Weather()), widgets.New("ChangeTitle", widgets.TextInput(titleUpdate, textinput.Label("Update Title: "), textinput.PlaceHolder("New Title"))), widgets.New("Wifi", widgets.WifiQRCode()), - /*widgets.New("NetworkDevices", widgets.NetworkDevices()),*/ + widgets.New("NetworkDevices", widgets.NetworkDevices()), widgets.New("Docker", widgets.DockerList()), widgets.New("HTTPProber", widgets.HTTPProber()), widgets.New("PiHole", widgets.PiholeStats()),