From cb2257394351d1cc761662fc2ec03809648ec250 Mon Sep 17 00:00:00 2001 From: xvzc Date: Mon, 10 Jan 2022 23:58:27 +0900 Subject: [PATCH 1/2] [update] move welcome to util module --- proxy/proxy.go | 13 ------------- util/util.go | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index 93ea199..bcd0c4c 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -1,12 +1,10 @@ package proxy import ( - "fmt" "log" "net" "os" - "github.com/pterm/pterm" "github.com/xvzc/SpoofDPI/doh" "github.com/xvzc/SpoofDPI/packet" ) @@ -25,17 +23,6 @@ func New(port string, os string, debug bool) *Proxy { } } -func (p *Proxy) PrintWelcome() { - cyan := pterm.NewLettersFromStringWithStyle("Spoof", pterm.NewStyle(pterm.FgCyan)) - purple := pterm.NewLettersFromStringWithStyle("DPI", pterm.NewStyle(pterm.FgLightMagenta)) - pterm.DefaultBigText.WithLetters(cyan, purple).Render() - - pterm.DefaultBulletList.WithItems([]pterm.BulletListItem{ - {Level: 0, Text: "PORT : " + p.Port}, - {Level: 0, Text: "DEBUG : " + fmt.Sprint(p.Debug)}, - }).Render() -} - func (p *Proxy) Start() { listener, err := net.Listen("tcp", ":"+p.Port) if err != nil { diff --git a/util/util.go b/util/util.go index a0452d2..80c7ce1 100644 --- a/util/util.go +++ b/util/util.go @@ -2,6 +2,9 @@ package util import ( "flag" + "fmt" + + "github.com/pterm/pterm" ) func ParseArgs() (string, string, bool) { @@ -21,3 +24,15 @@ func BytesToChunks(buf []byte) [][]byte { return [][]byte{buf[:1], buf[1:]} } + +func PrintWelcome(port string, 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() + + pterm.DefaultBulletList.WithItems([]pterm.BulletListItem{ + {Level: 0, Text: "PORT : " + port}, + {Level: 0, Text: "DNS : " + dns}, + {Level: 0, Text: "DEBUG : " + fmt.Sprint(debug)}, + }).Render() +} From ecc6a9fc2530d7a921a2e995a2b0ef993dbd0b39 Mon Sep 17 00:00:00 2001 From: xvzc Date: Mon, 10 Jan 2022 23:59:31 +0900 Subject: [PATCH 2/2] [update] fix PrintWelcome in main.go --- cmd/spoof-dpi/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/spoof-dpi/main.go b/cmd/spoof-dpi/main.go index 8194df5..b838643 100644 --- a/cmd/spoof-dpi/main.go +++ b/cmd/spoof-dpi/main.go @@ -16,7 +16,7 @@ func main() { port, dns, debug := util.ParseArgs() p := proxy.New(port, runtime.GOOS, debug) - p.PrintWelcome() + util.PrintWelcome(port, dns, debug) if err := p.SetOsProxy(); err != nil { log.Fatal(err)