mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-12-26 04:06:35 +08:00
提升通过域名查找服务的性能,轻松支持海量域名
This commit is contained in:
@@ -27,6 +27,10 @@ func MatchDomain(pattern string, domain string) (isMatched bool) {
|
||||
return
|
||||
}
|
||||
|
||||
if pattern == domain {
|
||||
return true
|
||||
}
|
||||
|
||||
if pattern == "*" {
|
||||
return true
|
||||
}
|
||||
@@ -61,3 +65,19 @@ func MatchDomain(pattern string, domain string) (isMatched bool) {
|
||||
}
|
||||
return isMatched
|
||||
}
|
||||
|
||||
// IsFuzzyDomain 判断是否为特殊域名
|
||||
func IsFuzzyDomain(domain string) bool {
|
||||
if len(domain) == 0 {
|
||||
return true
|
||||
}
|
||||
if domain[0] == '.' || domain[0] == '~' {
|
||||
return true
|
||||
}
|
||||
for _, c := range domain {
|
||||
if c == '*' {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user