Skip to content

Support IDN targets via punycode conversion - #1633

Open
locker95 wants to merge 1 commit into
prometheus:masterfrom
locker95:fix/idn-punycode-626
Open

Support IDN targets via punycode conversion#1633
locker95 wants to merge 1 commit into
prometheus:masterfrom
locker95:fix/idn-punycode-626

Conversation

@locker95

Copy link
Copy Markdown

Description

Unicode hostnames such as http://мтр24.рф fail DNS with no such host, while the punycode form works. Blackbox resolves hosts itself, so IDN never reaches Go's net/http IDNA handling.

Convert hostnames to ASCII with golang.org/x/net/idna (already a dependency via x/net) before:

  • DNS resolution (chooseProtocol — covers HTTP/TCP/ICMP/DNS/gRPC targets)
  • HTTP Host / default TLS SNI
  • DNS query_name and DoT SNI
  • TCP / gRPC default SNI

ASCII names and IP addresses are left unchanged. Logs keep the original target label; only the resolved name is rewritten.

How to verify

go test ./prober/ -run TestIdnaToASCII -count=1
go test ./prober/ -short -count=1

# optional: probe an IDN target
# curl 'http://localhost:9115/probe?module=http_2xx&target=http://мтр24.рф&debug=true'
[ENHANCEMENT] Convert IDN hostnames to punycode so HTTP/DNS/TCP/ICMP/gRPC probes resolve Unicode targets #626

Fixes #626

DNS lookups reject Unicode hostnames ("no such host"), so convert
names to ASCII with golang.org/x/net/idna before resolving and before
setting SNI / DNS query names. ASCII names and IP addresses are
unchanged.

Fixes prometheus#626

Signed-off-by: Dean Chen <862469039@qq.com>
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

1 participant