fix type for dns port

This commit is contained in:
xvzc 2024-07-21 17:12:16 +09:00
parent d6472d0421
commit d150d03a67
2 changed files with 7 additions and 5 deletions

View File

@ -5,6 +5,7 @@ import (
"errors" "errors"
"regexp" "regexp"
"time" "time"
"strconv"
"github.com/likexian/doh" "github.com/likexian/doh"
dohDns "github.com/likexian/doh/dns" dohDns "github.com/likexian/doh/dns"
@ -22,7 +23,7 @@ type DnsResolver struct {
func NewResolver(config *util.Config) *DnsResolver { func NewResolver(config *util.Config) *DnsResolver {
return &DnsResolver{ return &DnsResolver{
host: *config.DnsAddr, host: *config.DnsAddr,
port: *config.DnsPort, port: strconv.Itoa(*config.DnsPort),
enableDoh: *config.EnableDoh, enableDoh: *config.EnableDoh,
} }
} }

View File

@ -7,6 +7,7 @@ import (
"strings" "strings"
"github.com/pterm/pterm" "github.com/pterm/pterm"
"github.com/pterm/pterm/putils"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
@ -14,7 +15,7 @@ type Config struct {
Addr *string Addr *string
Port *int Port *int
DnsAddr *string DnsAddr *string
DnsPort *string DnsPort *int
EnableDoh *bool EnableDoh *bool
Debug *bool Debug *bool
NoBanner *bool NoBanner *bool
@ -56,7 +57,7 @@ func ParseArgs() {
config.Addr = flag.String("addr", "127.0.0.1", "Listen addr") config.Addr = flag.String("addr", "127.0.0.1", "Listen addr")
config.Port = flag.Int("port", 8080, "port") config.Port = flag.Int("port", 8080, "port")
config.DnsAddr = flag.String("dns-addr", "8.8.8.8", "DNS addr") config.DnsAddr = flag.String("dns-addr", "8.8.8.8", "DNS addr")
config.DnsPort = flag.String("dns-port", "53", "DNS port") config.DnsPort = flag.Int("dns-port", 53, "DNS port")
config.EnableDoh = flag.Bool("enable-doh", false, "Enable DOH") config.EnableDoh = flag.Bool("enable-doh", false, "Enable DOH")
config.Debug = flag.Bool("debug", false, "true | false") config.Debug = flag.Bool("debug", false, "true | false")
config.NoBanner = flag.Bool("no-banner", false, "true | false") config.NoBanner = flag.Bool("no-banner", false, "true | false")
@ -87,8 +88,8 @@ func ParseArgs() {
} }
func PrintColoredBanner() { func PrintColoredBanner() {
cyan := pterm.NewLettersFromStringWithStyle("Spoof", pterm.NewStyle(pterm.FgCyan)) cyan := putils.LettersFromStringWithStyle("Spoof", pterm.NewStyle(pterm.FgCyan))
purple := pterm.NewLettersFromStringWithStyle("DPI", pterm.NewStyle(pterm.FgLightMagenta)) purple := putils.LettersFromStringWithStyle("DPI", pterm.NewStyle(pterm.FgLightMagenta))
pterm.DefaultBigText.WithLetters(cyan, purple).Render() pterm.DefaultBigText.WithLetters(cyan, purple).Render()
pterm.DefaultBulletList.WithItems([]pterm.BulletListItem{ pterm.DefaultBulletList.WithItems([]pterm.BulletListItem{