fix(proxy): replace string literals with constants for proxy group types

This commit is contained in:
Chang lue Tsen 2025-04-29 18:09:53 +09:00
parent 6d13060aeb
commit 55ef348135

View File

@ -91,7 +91,7 @@ func addProxyToGroup(proxyName, groupName string, groups []proxy.Group) []proxy.
}
groups = append(groups, proxy.Group{
Name: groupName,
Type: "select",
Type: proxy.GroupTypeSelect,
Proxies: []string{proxyName},
})
return groups
@ -101,10 +101,10 @@ func adapterRules(groups []*server.RuleGroup) (proxyGroup []proxy.Group, rules [
for _, group := range groups {
proxyGroup = append(proxyGroup, proxy.Group{
Name: group.Name,
Type: "select",
Type: proxy.GroupTypeSelect,
Proxies: RemoveEmptyString(strings.Split(group.Tags, ",")),
})
rules = append(rules, strings.Split(group.Rules, "/n")...)
rules = append(rules, strings.Split(group.Rules, "\n")...)
}
return
}
@ -114,14 +114,14 @@ func generateProxyGroup(servers []proxy.Proxy) (proxyGroup []proxy.Group, region
proxyGroup = append(proxyGroup, []proxy.Group{
{
Name: "智能线路",
Type: "url-test",
Type: proxy.GroupTypeURLTest,
Proxies: make([]string, 0),
URL: "https://www.gstatic.com/generate_204",
Interval: 300,
},
{
Name: "手动选择",
Type: "select",
Type: proxy.GroupTypeSelect,
Proxies: []string{"智能线路"},
},
}...)
@ -130,8 +130,10 @@ func generateProxyGroup(servers []proxy.Proxy) (proxyGroup []proxy.Group, region
if node.Country != "" {
proxyGroup = addProxyToGroup(node.Name, node.Country, proxyGroup)
region = append(region, node.Country)
proxyGroup = addProxyToGroup(node.Country, "智能线路", proxyGroup)
}
proxyGroup = addProxyToGroup(node.Name, "手动选择", proxyGroup)
}
proxyGroup = addProxyToGroup("DIRECT", "手动选择", proxyGroup)