diff --git a/api/controller/default.go b/api/controller/default.go index 4ff52a4..55a9d4e 100644 --- a/api/controller/default.go +++ b/api/controller/default.go @@ -74,7 +74,7 @@ func BuildSub(clashType model.ClashType, query validator.SubValidator, template } // 解析订阅 err = yaml.Unmarshal(data, &sub) - newProxies := make([]model.Proxy, 0) + var newProxies []model.Proxy if err != nil { reg, _ := regexp.Compile("(ssr|ss|vmess|trojan|vless|hysteria)://") if reg.Match(data) { @@ -157,10 +157,6 @@ func BuildSub(clashType model.ClashType, query validator.SubValidator, template for i := range proxyList { // 重命名匹配到的节点 for j, v := range replaceRegs { - if err != nil { - logger.Logger.Debug("replace regexp compile failed", zap.Error(err)) - return nil, errors.New("replaceName 参数非法: " + err.Error()) - } if v.MatchString(proxyList[i].Name) { proxyList[i].Name = v.ReplaceAllString( proxyList[i].Name, query.ReplaceTo[j], @@ -200,7 +196,7 @@ func BuildSub(clashType model.ClashType, query validator.SubValidator, template sort.Sort(model.ProxyGroupsSortByName(t.ProxyGroups)) } // 合并新节点和模板 - MergeSubAndTemplate(temp, t) + MergeSubAndTemplate(temp, t, query.IgnoreCountryGrooup) // 处理自定义规则 for _, v := range query.Rules { if v.Prepend { @@ -233,7 +229,7 @@ func BuildSub(clashType model.ClashType, query validator.SubValidator, template return temp, nil } -func MergeSubAndTemplate(temp *model.Subscription, sub *model.Subscription) { +func MergeSubAndTemplate(temp *model.Subscription, sub *model.Subscription, igcg bool) { // 只合并节点、策略组 // 统计所有国家策略组名称 var countryGroupNames []string @@ -284,5 +280,7 @@ func MergeSubAndTemplate(temp *model.Subscription, sub *model.Subscription) { } temp.ProxyGroups[i].Proxies = newProxies } - temp.ProxyGroups = append(temp.ProxyGroups, sub.ProxyGroups...) + if !igcg { + temp.ProxyGroups = append(temp.ProxyGroups, sub.ProxyGroups...) + } } diff --git a/api/static/index.html b/api/static/index.html index 0bc756c..367fd4d 100644 --- a/api/static/index.html +++ b/api/static/index.html @@ -1,22 +1,16 @@ + - - + + sub2clash - + - + @@ -26,260 +20,156 @@ } .btn-xs { - padding: 2px 2px; /* 调整内边距以减小按钮大小 */ - font-size: 10px; /* 设置字体大小 */ - line-height: 1.2; /* 调整行高 */ - border-radius: 3px; /* 可选的边框半径调整 */ + padding: 2px 2px; + /* 调整内边距以减小按钮大小 */ + font-size: 10px; + /* 设置字体大小 */ + line-height: 1.2; + /* 调整行高 */ + border-radius: 3px; + /* 可选的边框半径调整 */ height: 25px; width: 25px; } + -
-
-

sub2clash

- 通用订阅链接转 Clash(Meta) 配置工具 - 使用文档
注意:本程序非纯前端程序,输入的订阅将被后端缓存,请确保您信任当前站点 -
+
+
+

sub2clash

+ 通用订阅链接转 Clash(Meta) 配置工具 + 使用文档
注意:本程序非纯前端程序,输入的订阅将被后端缓存,请确保您信任当前站点 +
- -
- -
- - +
+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
-
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- -
- - - -
-
- - - - + +
+ +
+ + + +
+
+ + + + +
+ +
+

+ Powered by + sub2clash +

+

Version {{.Version}}

+
- - -
- + + \ No newline at end of file diff --git a/api/static/index.js b/api/static/index.js index 388205c..5e54520 100644 --- a/api/static/index.js +++ b/api/static/index.js @@ -6,6 +6,7 @@ function clearExistingValues() { document.getElementById("refresh").checked = false; document.getElementById("autoTest").checked = false; document.getElementById("lazy").checked = false; + document.getElementById("igcg").checked = false; document.getElementById("template").value = ""; document.getElementById("sort").value = "nameasc"; document.getElementById("remove").value = ""; @@ -74,6 +75,8 @@ function generateURI() { queryParams.push(`lazy=${lazy ? "true" : "false"}`); const nodeList = document.getElementById("nodeList").checked; queryParams.push(`nodeList=${nodeList ? "true" : "false"}`); + const igcg = document.getElementById("igcg").checked; + queryParams.push(`ignoreCountryGroup=${igcg ? "true" : "false"}`); // 获取模板链接或名称(如果存在) const template = document.getElementById("template").value; diff --git a/utils/proxy.go b/utils/proxy.go index 16ed5ff..e483f10 100644 --- a/utils/proxy.go +++ b/utils/proxy.go @@ -65,17 +65,11 @@ func AddProxy( countryName := GetContryName(proxy.Name) for i := range sub.ProxyGroups { group := &sub.ProxyGroups[i] - if group.Name == countryName { group.Proxies = append(group.Proxies, proxy.Name) group.Size++ haveProxyGroup = true } - - if group.Name == "手动切换" { - group.Proxies = append(group.Proxies, proxy.Name) - group.Size++ - } } if !haveProxyGroup { var newGroup model.ProxyGroup diff --git a/utils/sub.go b/utils/sub.go index d7442b1..bad44dd 100644 --- a/utils/sub.go +++ b/utils/sub.go @@ -81,8 +81,5 @@ func FetchSubscriptionFromAPI(url string) ([]byte, error) { if err != nil { return nil, fmt.Errorf("failed to write to sub.yaml: %w", err) } - if err != nil { - return nil, fmt.Errorf("failed to unmarshal yaml: %w", err) - } return data, nil } diff --git a/utils/template.go b/utils/template.go index 45bf68a..6772a46 100644 --- a/utils/template.go +++ b/utils/template.go @@ -25,9 +25,6 @@ func LoadTemplate(template string) ([]byte, error) { if err != nil { return nil, err } - if err != nil { - return nil, err - } return result, nil } return nil, errors.New("模板文件不存在") diff --git a/validator/sub.go b/validator/sub.go index ea9dd8d..1557257 100644 --- a/validator/sub.go +++ b/validator/sub.go @@ -12,24 +12,25 @@ import ( ) type SubValidator struct { - Sub string `form:"sub" binding:""` - Subs []string `form:"-" binding:""` - Proxy string `form:"proxy" binding:""` - Proxies []string `form:"-" binding:""` - Refresh bool `form:"refresh,default=false" binding:""` - Template string `form:"template" binding:""` - RuleProvider string `form:"ruleProvider" binding:""` - RuleProviders []RuleProviderStruct `form:"-" binding:""` - Rule string `form:"rule" binding:""` - Rules []RuleStruct `form:"-" binding:""` - AutoTest bool `form:"autoTest,default=false" binding:""` - Lazy bool `form:"lazy,default=false" binding:""` - Sort string `form:"sort" binding:""` - Remove string `form:"remove" binding:""` - Replace string `form:"replace" binding:""` - ReplaceKeys []string `form:"-" binding:""` - ReplaceTo []string `form:"-" binding:""` - NodeListMode bool `form:"nodeList,default=false" binding:""` + Sub string `form:"sub" binding:""` + Subs []string `form:"-" binding:""` + Proxy string `form:"proxy" binding:""` + Proxies []string `form:"-" binding:""` + Refresh bool `form:"refresh,default=false" binding:""` + Template string `form:"template" binding:""` + RuleProvider string `form:"ruleProvider" binding:""` + RuleProviders []RuleProviderStruct `form:"-" binding:""` + Rule string `form:"rule" binding:""` + Rules []RuleStruct `form:"-" binding:""` + AutoTest bool `form:"autoTest,default=false" binding:""` + Lazy bool `form:"lazy,default=false" binding:""` + Sort string `form:"sort" binding:""` + Remove string `form:"remove" binding:""` + Replace string `form:"replace" binding:""` + ReplaceKeys []string `form:"-" binding:""` + ReplaceTo []string `form:"-" binding:""` + NodeListMode bool `form:"nodeList,default=false" binding:""` + IgnoreCountryGrooup bool `form:"ignoreCountryGroup,default=false" binding:""` } type RuleProviderStruct struct {