relay/internal/util/obfuscation.go
2022-08-05 14:39:03 -07:00

31 lines
494 B
Go

package util
func ValidateDomainObfuscation(domain, obfuscationDomain string) bool {
if len([]rune(domain)) != len([]rune(obfuscationDomain)) {
return false
}
for i := 0; i < len([]rune(domain)); i++ {
dRune := []rune(domain)[i]
odRune := []rune(obfuscationDomain)[i]
switch dRune {
case '.':
if odRune != '.' {
return false
}
default:
switch odRune {
case dRune:
continue
case '*':
continue
default:
return false
}
}
}
return true
}