mirror of
https://github.com/bettercap/bettercap
synced 2025-07-05 20:42:09 -07:00
Implement session script onExit call.
This commit is contained in:
parent
c4e45b368d
commit
159aed5080
1 changed files with 11 additions and 0 deletions
|
@ -13,11 +13,14 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/bettercap/bettercap/v2/core"
|
||||
"github.com/bettercap/bettercap/v2/log"
|
||||
"github.com/bettercap/bettercap/v2/network"
|
||||
|
||||
"github.com/bettercap/readline"
|
||||
"github.com/evilsocket/islazy/str"
|
||||
"github.com/evilsocket/islazy/tui"
|
||||
|
||||
"github.com/robertkrimen/otto"
|
||||
)
|
||||
|
||||
func (s *Session) generalHelp() {
|
||||
|
@ -155,6 +158,14 @@ func (s *Session) activeHandler(args []string, sess *Session) error {
|
|||
}
|
||||
|
||||
func (s *Session) exitHandler(args []string, sess *Session) error {
|
||||
if s.script != nil {
|
||||
if s.script.Plugin.HasFunc("onExit") {
|
||||
if _, err := s.script.Plugin.Call("onExit"); err != nil {
|
||||
log.Error("Error while executing onExit callback: %s", "\nTraceback:\n "+err.(*otto.Error).String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// notify any listener that the session is about to end
|
||||
s.Events.Add("session.stopped", nil)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue