️ Improve

This commit is contained in:
2024-08-11 23:55:47 +08:00
parent dedbf2bc03
commit 3cfa4bdf24
24 changed files with 204 additions and 304 deletions

View File

@ -11,7 +11,7 @@ import (
)
func GetContryName(countryKey string) string {
// 创建一个切片包含所有的国家映射
countryMaps := []map[string]string{
model.CountryFlag,
model.CountryChineseName,
@ -19,11 +19,9 @@ func GetContryName(countryKey string) string {
model.CountryEnglishName,
}
// 对每一个映射进行检查
for i, countryMap := range countryMaps {
if i == 2 {
// 对ISO匹配做特殊处理
// 根据常用分割字符分割字符串
splitChars := []string{"-", "_", " "}
key := make([]string, 0)
for _, splitChar := range splitChars {
@ -34,9 +32,9 @@ func GetContryName(countryKey string) string {
}
}
}
// 对每一个分割后的字符串进行检查
for _, v := range key {
// 如果匹配到了国家
if country, ok := countryMap[strings.ToUpper(v)]; ok {
return country
}
@ -56,7 +54,7 @@ func AddProxy(
lazy bool, clashType model.ClashType, proxies ...model.Proxy,
) {
proxyTypes := model.GetSupportProxyTypes(clashType)
// 添加节点
for _, proxy := range proxies {
if !proxyTypes[proxy.Type] {
continue
@ -106,7 +104,7 @@ func ParseProxy(proxies ...string) []model.Proxy {
if proxy != "" {
var proxyItem model.Proxy
var err error
// 解析节点
if strings.HasPrefix(proxy, constant.ShadowsocksPrefix) {
proxyItem, err = parser.ParseShadowsocks(proxy)
}