From 74eb0ff38de85b604657dea29f9e60c3cfb846a4 Mon Sep 17 00:00:00 2001 From: Wang Yihang Date: Fri, 19 Mar 2021 15:37:51 +0800 Subject: [PATCH] [+] #32 display commands execution results --- lib/cli/dispatcher/data_dispatcher.go | 13 +++++-------- lib/context/server.go | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/cli/dispatcher/data_dispatcher.go b/lib/cli/dispatcher/data_dispatcher.go index 0841401a..87cb6d33 100644 --- a/lib/cli/dispatcher/data_dispatcher.go +++ b/lib/cli/dispatcher/data_dispatcher.go @@ -4,6 +4,7 @@ import ( "bufio" "fmt" "os" + "strings" "github.com/WangYihang/Platypus/lib/context" "github.com/WangYihang/Platypus/lib/util/log" @@ -19,17 +20,13 @@ func (dispatcher Dispatcher) DataDispatcher(args []string) { return } n := 0 + command = strings.TrimSpace(command) for _, server := range context.Ctx.Servers { for _, client := range (*server).GetAllTCPClients() { if client.GroupDispatch { - log.Info("Executing on %s: %s", client.FullDesc(), command[0:len(command)-1]) - size, err := client.Conn.Write([]byte(command + "\n")) - fmt.Println(size) - if err != nil { - log.Error("Write error: %s", err) - (*server).DeleteTCPClient(client) - continue - } + log.Info("Executing on %s: %s", client.FullDesc(), command) + result := client.SystemToken(command) + log.Success("%s", result) n++ } } diff --git a/lib/context/server.go b/lib/context/server.go index b94e5e63..340629a2 100644 --- a/lib/context/server.go +++ b/lib/context/server.go @@ -151,7 +151,7 @@ func (s *TCPServer) Run() { } } if clientExist { - log.Warn("Incoming connection comes from a machine which has already connected.") + log.Warn("Incoming connection comes from a machine which has already connected. You can use `BlockSameIP` to switch [ON|OFF]") client.Close() } else { log.Info("New client %s Connected", client.FullDesc())