new: exposing the graph object to js

This commit is contained in:
Simone Margaritelli 2021-04-09 13:46:33 +02:00
parent 0042b77c36
commit 93b7e7f2ed
8 changed files with 48 additions and 13 deletions

View file

@ -1,43 +0,0 @@
package graph
import (
"io/ioutil"
"os"
"time"
)
func (mod *Module) generateJSONGraph(bssid string) error {
mod.wLock.Lock()
defer mod.wLock.Unlock()
start := time.Now()
if err := mod.updateSettings(); err != nil {
return err
}
data, size, discarded, err := mod.db.JSON(bssid, mod.settings.disconnected)
if err != nil {
return err
}
if size > 0 {
if mod.settings.privacy {
data = privacyFilter.ReplaceAllString(data, "$1:$2:xx:xx:xx:xx")
}
if err := ioutil.WriteFile(mod.settings.json.output, []byte(data), os.ModePerm); err != nil {
return err
} else {
mod.Info("graph saved to %s in %v (%d edges, %d discarded)",
mod.settings.json.output,
time.Since(start),
size,
discarded)
}
} else {
mod.Info("graph is empty")
}
return nil
}