SpoofDPI/util/config.go

69 lines
1.6 KiB
Go

package util
import (
"fmt"
"regexp"
"github.com/pterm/pterm"
"github.com/pterm/pterm/putils"
)
type Config struct {
Addr *string
Port *int
DnsAddr *string
DnsPort *int
EnableDoh *bool
Debug *bool
NoBanner *bool
SystemProxy *bool
Timeout *int
WindowSize *int
AllowedPattern []*regexp.Regexp
}
var config *Config
func GetConfig() *Config {
if config == nil {
config = new(Config)
}
return config
}
func (c *Config) Load(args *Args) {
c.Addr = args.Addr
c.Port = args.Port
c.DnsAddr = args.DnsAddr
c.DnsPort = args.DnsPort
c.Debug = args.Debug
c.EnableDoh = args.EnableDoh
c.NoBanner = args.NoBanner
c.SystemProxy = args.SystemProxy
c.Timeout = args.Timeout
c.AllowedPattern = args.AllowedPattern
c.WindowSize = args.WindowSize
}
func PrintColoredBanner() {
cyan := putils.LettersFromStringWithStyle("Spoof", pterm.NewStyle(pterm.FgCyan))
purple := putils.LettersFromStringWithStyle("DPI", pterm.NewStyle(pterm.FgLightMagenta))
pterm.DefaultBigText.WithLetters(cyan, purple).Render()
pterm.DefaultBulletList.WithItems([]pterm.BulletListItem{
{Level: 0, Text: "ADDR : " + fmt.Sprint(*config.Addr)},
{Level: 0, Text: "PORT : " + fmt.Sprint(*config.Port)},
{Level: 0, Text: "DNS : " + fmt.Sprint(*config.DnsAddr)},
{Level: 0, Text: "DEBUG : " + fmt.Sprint(*config.Debug)},
}).Render()
}
func PrintSimpleInfo() {
fmt.Println("")
fmt.Println("- ADDR : ", *config.Addr)
fmt.Println("- PORT : ", *config.Port)
fmt.Println("- DNS : ", *config.DnsAddr)
fmt.Println("- DEBUG : ", *config.Debug)
fmt.Println("")
}