diff --git a/core/dump_nix.go b/core/dump_nix.go new file mode 100644 index 0000000..ef08c7b --- /dev/null +++ b/core/dump_nix.go @@ -0,0 +1,23 @@ +// +build linux darwin + +package core + +import ( + "os" + "os/signal" + "syscall" +) + +func DumpSessionOnSig(sess *Session) { + sigChan := make(chan os.Signal, 1) + signal.Notify(sigChan, syscall.SIGUSR1) + for range sigChan { + sess.Lock() + err := sess.SaveToFile("aquatone_session.json") + if err != nil { + sess.Out.Error("Failed to write session file") + sess.Out.Debug("Err: %s", err.Error()) + } + sess.Unlock() + } +} \ No newline at end of file diff --git a/core/dump_windows.go b/core/dump_windows.go new file mode 100644 index 0000000..73f2086 --- /dev/null +++ b/core/dump_windows.go @@ -0,0 +1,7 @@ +// +build windows + +package core + +func DumpSessionOnSig(sess *Session) { + // not supported +} \ No newline at end of file diff --git a/main.go b/main.go index 649aaf0..29503e7 100644 --- a/main.go +++ b/main.go @@ -112,6 +112,8 @@ func main() { os.Exit(0) } + go core.DumpSessionOnSig(sess) + agents.NewTCPPortScanner().Register(sess) agents.NewURLPublisher().Register(sess) agents.NewURLRequester().Register(sess)