mirror of
https://github.com/bettercap/bettercap
synced 2025-07-15 01:23:42 -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
|
@ -6,6 +6,7 @@ import (
|
|||
"github.com/bettercap/bettercap/network"
|
||||
"github.com/bettercap/bettercap/session"
|
||||
"github.com/evilsocket/islazy/fs"
|
||||
"github.com/evilsocket/islazy/plugin"
|
||||
"github.com/evilsocket/islazy/str"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -50,6 +51,10 @@ type Module struct {
|
|||
wLock sync.Mutex
|
||||
}
|
||||
|
||||
func init() {
|
||||
plugin.Defines["graph"] = graphPackage{}
|
||||
}
|
||||
|
||||
func NewModule(s *session.Session) *Module {
|
||||
mod := &Module{
|
||||
SessionModule: session.NewSessionModule("graph", s),
|
||||
|
@ -173,8 +178,15 @@ func (mod *Module) updateSettings() error {
|
|||
}
|
||||
}
|
||||
|
||||
if mod.db, err = NewGraph(mod.settings.path); err != nil {
|
||||
return err
|
||||
// only reload if needed
|
||||
if mod.db != nil && mod.db.path != mod.settings.path {
|
||||
mod.db = nil
|
||||
}
|
||||
|
||||
if mod.db == nil {
|
||||
if mod.db, err = NewGraph(mod.settings.path); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue