Merge branch 'dev' of git.puqns67.icu:mirror/serenity into dev

This commit is contained in:
Puqns67 2025-01-04 20:03:42 +08:00
commit ea629c413d
Signed by: Puqns67
GPG Key ID: 9669DF042554F536
8 changed files with 22 additions and 18 deletions

View File

@ -2,8 +2,10 @@
icon: material/alert-decagram 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 * Fixes and improvements
#### 1.1.0-alpha.3 #### 1.1.0-alpha.3

View File

@ -19,6 +19,7 @@
"dns": "", "dns": "",
"dns_local": "", "dns_local": "",
"dns_servers": [],
"enable_fakeip": false, "enable_fakeip": false,
"pre_dns_rules": [], "pre_dns_rules": [],
"custom_dns_rules": [], "custom_dns_rules": [],
@ -143,6 +144,12 @@ DNS server used for China DNS requests.
`114.114.114.114` is used by default. `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
Enable FakeIP. Enable FakeIP.

View File

@ -1,10 +1,10 @@
--- ---
description: 欢迎来到该 sing-box 项目的文档页。 description: 欢迎来到该 serenity 项目的文档页。
--- ---
# :material-home: 开始 # :material-home: 开始
欢迎来到该 sing-box 项目的文档页。 欢迎来到该 serenity 项目的文档页。
sing-box 配置生成器。 sing-box 配置生成器。

View File

@ -28,7 +28,7 @@ type _Template struct {
RemoteResolve bool `json:"remote_resolve,omitempty"` RemoteResolve bool `json:"remote_resolve,omitempty"`
// DNS // DNS
CustomDNSServers []option.DNSServerOptions `json:"custom_dns_servers,omitempty"` DNSServers []option.DNSServerOptions `json:"dns_servers,omitempty"`
DNS string `json:"dns,omitempty"` DNS string `json:"dns,omitempty"`
DNSLocal string `json:"dns_local,omitempty"` DNSLocal string `json:"dns_local,omitempty"`
DNSSetup string `json:"dns_setup,omitempty"` DNSSetup string `json:"dns_setup,omitempty"`

View File

@ -39,6 +39,6 @@ func decodeBase64URLSafe(content string) (string, error) {
content = strings.ReplaceAll(content, "/", "_") content = strings.ReplaceAll(content, "/", "_")
content = strings.ReplaceAll(content, "+", "-") 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 return string(result), err
} }

View File

@ -45,7 +45,7 @@ func extendTemplate(ctx context.Context, rawTemplates []option.Template, root, c
if err != nil { if err != nil {
return option.Template{}, E.Cause(err, "initialize template[", current.Name, "]: merge extended template: ", current.Extend) 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 { if err != nil {
return option.Template{}, E.Cause(err, "initialize template[", current.Name, "]: unmarshal extended template: ", current.Extend) return option.Template{}, E.Cause(err, "initialize template[", current.Name, "]: unmarshal extended template: ", current.Extend)
} }

View File

@ -130,11 +130,7 @@ func (t *Template) renderDNS(metadata M.Metadata, options *option.Options) error
Address: "fakeip", Address: "fakeip",
}) })
} }
options.DNS.Servers = append(options.DNS.Servers, t.DNSServers...)
if len(t.CustomDNSServers) > 0 {
options.DNS.Servers = append(options.DNS.Servers, t.CustomDNSServers...)
}
options.DNS.Rules = []option.DNSRule{ options.DNS.Rules = []option.DNSRule{
{ {
Type: C.RuleTypeDefault, Type: C.RuleTypeDefault,

View File

@ -29,6 +29,7 @@ func (t *Template) renderInbounds(metadata M.Metadata, options *option.Options)
autoRedirect := t.AutoRedirect && autoRedirect := t.AutoRedirect &&
!metadata.Platform.IsApple() && !metadata.Platform.IsApple() &&
(metadata.Version == nil || metadata.Version.GreaterThanOrEqual(semver.ParseVersion("1.10.0-alpha.2"))) (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() disableTun := t.DisableTUN && !metadata.Platform.TunOnly()
if !disableTun { if !disableTun {
options.Route.AutoDetectInterface = true 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")) address = append(address, netip.MustParsePrefix("fdfe:dcba:9876::1/126"))
} }
tunOptions := &option.TunInboundOptions{ tunOptions := &option.TunInboundOptions{
AutoRoute: true, AutoRoute: true,
Address: address, Address: address,
AutoRedirect: autoRedirect,
} }
tunInbound := option.Inbound{ tunInbound := option.Inbound{
Type: C.TypeTun, Type: C.TypeTun,
Options: tunOptions, Options: tunOptions,
} }
if autoRedirect { if tunExclude && !t.DisableTrafficBypass {
tunOptions.AutoRedirect = true tunOptions.RouteExcludeAddressSet = []string{"geoip-cn"}
if !t.DisableTrafficBypass && metadata.Platform == "" {
tunOptions.RouteExcludeAddressSet = []string{"geoip-cn"}
}
} }
if metadata.Platform == M.PlatformUnknown { if metadata.Platform == M.PlatformUnknown {
tunOptions.StrictRoute = true tunOptions.StrictRoute = true