mirror of
https://github.com/bettercap/bettercap
synced 2025-07-12 16:13:48 -07:00
new: exposing the graph object to js
This commit is contained in:
parent
0042b77c36
commit
93b7e7f2ed
8 changed files with 48 additions and 13 deletions
|
@ -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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue