From c2ada999ac8d0b6fc694ae109db7ad5049f7f472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Tue, 31 Dec 2024 15:53:51 +0800 Subject: [PATCH 1/7] Fix extend template --- template/manager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/manager.go b/template/manager.go index f2f5c81..7a46b8c 100644 --- a/template/manager.go +++ b/template/manager.go @@ -45,7 +45,7 @@ func extendTemplate(ctx context.Context, rawTemplates []option.Template, root, c if err != nil { return option.Template{}, E.Cause(err, "initialize template[", current.Name, "]: merge extended template: ", current.Extend) } - newTemplate, err := json.UnmarshalExtended[option.Template](newRawTemplate) + newTemplate, err := json.UnmarshalExtendedContext[option.Template](ctx, newRawTemplate) if err != nil { return option.Template{}, E.Cause(err, "initialize template[", current.Name, "]: unmarshal extended template: ", current.Extend) } From f5578d425df2e2f2a44c4f9d35b6bdf1e081d30d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Tue, 31 Dec 2024 15:58:53 +0800 Subject: [PATCH 2/7] Fix DNS server offset --- template/render_dns.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/render_dns.go b/template/render_dns.go index 0c74e10..2326980 100644 --- a/template/render_dns.go +++ b/template/render_dns.go @@ -36,7 +36,6 @@ func (t *Template) renderDNS(metadata M.Metadata, options *option.Options) error domainStrategyLocal = 0 } options.DNS = &option.DNSOptions{ - Servers: t.Servers, ReverseMapping: !t.DisableTrafficBypass && metadata.Platform != M.PlatformUnknown && !metadata.Platform.IsApple(), DNSClientOptions: option.DNSClientOptions{ Strategy: domainStrategy, @@ -110,6 +109,7 @@ func (t *Template) renderDNS(metadata M.Metadata, options *option.Options) error Address: "fakeip", }) } + options.DNS.Servers = append(options.DNS.Servers, t.Servers...) options.DNS.Rules = []option.DNSRule{ { Type: C.RuleTypeDefault, From 013014815f8f59757532cb86286b9edc3415e99f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Tue, 31 Dec 2024 16:01:19 +0800 Subject: [PATCH 3/7] documentation: Fix typo --- docs/index.zh.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/index.zh.md b/docs/index.zh.md index 54060c0..88b5bf4 100644 --- a/docs/index.zh.md +++ b/docs/index.zh.md @@ -1,10 +1,10 @@ --- -description: 欢迎来到该 sing-box 项目的文档页。 +description: 欢迎来到该 serenity 项目的文档页。 --- # :material-home: 开始 -欢迎来到该 sing-box 项目的文档页。 +欢迎来到该 serenity 项目的文档页。 sing-box 配置生成器。 From f6354971c4d4fb392ea03e00765144de4c80eadd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Tue, 31 Dec 2024 16:07:22 +0800 Subject: [PATCH 4/7] Rename `template.servers` to `template.dns_servers` --- docs/configuration/template.md | 7 +++++++ option/template.go | 2 +- template/render_dns.go | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/configuration/template.md b/docs/configuration/template.md index d4a5e34..04f0b09 100644 --- a/docs/configuration/template.md +++ b/docs/configuration/template.md @@ -19,6 +19,7 @@ "dns": "", "dns_local": "", + "dns_servers": [], "enable_fakeip": false, "pre_dns_rules": [], "custom_dns_rules": [], @@ -143,6 +144,12 @@ DNS server used for China DNS requests. `114.114.114.114` is used by default. +#### dns_servers + +List of [DNS Server](https://sing-box.sagernet.org/configuration/dns/server/). + +Will be append to DNS servers. + #### enable_fakeip Enable FakeIP. diff --git a/option/template.go b/option/template.go index 59201cc..0f93caf 100644 --- a/option/template.go +++ b/option/template.go @@ -28,7 +28,7 @@ type _Template struct { RemoteResolve bool `json:"remote_resolve,omitempty"` // DNS - Servers []option.DNSServerOptions `json:"servers,omitempty"` + DNSServers []option.DNSServerOptions `json:"dns_servers,omitempty"` DNS string `json:"dns,omitempty"` DNSLocal string `json:"dns_local,omitempty"` EnableFakeIP bool `json:"enable_fakeip,omitempty"` diff --git a/template/render_dns.go b/template/render_dns.go index 2326980..36f9186 100644 --- a/template/render_dns.go +++ b/template/render_dns.go @@ -109,7 +109,7 @@ func (t *Template) renderDNS(metadata M.Metadata, options *option.Options) error Address: "fakeip", }) } - options.DNS.Servers = append(options.DNS.Servers, t.Servers...) + options.DNS.Servers = append(options.DNS.Servers, t.DNSServers...) options.DNS.Rules = []option.DNSRule{ { Type: C.RuleTypeDefault, From a2665f79932d617cf2296fabec1932eaefe53db7 Mon Sep 17 00:00:00 2001 From: Richard Wang <62804488+ricky9w@users.noreply.github.com> Date: Tue, 31 Dec 2024 16:16:41 +0800 Subject: [PATCH 5/7] Fix decode base64 URL --- subscription/parser/raw.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subscription/parser/raw.go b/subscription/parser/raw.go index aa7a75c..72205c3 100644 --- a/subscription/parser/raw.go +++ b/subscription/parser/raw.go @@ -39,6 +39,6 @@ func decodeBase64URLSafe(content string) (string, error) { content = strings.ReplaceAll(content, "/", "_") content = strings.ReplaceAll(content, "+", "-") content = strings.ReplaceAll(content, "=", "") - result, err := base64.StdEncoding.DecodeString(content) + result, err := base64.RawURLEncoding.DecodeString(content) return string(result), err } From e72f4526200462d9da78ae95274b139d7da575f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Tue, 31 Dec 2024 16:26:37 +0800 Subject: [PATCH 6/7] Set `route_exclude_address_set` for routing --- template/render_inbounds.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/template/render_inbounds.go b/template/render_inbounds.go index 237d8c3..43313a4 100644 --- a/template/render_inbounds.go +++ b/template/render_inbounds.go @@ -29,6 +29,7 @@ func (t *Template) renderInbounds(metadata M.Metadata, options *option.Options) autoRedirect := t.AutoRedirect && !metadata.Platform.IsApple() && (metadata.Version == nil || metadata.Version.GreaterThanOrEqual(semver.ParseVersion("1.10.0-alpha.2"))) + tunExclude := metadata.Platform != M.PlatformAndroid && (metadata.Version == nil || metadata.Version.GreaterThanOrEqual(semver.ParseVersion("1.11.0-beta.14"))) disableTun := t.DisableTUN && !metadata.Platform.TunOnly() if !disableTun { options.Route.AutoDetectInterface = true @@ -37,18 +38,16 @@ func (t *Template) renderInbounds(metadata M.Metadata, options *option.Options) address = append(address, netip.MustParsePrefix("fdfe:dcba:9876::1/126")) } tunOptions := &option.TunInboundOptions{ - AutoRoute: true, - Address: address, + AutoRoute: true, + Address: address, + AutoRedirect: autoRedirect, } tunInbound := option.Inbound{ Type: C.TypeTun, Options: tunOptions, } - if autoRedirect { - tunOptions.AutoRedirect = true - if !t.DisableTrafficBypass && metadata.Platform == "" { - tunOptions.RouteExcludeAddressSet = []string{"geoip-cn"} - } + if tunExclude && !t.DisableTrafficBypass { + tunOptions.RouteExcludeAddressSet = []string{"geoip-cn"} } if metadata.Platform == M.PlatformUnknown { tunOptions.StrictRoute = true From 09e4fee404a14437aa167a4c80e8adcaab9e0f4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Tue, 31 Dec 2024 16:33:46 +0800 Subject: [PATCH 7/7] documentation: Bump version --- docs/changelog.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/changelog.md b/docs/changelog.md index 9c1a6de..204b0b6 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,8 +2,10 @@ icon: material/alert-decagram --- -#### 1.1.0-alpha.4 +#### 1.1.0-beta.3 +* Rename `template.servers` to `template.dns_servers` +* Set `tun.route_exclude_address_set` for traffic bypassing * Fixes and improvements #### 1.1.0-alpha.3