This commit is contained in:
kolaente 2018-11-28 21:22:02 +01:00
parent a9a48ffbd8
commit 9dcf6d9c6f
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 31 additions and 0 deletions

1
go.mod Normal file
View File

@ -0,0 +1 @@
module git.kolaente.de/konrad/wifi-statistics

30
main.go
View File

@ -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 <secs> 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 {