实现基础的DDoS防护

This commit is contained in:
刘祥超
2022-05-18 21:03:51 +08:00
parent 45620dcdb7
commit 9bdd9a433c
31 changed files with 2605 additions and 58 deletions

View File

@@ -1,6 +1,7 @@
package utils
import (
"sort"
"strings"
"unsafe"
)
@@ -36,6 +37,22 @@ func FormatAddressList(addrList []string) []string {
return result
}
// ToValidUTF8string 去除字符串中的非UTF-8字符
func ToValidUTF8string(v string) string {
return strings.ToValidUTF8(v, "")
}
// ContainsSameStrings 检查两个字符串slice内容是否一致
func ContainsSameStrings(s1 []string, s2 []string) bool {
if len(s1) != len(s2) {
return false
}
sort.Strings(s1)
sort.Strings(s2)
for index, v1 := range s1 {
if v1 != s2[index] {
return false
}
}
return true
}