mirror of
https://github.com/bettercap/bettercap.git
synced 2025-09-06 22:27:49 +00:00
Implement session script onExit call.
This commit is contained in:
@@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user