diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..2cc6c08 --- /dev/null +++ b/go.mod @@ -0,0 +1 @@ +module git.kolaente.de/konrad/wifi-statistics diff --git a/main.go b/main.go index 87277bf..20c9bde 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "fmt" "io/ioutil" "log" + "os/exec" "strconv" "strings" "time" @@ -27,6 +28,7 @@ const SecondsUntilInactive = 120 func main() { clients := ParseCSVDump(CSVDump) + //clients := GetClientsFromBytes() var activeClients int64 for _, c := range clients { @@ -39,6 +41,34 @@ func main() { fmt.Println("Total Clients:", len(clients)) } +func GetClientsFromBytes() (clients []*WifiClient) { + + // Tooo much hassle, just output a csv dump and parse that and delete it afterwards should be good enough + + // -u für delay + argstr := []string{"-c", "airodump-ng wlp59s0 -u 9"} + command := exec.Command("/bin/bash", argstr...) + var buf bytes.Buffer + command.Stdout = &buf + + if err := command.Start(); err != nil { + log.Fatal(err) + } + + timer := time.AfterFunc(10 *time.Second, func() { + err := command.Process.Kill() + if err != nil { + panic(err) + } + }) + + command.Wait() + timer.Stop() + ioutil.WriteFile("dump", buf.Bytes(), 0644) + + return +} + func ParseCSVDump(pathToDump string) (clients []*WifiClient) { bs, err := ioutil.ReadFile(pathToDump) if err != nil {