Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

roidelapluie
Copy link
Member

Fixes #626

Signed-off-by: Julien Pivotto [email protected]

@roidelapluie roidelapluie force-pushed the dina branch 2 times, most recently from a5f9121 to 474f012 Compare June 15, 2020 23:29
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)
Copy link
Contributor

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?

Copy link
Member Author

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

@brian-brazil
Copy link
Contributor

CI doesn't seem happy, it's timing out.

@roidelapluie
Copy link
Member Author

Yes, locally as well

@roidelapluie
Copy link
Member Author

I have fixed the test


func internationalizeDNSDomain(logger log.Logger, domain string) string {
idnaDomain, err := idna.Lookup.ToASCII(domain)
if err != nil {
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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)
...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@brian-brazil
Copy link
Contributor

:: 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)
Copy link
Contributor

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.

@SuperQ
Copy link
Member

SuperQ commented Jan 22, 2022

Ping, this needs a rebase.

@InsanePrawn
Copy link

@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.

@InsanePrawn
Copy link

Nevermind, I didn't realise this doesn't affect the http prober. Opened #1192.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IDN (Internationalized domain names) support
5 participants