88import java .lang .reflect .Executable ;
99import java .lang .reflect .InvocationTargetException ;
1010import java .lang .reflect .Method ;
11+ import java .net .IDN ;
1112import java .net .InetAddress ;
1213import java .net .MalformedURLException ;
1314import java .net .URL ;
@@ -32,6 +33,29 @@ public static class InetAdvice {
3233 // Since we have to wrap a native Java Class stuff gets more complicated
3334 // The classpath is not the same anymore, and we can't import our modules directly.
3435 // To bypass this issue we load collectors from a .jar file
36+
37+ // Java's system resolver rejects non-ASCII hostnames, so convert IDN to Punycode
38+ // before the real lookup runs. Without this, getAllByName throws UnknownHostException
39+ // and OnMethodExit never fires — meaning DNSRecordCollector can't block or track
40+ // the hostname.
41+ @ Advice .OnMethodEnter (suppress = Throwable .class )
42+ public static void before (
43+ @ Advice .Argument (value = 0 , readOnly = false ) String hostname
44+ ) {
45+ if (hostname == null ) {
46+ return ;
47+ }
48+ for (int i = 0 ; i < hostname .length (); i ++) {
49+ if (hostname .charAt (i ) > 0x7F ) {
50+ try {
51+ hostname = IDN .toASCII (hostname , IDN .ALLOW_UNASSIGNED );
52+ } catch (IllegalArgumentException ignored ) {
53+ }
54+ return ;
55+ }
56+ }
57+ }
58+
3559 @ Advice .OnMethodExit
3660 public static void after (
3761 @ Advice .Argument (0 ) String hostname ,
0 commit comments