add banner mode off option

This commit is contained in:
xvzc 2022-07-24 11:20:23 +09:00
parent 5720894017
commit 5eaea37f48
2 changed files with 19 additions and 5 deletions

View File

@ -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)

View File

@ -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("")
}