From 5eaea37f48da24b62ae82b150fb8fc3b333d27a9 Mon Sep 17 00:00:00 2001 From: xvzc Date: Sun, 24 Jul 2022 11:20:23 +0900 Subject: [PATCH] add banner mode off option --- cmd/spoof-dpi/main.go | 8 ++++++-- util/util.go | 16 +++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/cmd/spoof-dpi/main.go b/cmd/spoof-dpi/main.go index 2559896..9495ee4 100644 --- a/cmd/spoof-dpi/main.go +++ b/cmd/spoof-dpi/main.go @@ -13,7 +13,7 @@ import ( ) func main() { - addr, port, dns, debug := util.ParseArgs() + addr, port, dns, debug, banner := util.ParseArgs() p := proxy.New(addr, port) doh.Init(dns) @@ -27,7 +27,11 @@ func main() { FullTimestamp: true, }) - util.PrintWelcome(addr, port, dns, debug) + if banner { + util.PrintColoredBanner(addr, port, dns, debug) + } else { + util.PrintSimpleInfo(addr, port, dns, debug) + } if err := util.SetOsProxy(port); err != nil { log.Fatal(err) diff --git a/util/util.go b/util/util.go index 16364dd..fa8a149 100644 --- a/util/util.go +++ b/util/util.go @@ -7,18 +7,19 @@ import ( "github.com/pterm/pterm" ) -func ParseArgs() (string, int, string, bool) { +func ParseArgs() (string, int, string, bool, bool) { addr := flag.String("addr", "127.0.0.1", "Listen addr") port := flag.Int("port", 8080, "port") dns := flag.String("dns", "8.8.8.8", "DNS server") debug := flag.Bool("debug", false, "true | false") + banner := flag.Bool("banner", true, "true | false") flag.Parse() - return *addr, *port, *dns, *debug + return *addr, *port, *dns, *debug, *banner } -func PrintWelcome(addr string, port int, dns string, debug bool) { +func PrintColoredBanner(addr string, port int, dns string, debug bool) { cyan := pterm.NewLettersFromStringWithStyle("Spoof", pterm.NewStyle(pterm.FgCyan)) purple := pterm.NewLettersFromStringWithStyle("DPI", pterm.NewStyle(pterm.FgLightMagenta)) pterm.DefaultBigText.WithLetters(cyan, purple).Render() @@ -30,3 +31,12 @@ func PrintWelcome(addr string, port int, dns string, debug bool) { {Level: 0, Text: "DEBUG : " + fmt.Sprint(debug)}, }).Render() } + +func PrintSimpleInfo(addr string, port int, dns string, debug bool) { + fmt.Println("") + fmt.Println("- ADDR : ", addr) + fmt.Println("- PORT : ", port) + fmt.Println("- DNS : ", dns) + fmt.Println("- DEBUG : ", debug) + fmt.Println("") +}