-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for IDNA #640
base: master
Are you sure you want to change the base?
Add support for IDNA #640
Conversation
a5f9121
to
474f012
Compare
prober/utils.go
Outdated
@@ -119,3 +126,14 @@ func ipHash(ip net.IP) float64 { | |||
h.Write(ip) | |||
return float64(h.Sum32()) | |||
} | |||
|
|||
func internationalizeDNSTarget(logger log.Logger, target string) (string, error) { | |||
idnaTarget, err := idna.ToASCII(target) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use the lookup profile here rather than the raw punycode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to use idna.Lookup.ToASCII
CI doesn't seem happy, it's timing out. |
Yes, locally as well |
I have fixed the test |
|
||
func internationalizeDNSDomain(logger log.Logger, domain string) string { | ||
idnaDomain, err := idna.Lookup.ToASCII(domain) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should be silently ignoring errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somehow we pass :: in some tests, which creates an error disallowed rune U+003A. I need to investigate why, but I was thinking that it would be safe to ignore those errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what's going on here.
You have to try to handle the hostname as an IP address (either IPv4 or IPv6), net.ParseIP
will do this for you, and if that fails handle it as a hostname and apply a punycode transformation to it.
Basically:
if net.ParseIP(domain) != nil {
return domain
}
idnaDomain, err := idna.Lookup.ToASCII(domain)
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
:: is an ipv6 version of 0.0.0.0, so it's a valid IP address. |
Signed-off-by: Julien Pivotto <[email protected]>
@@ -248,11 +248,13 @@ func ProbeDNS(ctx context.Context, target string, module config.Module, registry | |||
} | |||
} | |||
|
|||
queryName := internationalizeDNSDomain(logger, module.DNS.QueryName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is correct, let's leave this out.
Ping, this needs a rebase. |
@SuperQ I'm not the original author but I gave it a rebase here d6f6a341b4ad7b21886855739a7e9cd292b6e446 and tests seem to pass. Let me know if you need me to open my own MR. |
Nevermind, I didn't realise this doesn't affect the http prober. Opened #1192. |
Fixes #626
Signed-off-by: Julien Pivotto [email protected]