From 5645d3d3c74cee55bae3328a76d2afe9b978717f Mon Sep 17 00:00:00 2001 From: cubemaze Date: Mon, 28 Aug 2023 15:24:28 +0800 Subject: [PATCH] feat: domain_strategy --- conf/sing.go | 5 +++++ core/sing/node.go | 1 + example/config.json | 8 +++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/conf/sing.go b/conf/sing.go index 19120cc..9501e67 100644 --- a/conf/sing.go +++ b/conf/sing.go @@ -1,5 +1,9 @@ package conf +import ( + "github.com/inazumav/sing-box/option" +) + type SingConfig struct { LogConfig SingLogConfig `json:"Log"` NtpConfig SingNtpConfig `json:"NTP"` @@ -31,6 +35,7 @@ type SingOptions struct { EnableProxyProtocol bool `json:"EnableProxyProtocol"` TCPFastOpen bool `json:"EnableTFO"` SniffEnabled bool `json:"EnableSniff"` + DomainStrategy option.DomainStrategy `json:"DomainStrategy"` SniffOverrideDestination bool `json:"SniffOverrideDestination"` FallBackConfigs *FallBackConfigForSing `json:"FallBackConfigs"` } diff --git a/core/sing/node.go b/core/sing/node.go index 3a11675..ea8bd69 100644 --- a/core/sing/node.go +++ b/core/sing/node.go @@ -38,6 +38,7 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio InboundOptions: option.InboundOptions{ SniffEnabled: c.SingOptions.SniffEnabled, SniffOverrideDestination: c.SingOptions.SniffOverrideDestination, + DomainStrategy: c.SingOptions.DomainStrategy, }, } var tls option.InboundTLSOptions diff --git a/example/config.json b/example/config.json index d87f53c..51ee651 100644 --- a/example/config.json +++ b/example/config.json @@ -63,7 +63,12 @@ // 开启 Proxy Protocol,参见 https://github.com/haproxy/haproxy/blob/master/doc/proxy-protocol.txt "EnableProxyProtocol": false, // 开启 TCP Fast Open - "EnableTFO": true + "EnableTFO": true, + + // 设置 Domain Strategy + // 可选 prefer_ipv4 / prefer_ipv6 / ipv4_only / ipv6_only + "DomainStrategy": "ipv4_only", + // More } /*, @@ -81,6 +86,7 @@ "Core": "sing", "EnableProxyProtocol": true, "EnableTFO": true + "DomainStrategy": "ipv4_only", } }, {