uses arp-scan for networking devices
This commit is contained in:
@@ -85,7 +85,7 @@ func knownDevices() map[string]Device {
|
|||||||
|
|
||||||
func arpDevices() map[string]Device {
|
func arpDevices() map[string]Device {
|
||||||
exec.Command("ip", "n", "show")
|
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
|
var out bytes.Buffer
|
||||||
arp.Stdout = &out
|
arp.Stdout = &out
|
||||||
if err := arp.Run(); err != nil {
|
if err := arp.Run(); err != nil {
|
||||||
@@ -95,9 +95,9 @@ func arpDevices() map[string]Device {
|
|||||||
lines := strings.Split(res, "\n")
|
lines := strings.Split(res, "\n")
|
||||||
devices := make(map[string]Device)
|
devices := make(map[string]Device)
|
||||||
for l := range lines {
|
for l := range lines {
|
||||||
entry := strings.Fields(lines[l])
|
entry := strings.Split(lines[l], "|")
|
||||||
if len(entry) > 6 {
|
if len(entry) >= 3 {
|
||||||
devices[entry[3]] = Device{Name: entry[0], IP: strings.ReplaceAll(strings.ReplaceAll(entry[1], "(", ""), ")", ""), Interface: entry[6]}
|
devices[entry[1]] = Device{Name: entry[2], IP: entry[0]}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return devices
|
return devices
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ func initWidgets(ctx context.Context, term *tcell.Terminal) {
|
|||||||
widgets.New("Weather", widgets.Weather()),
|
widgets.New("Weather", widgets.Weather()),
|
||||||
widgets.New("ChangeTitle", widgets.TextInput(titleUpdate, textinput.Label("Update Title: "), textinput.PlaceHolder("New Title"))),
|
widgets.New("ChangeTitle", widgets.TextInput(titleUpdate, textinput.Label("Update Title: "), textinput.PlaceHolder("New Title"))),
|
||||||
widgets.New("Wifi", widgets.WifiQRCode()),
|
widgets.New("Wifi", widgets.WifiQRCode()),
|
||||||
/*widgets.New("NetworkDevices", widgets.NetworkDevices()),*/
|
widgets.New("NetworkDevices", widgets.NetworkDevices()),
|
||||||
widgets.New("Docker", widgets.DockerList()),
|
widgets.New("Docker", widgets.DockerList()),
|
||||||
widgets.New("HTTPProber", widgets.HTTPProber()),
|
widgets.New("HTTPProber", widgets.HTTPProber()),
|
||||||
widgets.New("PiHole", widgets.PiholeStats()),
|
widgets.New("PiHole", widgets.PiholeStats()),
|
||||||
|
|||||||
Reference in New Issue
Block a user