completely save config with toml format

This commit is contained in:
杨黄林
2023-09-17 01:35:42 +08:00
parent 2f79a5d093
commit 7c30c6d150
13 changed files with 398 additions and 207 deletions

View File

@@ -78,7 +78,7 @@ func (c *HandleController) JudgePort(content *plugin.NewProxyContent) plugin.Res
}
proxyType := content.ProxyType
if StringIndexOf(proxyType, supportProxyTypes) == -1 {
if stringContains(proxyType, supportProxyTypes) {
log.Printf("proxy type [%v] not support, plugin do nothing", proxyType)
res.Unchange = true
return res
@@ -100,12 +100,12 @@ func (c *HandleController) JudgePort(content *plugin.NewProxyContent) plugin.Res
portErr = fmt.Errorf("user [%v] port range [%v] format error", user, port)
break
}
start, err := strconv.Atoi(strings.TrimSpace(allowedRanges[0]))
start, err := strconv.Atoi(trimString(allowedRanges[0]))
if err != nil {
portErr = fmt.Errorf("user [%v] port rang [%v] start port [%v] is not a number", user, port, allowedRanges[0])
break
}
end, err := strconv.Atoi(strings.TrimSpace(allowedRanges[1]))
end, err := strconv.Atoi(trimString(allowedRanges[1]))
if err != nil {
portErr = fmt.Errorf("user [%v] port rang [%v] end port [%v] is not a number", user, port, allowedRanges[0])
break
@@ -141,7 +141,7 @@ func (c *HandleController) JudgePort(content *plugin.NewProxyContent) plugin.Res
if portAllowed {
if token, exist := c.Tokens[user]; exist {
for _, userDomain := range userDomains {
if StringIndexOf(userDomain, token.Domains) == -1 {
if stringContains(userDomain, token.Domains) {
domainAllowed = false
break
}
@@ -183,12 +183,3 @@ func (c *HandleController) JudgePort(content *plugin.NewProxyContent) plugin.Res
}
return res
}
func StringIndexOf(element string, data []string) int {
for k, v := range data {
if element == v {
return k
}
}
return -1
}