Skip to content

Commit

Permalink
fix(resolver): IPv4 Base32 Crockford does not match Hexa
Browse files Browse the repository at this point in the history
  • Loading branch information
Damien Abos committed Jan 7, 2023
1 parent 1331916 commit 2297129
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/backend/ipv4b32crockford_builtin_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewIPv4B32CrockfordResolver(settings map[string]interface{}) *IPv4B32Crockf
var ttl uint32
domain, _ = settings["domain"].(string)
ttl, _ = settings["ttl"].(uint32)
pattern = fmt.Sprintf("([0123456789abcdefghjkmnpqrstvwxyzABCDEFGHJKMNPQRSTVWXYZ]{5,7})\\.%s$", strings.ReplaceAll(domain, ".", "\\."))
pattern = fmt.Sprintf("(^|\\.)([0123456789abcdefghjkmnpqrstvwxyzABCDEFGHJKMNPQRSTVWXYZ]{5,7})\\.%s$", strings.ReplaceAll(domain, ".", "\\."))
re, _ := regexp.Compile(pattern)
return &IPv4B32CrockfordResolver{
settings: settings,
Expand All @@ -44,7 +44,7 @@ func (resolver *IPv4B32CrockfordResolver) Lookup(qtype string, qname string, _ s
if qtype == A || qtype == AAAA || qtype == ANY {
a := resolver.regexp.FindStringSubmatch(qname)
if len(a) > 1 {
lower := strings.ToLower(a[1])
lower := strings.ToLower(a[2])
if len(lower) == 6 {
// add padding
lower = fmt.Sprintf("0%s", lower)
Expand Down

0 comments on commit 2297129

Please sign in to comment.