From f8f740b0cf6454bf3cb1a8df95f63fcebc44e7f7 Mon Sep 17 00:00:00 2001 From: xvzc <45588457+xvzc@users.noreply.github.com> Date: Sun, 25 Aug 2024 18:09:58 +0900 Subject: [PATCH] Release 0.10.11 (#195) * chore: increase the length of traceId token * fix: size of string builder for trace id * chore: rename --no-banner to --banner * chore: update docs * chore: prepare for next release --- README.md | 4 ++-- _docs/README_ja.md | 4 ++-- _docs/README_ko.md | 4 ++-- _docs/README_ru.md | 4 ++-- _docs/README_zh-cn.md | 4 ++-- cmd/spoof-dpi/main.go | 6 +++--- util/args.go | 4 ++-- util/config.go | 8 ++++++-- util/context.go | 4 ++-- version/VERSION | 2 +- 10 files changed, 24 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index b1f8772..64db368 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,8 @@ $ go build ./cmd/... Usage: spoof-dpi [options...] -addr string listen address (default "127.0.0.1") + -banner + enable banner (default true) -debug enable debug output -dns-addr string @@ -67,8 +69,6 @@ Usage: spoof-dpi [options...] port number for dns (default 53) -enable-doh enable 'dns-over-https' - -no-banner - disable banner -pattern value bypass DPI only on packets matching this regex pattern; can be given multiple times -port int diff --git a/_docs/README_ja.md b/_docs/README_ja.md index f7b474c..06f5b77 100644 --- a/_docs/README_ja.md +++ b/_docs/README_ja.md @@ -56,6 +56,8 @@ $ go build ./cmd/... Usage: spoof-dpi [options...] -addr string listen address (default "127.0.0.1") + -banner + enable banner (default true) -debug enable debug output -dns-addr string @@ -64,8 +66,6 @@ Usage: spoof-dpi [options...] port number for dns (default 53) -enable-doh enable 'dns-over-https' - -no-banner - disable banner -pattern value bypass DPI only on packets matching this regex pattern; can be given multiple times -port int diff --git a/_docs/README_ko.md b/_docs/README_ko.md index ac97f58..ed57b58 100644 --- a/_docs/README_ko.md +++ b/_docs/README_ko.md @@ -54,6 +54,8 @@ $ go install github.com/xvzc/SpoofDPI/cmd/spoof-dpi@latest Usage: spoof-dpi [options...] -addr string listen address (default "127.0.0.1") + -banner + enable banner (default true) -debug enable debug output -dns-addr string @@ -62,8 +64,6 @@ Usage: spoof-dpi [options...] port number for dns (default 53) -enable-doh enable 'dns-over-https' - -no-banner - disable banner -pattern value bypass DPI only on packets matching this regex pattern; can be given multiple times -port int diff --git a/_docs/README_ru.md b/_docs/README_ru.md index a791602..8e7b932 100644 --- a/_docs/README_ru.md +++ b/_docs/README_ru.md @@ -58,6 +58,8 @@ $ go build ./cmd/... Usage: spoof-dpi [опции...] -addr string listen address (default "127.0.0.1") + -banner + enable banner (default true) -debug enable debug output -dns-addr string @@ -66,8 +68,6 @@ Usage: spoof-dpi [опции...] port number for dns (default 53) -enable-doh enable 'dns-over-https' - -no-banner - disable banner -pattern value bypass DPI only on packets matching this regex pattern; can be given multiple times -port int diff --git a/_docs/README_zh-cn.md b/_docs/README_zh-cn.md index c38eb8b..e2fa68d 100644 --- a/_docs/README_zh-cn.md +++ b/_docs/README_zh-cn.md @@ -63,6 +63,8 @@ $ go build ./cmd/... Usage: spoof-dpi [options...] -addr string listen address (default "127.0.0.1") + -banner + enable banner (default true) -debug enable debug output -dns-addr string @@ -71,8 +73,6 @@ Usage: spoof-dpi [options...] port number for dns (default 53) -enable-doh enable 'dns-over-https' - -no-banner - disable banner -pattern value bypass DPI only on packets matching this regex pattern; can be given multiple times -port int diff --git a/cmd/spoof-dpi/main.go b/cmd/spoof-dpi/main.go index 4e1b902..e4af8f8 100644 --- a/cmd/spoof-dpi/main.go +++ b/cmd/spoof-dpi/main.go @@ -29,10 +29,10 @@ func main() { pxy := proxy.New(config) - if config.NoBanner { - util.PrintSimpleInfo() - } else { + if config.Banner { util.PrintColoredBanner() + } else { + util.PrintSimpleInfo() } if config.SystemProxy { diff --git a/util/args.go b/util/args.go index a5edce6..f99beed 100644 --- a/util/args.go +++ b/util/args.go @@ -12,7 +12,7 @@ type Args struct { DnsPort int EnableDoh bool Debug bool - NoBanner bool + Banner bool SystemProxy bool Timeout int AllowedPattern StringArray @@ -40,7 +40,7 @@ func ParseArgs() *Args { flag.IntVar(&args.DnsPort, "dns-port", 53, "port number for dns") flag.BoolVar(&args.EnableDoh, "enable-doh", false, "enable 'dns-over-https'") flag.BoolVar(&args.Debug, "debug", false, "enable debug output") - flag.BoolVar(&args.NoBanner, "no-banner", false, "disable banner") + flag.BoolVar(&args.Banner, "banner", true, "enable banner") flag.BoolVar(&args.SystemProxy, "system-proxy", true, "enable system-wide proxy") flag.IntVar(&args.Timeout, "timeout", 0, "timeout in milliseconds; no timeout when not given") flag.IntVar(&args.WindowSize, "window-size", 0, `chunk size, in number of bytes, for fragmented client hello, diff --git a/util/config.go b/util/config.go index b303c1b..d5a3c72 100644 --- a/util/config.go +++ b/util/config.go @@ -15,7 +15,7 @@ type Config struct { DnsPort int EnableDoh bool Debug bool - NoBanner bool + Banner bool SystemProxy bool Timeout int WindowSize int @@ -38,7 +38,7 @@ func (c *Config) Load(args *Args) { c.DnsPort = args.DnsPort c.Debug = args.Debug c.EnableDoh = args.EnableDoh - c.NoBanner = args.NoBanner + c.Banner = args.Banner c.SystemProxy = args.SystemProxy c.Timeout = args.Timeout c.AllowedPatterns = parseAllowedPattern(args.AllowedPattern) @@ -66,6 +66,8 @@ func PrintColoredBanner() { {Level: 0, Text: "DNS : " + fmt.Sprint(config.DnsAddr)}, {Level: 0, Text: "DEBUG : " + fmt.Sprint(config.Debug)}, }).Render() + + pterm.DefaultBasicText.Println("Press 'CTRL + c to quit'") } func PrintSimpleInfo() { @@ -75,4 +77,6 @@ func PrintSimpleInfo() { fmt.Println("- DNS : ", config.DnsAddr) fmt.Println("- DEBUG : ", config.Debug) fmt.Println("") + fmt.Println("Press 'CTRL + c to quit'") + fmt.Println("") } diff --git a/util/context.go b/util/context.go index d557a02..c3f97b6 100644 --- a/util/context.go +++ b/util/context.go @@ -34,7 +34,7 @@ func GetTraceIdFromCtx(ctx context.Context) (string, bool) { func generateTraceId() string { sb := strings.Builder{} - sb.Grow(22) + sb.Grow(35) var q uint64 var r uint8 @@ -47,7 +47,7 @@ func generateTraceId() string { r += 0x27 } sb.WriteByte(r + 0x30) - if i&3 == 3 && i != 31 { + if i&7 == 7 && i != 31 { sb.WriteByte(0x2D) } } diff --git a/version/VERSION b/version/VERSION index ddf1d4a..223df19 100644 --- a/version/VERSION +++ b/version/VERSION @@ -1 +1 @@ -0.10.10 +0.10.11