换成单集群模式
This commit is contained in:
@@ -173,6 +173,10 @@ func (this *DDoSProtectionManager) addTCPRules(tcpConfig *ddosconfigs.TCPConfig)
|
||||
|
||||
var ports = []int32{}
|
||||
for _, portConfig := range tcpConfig.Ports {
|
||||
// 校验端口范围
|
||||
if portConfig.Port <= 0 || portConfig.Port > 65535 {
|
||||
continue
|
||||
}
|
||||
if !lists.ContainsInt32(ports, portConfig.Port) {
|
||||
ports = append(ports, portConfig.Port)
|
||||
}
|
||||
@@ -367,7 +371,19 @@ func (this *DDoSProtectionManager) encodeUserData(attrs []string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
return "ZZ" + strings.Join(attrs, "_") + "ZZ"
|
||||
// 清洗每个属性值,只保留字母、数字和横杠
|
||||
var safeAttrs = make([]string, len(attrs))
|
||||
for i, attr := range attrs {
|
||||
var safe strings.Builder
|
||||
for _, c := range attr {
|
||||
if (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '-' {
|
||||
safe.WriteRune(c)
|
||||
}
|
||||
}
|
||||
safeAttrs[i] = safe.String()
|
||||
}
|
||||
|
||||
return "ZZ" + strings.Join(safeAttrs, "_") + "ZZ"
|
||||
}
|
||||
|
||||
// 解码user data
|
||||
|
||||
Reference in New Issue
Block a user