From db0d4528da7c6ab76383321b898806619f24aff5 Mon Sep 17 00:00:00 2001 From: kerwin612 Date: Mon, 17 Jun 2024 10:43:29 +0800 Subject: [PATCH] Enhance user experience --- cli/main.go | 18 ++++++++++-------- gui/src/components/business/Main/index.js | 4 ++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/cli/main.go b/cli/main.go index 07f8527..746722e 100755 --- a/cli/main.go +++ b/cli/main.go @@ -2,7 +2,7 @@ package main import ( "os" - "fmt" + "log" "flag" "errors" "strings" @@ -49,19 +49,21 @@ func parseTarget(s string) (string, string, int, error) { } func main() { - source := flag.String("s", "", "Source Addr: addr:port") - target := flag.String("t", "", "Target Addr: protocol:addr:port") + source := flag.String("s", "", "Source Addr: [addr]<:port>") + target := flag.String("t", "", "Target Addr: ") flag.Parse() source_addr, source_port, err := parseSource(*source) if err != nil { - panic(err) + flag.PrintDefaults() + log.Fatal("Source Addr Error: ", err) } protocol, target_addr, target_port, err := parseTarget(*target) if err != nil { - panic(err) + flag.PrintDefaults() + log.Fatal("Target Addr Error: ", err) } ln, err := core.Forward(core.Info{ @@ -72,15 +74,15 @@ func main() { Protocol: protocol, }) if err != nil { - panic(err) + log.Fatal("Forward Error: ", err) } - fmt.Printf("Forwarded: [[%s]] ==>> [[%s]]\n", *source, *target) + log.Printf("Forwarded: [[%s]] ==>> [[%s]]\n", *source, *target) sigs := make(chan os.Signal, 1) signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) sig := <-sigs - fmt.Printf("Received signal: %s, shutting down...\n", sig) + log.Printf("Received signal: %s, shutting down...\n", sig) ln.Close() os.Exit(0) diff --git a/gui/src/components/business/Main/index.js b/gui/src/components/business/Main/index.js index 67dd77e..71aeedd 100755 --- a/gui/src/components/business/Main/index.js +++ b/gui/src/components/business/Main/index.js @@ -302,8 +302,8 @@ export default function Main() { return ( <> -
- {rowData.description} +
+ {rowData.description}
);