Multiple interfaces
This commit is contained in:
parent
415da92477
commit
09729acee7
5 changed files with 26 additions and 14 deletions
2
.github/workflows/docker-publish.yml
vendored
2
.github/workflows/docker-publish.yml
vendored
|
|
@ -14,7 +14,7 @@ on:
|
|||
|
||||
env:
|
||||
IMAGE_NAME: watchyourlan
|
||||
TAGS: latest, v0.5
|
||||
TAGS: latest, v0.6
|
||||
|
||||
|
||||
jobs:
|
||||
|
|
|
|||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,3 +1,4 @@
|
|||
# Ignore local data
|
||||
data/
|
||||
watchyourlan
|
||||
tmp/
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
# WatchYourLAN
|
||||
|
||||
[](https://github.com/aceberg/WatchYourLAN/actions/workflows/docker-publish.yml)
|
||||

|
||||
|
||||
Local network IP scanner with web gui
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
// "fmt"
|
||||
"log"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
|
|
@ -11,11 +10,10 @@ import (
|
|||
func scan_iface(iface string) (string) {
|
||||
cmd, err := exec.Command("arp-scan", "-glNx", "-I", iface).Output()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
return string("")
|
||||
} else {
|
||||
return string(cmd)
|
||||
}
|
||||
|
||||
return string(cmd)
|
||||
// fmt.Println(text)
|
||||
}
|
||||
|
||||
func parse_output(text string) ([]Host) {
|
||||
|
|
@ -24,10 +22,10 @@ func parse_output(text string) ([]Host) {
|
|||
perString := strings.Split(text, "\n")
|
||||
currentTime := time.Now()
|
||||
|
||||
for _, v := range perString {
|
||||
if v != "" {
|
||||
for _, host := range perString {
|
||||
if host != "" {
|
||||
var oneHost Host
|
||||
p := strings.Split(v, " ")
|
||||
p := strings.Split(host, " ")
|
||||
oneHost.Ip = p[0]
|
||||
oneHost.Mac = p[1]
|
||||
oneHost.Hw = p[2]
|
||||
|
|
@ -38,5 +36,18 @@ func parse_output(text string) ([]Host) {
|
|||
}
|
||||
|
||||
return foundHosts
|
||||
// fmt.Println(foundHosts)
|
||||
}
|
||||
|
||||
func arp_scan() ([]Host) {
|
||||
var text string
|
||||
var foundHosts = []Host{}
|
||||
|
||||
perString := strings.Split(AppConfig.Iface, " ")
|
||||
|
||||
for _, iface := range perString {
|
||||
text = scan_iface(iface)
|
||||
foundHosts = append(foundHosts, parse_output(text)...)
|
||||
}
|
||||
|
||||
return foundHosts
|
||||
}
|
||||
|
|
@ -27,9 +27,9 @@ type Conf struct {
|
|||
var AppConfig Conf
|
||||
var AllHosts []Host
|
||||
|
||||
func scan() {
|
||||
func scan_and_compare() {
|
||||
for {
|
||||
foundHosts := parse_output(scan_iface(AppConfig.Iface))
|
||||
foundHosts := arp_scan()
|
||||
dbHosts := db_select()
|
||||
db_setnow()
|
||||
hosts_compare(foundHosts, dbHosts)
|
||||
|
|
@ -45,8 +45,7 @@ func main() {
|
|||
AppConfig = get_config("./data/config")
|
||||
db_create()
|
||||
|
||||
// fmt.Println("Timeout: ", AppConfig.Timeout)
|
||||
go scan()
|
||||
go scan_and_compare()
|
||||
|
||||
webgui()
|
||||
}
|
||||
Loading…
Reference in a new issue