From 442994f15a4f2de4fe16ec0c1e37875e83572a35 Mon Sep 17 00:00:00 2001 From: chenxudong2020 <872603935@qq.com> Date: Wed, 8 Jan 2025 13:53:20 +0000 Subject: [PATCH 1/9] =?UTF-8?q?=E4=B8=AA=E6=80=A7=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config.go | 2 +- v2/standalone.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.go b/config/config.go index 383b1194..cce1afd3 100644 --- a/config/config.go +++ b/config/config.go @@ -277,7 +277,7 @@ func setClashAPI(options *option.Options, opt *HiddifyOptions) { }, CacheFile: &option.CacheFileOptions{ - Enabled: true, + Enabled: false, Path: "clash.db", }, } diff --git a/v2/standalone.go b/v2/standalone.go index 173c9eef..58fe9e42 100644 --- a/v2/standalone.go +++ b/v2/standalone.go @@ -167,7 +167,7 @@ func buildConfig(configContent string, options config.HiddifyOptions) (string, e } finalconfig.Log.Output = "" - finalconfig.Experimental.ClashAPI.ExternalUI = "webui" + finalconfig.Experimental.ClashAPI.ExternalUI = "/etc/s6-overlay/s6-rc.d/hiddify/webui" if options.AllowConnectionFromLAN { finalconfig.Experimental.ClashAPI.ExternalController = "0.0.0.0:6756" } else { From 3a7f49ec34f77386f6a36d4168994a1fd6844e89 Mon Sep 17 00:00:00 2001 From: chenxudong2020 <872603935@qq.com> Date: Wed, 8 Jan 2025 14:24:12 +0000 Subject: [PATCH 2/9] add proxy http srs --- config/config.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/config/config.go b/config/config.go index cce1afd3..85752541 100644 --- a/config/config.go +++ b/config/config.go @@ -594,7 +594,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geosite-ads", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-category-ads-all.srs", + URL: "https://ghgo.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-category-ads-all.srs", UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -603,7 +603,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geosite-malware", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-malware.srs", + URL: "https://ghgo.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-malware.srs", UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -612,7 +612,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geosite-phishing", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-phishing.srs", + URL: "https://ghgo.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-phishing.srs", UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -621,7 +621,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geosite-cryptominers", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-cryptominers.srs", + URL: "https://ghgo.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-cryptominers.srs", UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -630,7 +630,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geoip-phishing", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geoip-phishing.srs", + URL: "https://ghgo.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geoip-phishing.srs", UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -639,7 +639,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geoip-malware", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geoip-malware.srs", + URL: "https://ghgo.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geoip-malware.srs", UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -697,7 +697,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geoip-" + opt.Region, Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/country/geoip-" + opt.Region + ".srs", + URL: "https://ghgo.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/country/geoip-" + opt.Region + ".srs", UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -706,7 +706,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geosite-" + opt.Region, Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/country/geosite-" + opt.Region + ".srs", + URL: "https://ghgo.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/country/geosite-" + opt.Region + ".srs", UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) From af02780bf25abba43983df2fbedfbddd81210a8f Mon Sep 17 00:00:00 2001 From: chenxudong2020 <872603935@qq.com> Date: Wed, 8 Jan 2025 14:45:13 +0000 Subject: [PATCH 3/9] proxy --- config/config.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/config/config.go b/config/config.go index 85752541..2d4b6b3c 100644 --- a/config/config.go +++ b/config/config.go @@ -594,7 +594,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geosite-ads", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://ghgo.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-category-ads-all.srs", + URL: "https://gh-proxy.com/raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-category-ads-all.srs", UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -603,7 +603,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geosite-malware", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://ghgo.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-malware.srs", + URL: "https://gh-proxy.com/raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-malware.srs", UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -612,7 +612,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geosite-phishing", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://ghgo.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-phishing.srs", + URL: "https://gh-proxy.com/raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-phishing.srs", UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -621,7 +621,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geosite-cryptominers", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://ghgo.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-cryptominers.srs", + URL: "https://gh-proxy.com/raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-cryptominers.srs", UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -630,7 +630,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geoip-phishing", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://ghgo.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geoip-phishing.srs", + URL: "https://gh-proxy.com/raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geoip-phishing.srs", UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -639,7 +639,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geoip-malware", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://ghgo.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geoip-malware.srs", + URL: "https://gh-proxy.com/raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geoip-malware.srs", UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -697,7 +697,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geoip-" + opt.Region, Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://ghgo.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/country/geoip-" + opt.Region + ".srs", + URL: "https://gh-proxy.com/raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/country/geoip-" + opt.Region + ".srs", UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -706,7 +706,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geosite-" + opt.Region, Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://ghgo.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/country/geosite-" + opt.Region + ".srs", + URL: "https://gh-proxy.com/raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/country/geosite-" + opt.Region + ".srs", UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) From db83a0b4da6be2a208a6ae4a0bba9b6a02ff4f43 Mon Sep 17 00:00:00 2001 From: chenxudong2020 <872603935@qq.com> Date: Wed, 8 Jan 2025 15:06:55 +0000 Subject: [PATCH 4/9] proxy --- config/config.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/config/config.go b/config/config.go index 2d4b6b3c..d1b280a6 100644 --- a/config/config.go +++ b/config/config.go @@ -594,7 +594,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geosite-ads", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://gh-proxy.com/raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-category-ads-all.srs", + URL: "https://gh.api.99988866.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-category-ads-all.srs", UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -603,7 +603,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geosite-malware", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://gh-proxy.com/raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-malware.srs", + URL: "https://gh.api.99988866.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-malware.srs", UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -612,7 +612,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geosite-phishing", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://gh-proxy.com/raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-phishing.srs", + URL: "https://gh.api.99988866.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-phishing.srs", UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -621,7 +621,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geosite-cryptominers", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://gh-proxy.com/raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-cryptominers.srs", + URL: "https://gh.api.99988866.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-cryptominers.srs", UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -630,7 +630,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geoip-phishing", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://gh-proxy.com/raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geoip-phishing.srs", + URL: "https://gh.api.99988866.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geoip-phishing.srs", UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -639,7 +639,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geoip-malware", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://gh-proxy.com/raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geoip-malware.srs", + URL: "https://gh.api.99988866.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geoip-malware.srs", UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -697,7 +697,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geoip-" + opt.Region, Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://gh-proxy.com/raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/country/geoip-" + opt.Region + ".srs", + URL: "https://gh.api.99988866.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/country/geoip-" + opt.Region + ".srs", UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -706,7 +706,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geosite-" + opt.Region, Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://gh-proxy.com/raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/country/geosite-" + opt.Region + ".srs", + URL: "https://gh.api.99988866.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/country/geosite-" + opt.Region + ".srs", UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) From 1983bdbee3aa0867726fe1e1d4a3973a4fb3db27 Mon Sep 17 00:00:00 2001 From: chenxudong2020 <872603935@qq.com> Date: Thu, 9 Jan 2025 11:18:26 +0000 Subject: [PATCH 5/9] add web_ui_path --- config/config.go | 2 +- config/hiddify_option.go | 1 + v2/standalone.go | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config/config.go b/config/config.go index d1b280a6..60f088c6 100644 --- a/config/config.go +++ b/config/config.go @@ -274,8 +274,8 @@ func setClashAPI(options *option.Options, opt *HiddifyOptions) { ClashAPI: &option.ClashAPIOptions{ ExternalController: fmt.Sprintf("%s:%d", "127.0.0.1", opt.ClashApiPort), Secret: opt.ClashApiSecret, + ExternalUI: opt.ClashWebPath, }, - CacheFile: &option.CacheFileOptions{ Enabled: false, Path: "clash.db", diff --git a/config/hiddify_option.go b/config/hiddify_option.go index 5b13242e..98693fae 100644 --- a/config/hiddify_option.go +++ b/config/hiddify_option.go @@ -11,6 +11,7 @@ type HiddifyOptions struct { LogFile string `json:"log-file"` EnableClashApi bool `json:"enable-clash-api"` ClashApiPort uint16 `json:"clash-api-port"` + ClashWebPath string `json:"clash-web-path"` ClashApiSecret string `json:"web-secret"` Region string `json:"region"` BlockAds bool `json:"block-ads"` diff --git a/v2/standalone.go b/v2/standalone.go index 58fe9e42..d0eaae7f 100644 --- a/v2/standalone.go +++ b/v2/standalone.go @@ -167,7 +167,7 @@ func buildConfig(configContent string, options config.HiddifyOptions) (string, e } finalconfig.Log.Output = "" - finalconfig.Experimental.ClashAPI.ExternalUI = "/etc/s6-overlay/s6-rc.d/hiddify/webui" + // finalconfig.Experimental.ClashAPI.ExternalUI = "/etc/s6-overlay/s6-rc.d/hiddify/webui" if options.AllowConnectionFromLAN { finalconfig.Experimental.ClashAPI.ExternalController = "0.0.0.0:6756" } else { From a4329d630075aad6c11d0353eb13cd4d9a33e1bf Mon Sep 17 00:00:00 2001 From: chenxudong2020 <872603935@qq.com> Date: Fri, 10 Jan 2025 11:32:04 +0000 Subject: [PATCH 6/9] add user auth --- config/config.go | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 60f088c6..f7503e46 100644 --- a/config/config.go +++ b/config/config.go @@ -9,6 +9,8 @@ import ( "net" "net/netip" "net/url" + "os" + "regexp" "runtime" "strings" "time" @@ -16,6 +18,7 @@ import ( C "github.com/sagernet/sing-box/constant" "github.com/sagernet/sing-box/option" dns "github.com/sagernet/sing-dns" + "github.com/sagernet/sing/common/auth" ) const ( @@ -39,6 +42,30 @@ const ( InboundDNSTag = "dns-in" ) +func ReplaceEnvVariables(input string) string { + re := regexp.MustCompile(`\$\{(\w+)\}`) + return re.ReplaceAllStringFunc(input, func(m string) string { + varName := m[2 : len(m)-1] + return os.Getenv(varName) + }) +} + +func GetUsers() []auth.User { + username := os.Getenv("PROXY_USER") + password := os.Getenv("PROXY_PASS") + + if username == "" || password == "" { + return []auth.User{} + } + + return []auth.User{ + { + Username: username, + Password: password, + }, + } +} + var OutboundMainProxyTag = OutboundSelectTag func BuildConfigJson(configOpt HiddifyOptions, input option.Options) (string, error) { @@ -274,7 +301,7 @@ func setClashAPI(options *option.Options, opt *HiddifyOptions) { ClashAPI: &option.ClashAPIOptions{ ExternalController: fmt.Sprintf("%s:%d", "127.0.0.1", opt.ClashApiPort), Secret: opt.ClashApiSecret, - ExternalUI: opt.ClashWebPath, + ExternalUI: ReplaceEnvVariables(opt.ClashWebPath), }, CacheFile: &option.CacheFileOptions{ Enabled: false, @@ -365,6 +392,7 @@ func setInbound(options *option.Options, opt *HiddifyOptions) { DomainStrategy: inboundDomainStrategy, }, }, + Users: GetUsers(), SetSystemProxy: opt.SetSystemProxy, }, }, From 65439e9c9e8b8ddf4921bf6644e110fcc93eb96d Mon Sep 17 00:00:00 2001 From: chenxudong2020 <872603935@qq.com> Date: Fri, 10 Jan 2025 12:04:27 +0000 Subject: [PATCH 7/9] fix --- config/config.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/config.go b/config/config.go index f7503e46..9d68f8f0 100644 --- a/config/config.go +++ b/config/config.go @@ -296,6 +296,8 @@ func setClashAPI(options *option.Options, opt *HiddifyOptions) { if opt.EnableClashApi { if opt.ClashApiSecret == "" { opt.ClashApiSecret = generateRandomString(16) + } else { + opt.ClashApiSecret = ReplaceEnvVariables(opt.ClashApiSecret) } options.Experimental = &option.ExperimentalOptions{ ClashAPI: &option.ClashAPIOptions{ From 30e654cbda114c46e2075563bd5f413fd9fd0c5c Mon Sep 17 00:00:00 2001 From: chenxudong2020 <872603935@qq.com> Date: Sat, 11 Jan 2025 01:15:25 +0000 Subject: [PATCH 8/9] fix users init --- config/config.go | 29 ++++++++++++++--------------- config/hiddify_option.go | 20 +++++++++++--------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/config/config.go b/config/config.go index 9d68f8f0..dd73b271 100644 --- a/config/config.go +++ b/config/config.go @@ -50,20 +50,19 @@ func ReplaceEnvVariables(input string) string { }) } -func GetUsers() []auth.User { - username := os.Getenv("PROXY_USER") - password := os.Getenv("PROXY_PASS") - - if username == "" || password == "" { - return []auth.User{} - } - - return []auth.User{ - { - Username: username, - Password: password, - }, - } +func GetUsers(opt *HiddifyOptions) []auth.User { + var newUsers []auth.User + for _, user := range opt.InboundOptions.Users { + newUsername := ReplaceEnvVariables(user.Username) + newPassword := ReplaceEnvVariables(user.Password) + if newUsername != "" && newPassword != "" { + newUsers = append(newUsers, auth.User{ + Username: newUsername, + Password: newPassword, + }) + } + } + return newUsers } var OutboundMainProxyTag = OutboundSelectTag @@ -394,7 +393,7 @@ func setInbound(options *option.Options, opt *HiddifyOptions) { DomainStrategy: inboundDomainStrategy, }, }, - Users: GetUsers(), + Users: GetUsers(opt), SetSystemProxy: opt.SetSystemProxy, }, }, diff --git a/config/hiddify_option.go b/config/hiddify_option.go index 98693fae..53ed9915 100644 --- a/config/hiddify_option.go +++ b/config/hiddify_option.go @@ -3,6 +3,7 @@ package config import ( "github.com/sagernet/sing-box/option" dns "github.com/sagernet/sing-dns" + "github.com/sagernet/sing/common/auth" ) type HiddifyOptions struct { @@ -40,15 +41,16 @@ type DNSOptions struct { } type InboundOptions struct { - EnableTun bool `json:"enable-tun"` - EnableTunService bool `json:"enable-tun-service"` - SetSystemProxy bool `json:"set-system-proxy"` - MixedPort uint16 `json:"mixed-port"` - TProxyPort uint16 `json:"tproxy-port"` - LocalDnsPort uint16 `json:"local-dns-port"` - MTU uint32 `json:"mtu"` - StrictRoute bool `json:"strict-route"` - TUNStack string `json:"tun-implementation"` + EnableTun bool `json:"enable-tun"` + EnableTunService bool `json:"enable-tun-service"` + SetSystemProxy bool `json:"set-system-proxy"` + MixedPort uint16 `json:"mixed-port"` + TProxyPort uint16 `json:"tproxy-port"` + LocalDnsPort uint16 `json:"local-dns-port"` + MTU uint32 `json:"mtu"` + StrictRoute bool `json:"strict-route"` + TUNStack string `json:"tun-implementation"` + Users []auth.User `json:"users,omitempty"` } type URLTestOptions struct { From 51728305443234548e5114695234e68d2bbe91ea Mon Sep 17 00:00:00 2001 From: chenxudong2020 <872603935@qq.com> Date: Sat, 11 Jan 2025 01:51:28 +0000 Subject: [PATCH 9/9] remove download link --- config/config.go | 17 +++++++++-------- config/hiddify_option.go | 13 +++++++++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/config/config.go b/config/config.go index dd73b271..87b9e11c 100644 --- a/config/config.go +++ b/config/config.go @@ -623,7 +623,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geosite-ads", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://gh.api.99988866.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-category-ads-all.srs", + URL: opt.GeositeConfigOptions.GeositeAds, UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -632,7 +632,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geosite-malware", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://gh.api.99988866.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-malware.srs", + URL: opt.GeositeConfigOptions.GeositeMalware, UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -641,7 +641,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geosite-phishing", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://gh.api.99988866.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-phishing.srs", + URL: opt.GeositeConfigOptions.GeositePhishing, UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -650,7 +650,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geosite-cryptominers", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://gh.api.99988866.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geosite-cryptominers.srs", + URL: opt.GeositeConfigOptions.GeositeCryptominers, UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -659,7 +659,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geoip-phishing", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://gh.api.99988866.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geoip-phishing.srs", + URL: opt.GeositeConfigOptions.GeoipPhishing, UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -668,7 +668,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geoip-malware", Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://gh.api.99988866.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/block/geoip-malware.srs", + URL: opt.GeositeConfigOptions.GeoipMalware, UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -701,6 +701,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { }) } + opt.Region = ReplaceEnvVariables(opt.Region) if opt.Region != "other" { dnsRules = append(dnsRules, option.DefaultDNSRule{ DomainSuffix: []string{"." + opt.Region}, @@ -726,7 +727,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geoip-" + opt.Region, Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://gh.api.99988866.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/country/geoip-" + opt.Region + ".srs", + URL: ReplaceEnvVariables(opt.GeositeConfigOptions.GeoipRegion), UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) @@ -735,7 +736,7 @@ func setRoutingOptions(options *option.Options, opt *HiddifyOptions) { Tag: "geosite-" + opt.Region, Format: C.RuleSetFormatBinary, RemoteOptions: option.RemoteRuleSet{ - URL: "https://gh.api.99988866.xyz/https://raw.githubusercontent.com/hiddify/hiddify-geo/rule-set/country/geosite-" + opt.Region + ".srs", + URL: ReplaceEnvVariables(opt.GeositeConfigOptions.GeositeRegion), UpdateInterval: option.Duration(5 * time.Hour * 24), }, }) diff --git a/config/hiddify_option.go b/config/hiddify_option.go index 53ed9915..af1c828d 100644 --- a/config/hiddify_option.go +++ b/config/hiddify_option.go @@ -28,6 +28,19 @@ type HiddifyOptions struct { InboundOptions URLTestOptions RouteOptions + GeositeConfigOptions +} + +// Move the download link to the configuration file +type GeositeConfigOptions struct { + GeositeAds string `json:"geosite-ads"` + GeositeMalware string `json:"geosite-malware"` + GeositePhishing string `json:"geosite-phishing"` + GeositeCryptominers string `json:"geosite-cryptominers"` + GeoipPhishing string `json:"geoip-phishing"` + GeoipMalware string `json:"geoip-malware"` + GeoipRegion string `json:"geoip-region"` + GeositeRegion string `json:"geosite-region"` } type DNSOptions struct {