Merge pull request #6 from xvzc/util

Merge branch util to main
This commit is contained in:
Kwanghoo Park 2022-01-11 00:00:58 +09:00 committed by GitHub
commit 510f2f9835
3 changed files with 16 additions and 14 deletions

View File

@ -16,7 +16,7 @@ func main() {
port, dns, debug := util.ParseArgs() port, dns, debug := util.ParseArgs()
p := proxy.New(port, runtime.GOOS, debug) p := proxy.New(port, runtime.GOOS, debug)
p.PrintWelcome() util.PrintWelcome(port, dns, debug)
if err := p.SetOsProxy(); err != nil { if err := p.SetOsProxy(); err != nil {
log.Fatal(err) log.Fatal(err)

View File

@ -1,12 +1,10 @@
package proxy package proxy
import ( import (
"fmt"
"log" "log"
"net" "net"
"os" "os"
"github.com/pterm/pterm"
"github.com/xvzc/SpoofDPI/doh" "github.com/xvzc/SpoofDPI/doh"
"github.com/xvzc/SpoofDPI/packet" "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() { func (p *Proxy) Start() {
listener, err := net.Listen("tcp", ":"+p.Port) listener, err := net.Listen("tcp", ":"+p.Port)
if err != nil { if err != nil {

View File

@ -2,6 +2,9 @@ package util
import ( import (
"flag" "flag"
"fmt"
"github.com/pterm/pterm"
) )
func ParseArgs() (string, string, bool) { func ParseArgs() (string, string, bool) {
@ -21,3 +24,15 @@ func BytesToChunks(buf []byte) [][]byte {
return [][]byte{buf[:1], buf[1:]} 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()
}