Comments (4)
Thank you, we'll take a look into this when possible
from graal.
Complete Java classes for debugging purposes 🙏
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
import java.util.Hashtable;
public class Test {
public static String getDnsTxtValue(String domain) throws NamingException {
Hashtable<String, String> env = new Hashtable<>();
env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
DirContext dirContext = new InitialDirContext(env);
//There is an exception here
Attributes attrs = dirContext.getAttributes(domain, new String[] { "TXT" });
Attribute txt = attrs.get("TXT");
NamingEnumeration<?> e = txt.getAll();
String value = null;
while (e.hasMore()) {
value = e.next().toString();
}
return value;
}
public static void main(String[] args) throws NamingException {
//The record type here is TXT
System.out.println(getDnsTxtValue("_acme-challenge.example.com"));
}
}
from graal.
Before fixing this issue, you can use nslookup and Process to solve it
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
public class Test {
public static List<String> getTXTRecord(String domain) throws IOException, InterruptedException {
List<String> txtRecords = new ArrayList<>();
// 使用 ProcessBuilder 运行 nslookup 命令
var pb = new ProcessBuilder("nslookup", "-query=TXT", domain);
var process = pb.start();
// 读取命令输出
try (var reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
String line;
boolean recordFound = false;
while ((line = reader.readLine()) != null) {
// 检查是否为TXT记录
if (line.contains("text =")) {
recordFound = true;
}
// 获取TXT记录值部分
if (recordFound && line.trim().startsWith("\"")) {
txtRecords.add(line.trim().replace("\"", ""));
}
}
}
process.waitFor();
return txtRecords;
}
public static void main(String[] args) throws IOException, InterruptedException {
//The record type here is TXT
// 示例域名
String domain = "_acme-challenge.example.com";
List<String> txtRecords = getTXTRecord(domain);
// 输出TXT记录值
txtRecords.forEach(record -> System.out.println("TXT Record: " + record));
}
}
from graal.
I tested the code from here: #9597 (comment)
it didn't run correctly as a java code
>java Test
Exception in thread "main" javax.naming.NameNotFoundException: DNS name not found [response code 3]; remaining name '_acme-challenge.example.com'
at jdk.naming.dns/com.sun.jndi.dns.DnsClient.checkResponseCode(DnsClient.java:659)
at jdk.naming.dns/com.sun.jndi.dns.DnsClient.isMatchResponse(DnsClient.java:577)
at jdk.naming.dns/com.sun.jndi.dns.DnsClient.doUdpQuery(DnsClient.java:429)
at jdk.naming.dns/com.sun.jndi.dns.DnsClient.query(DnsClient.java:214)
at jdk.naming.dns/com.sun.jndi.dns.Resolver.query(Resolver.java:81)
at jdk.naming.dns/com.sun.jndi.dns.DnsContext.c_getAttributes(DnsContext.java:434)
at java.naming/com.sun.jndi.toolkit.ctx.ComponentDirContext.p_getAttributes(ComponentDirContext.java:235)
at java.naming/com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:141)
at java.naming/com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:129)
at java.naming/javax.naming.directory.InitialDirContext.getAttributes(InitialDirContext.java:171)
at Test.getDnsTxtValue(Test.java:16)
at Test.main(Test.java:28)
Is there something missing in the code?
from graal.
Related Issues (20)
- [GR-57707] native-image-agent omits String[] from "serialization" when using newConstructorForSerialization HOT 3
- Graal Initialization Failure - Intel i3 Processors 2nd Gen HOT 3
- [GR-57831] StringLatin1.charAt has a substantially supoptimal translation HOT 8
- [GR-57845] Java/Espresso Support: EspressoFinalReference NoSuchMethodError
- Build akka with nativeImageRunAgent warning for java.lang.IndexOutOfBoundsException HOT 1
- [native-image] Runtime error when using java.lang.reflect.Array in library HOT 1
- java.lang.UnsatisfiedLinkError: com.fazecast.jSerialComm.SerialPort.getCommPortsNative() HOT 2
- Trying to generate native image graalVM with quarkus app on Windows doesn't work HOT 1
- com.oracle.svm.core.jdk.UnsupportedFeatureError: SerializationConstructorAccessor class not found for declaringClass: java.time.Ser HOT 1
- AudioSystem.getMixerInfo() returns empty list in native image
- Class.forName does not respect ClassLoader parameter
- [GR-58048] Unexpected process finished for GraalVM for JDK 22 HOT 1
- How to compile as static object file .o (not shared object)? HOT 1
- graalvm Improvements to the way metadata is generated,Metadata is generated by the class name directory, which makes it easy to troubleshoot missing metadata HOT 1
- When using new Date() in JavaScript, if the system time is changed, the returned value is still the time before the modification HOT 1
- The build crashed with $ mx build on IBM Semeru 21 LTS JDK HOT 4
- The build failed with compilation error and $ mx build on Open JDK 21 LTS JDK HOT 1
- Fatal error: com.oracle.graal.pointsto.util.AnalysisError$ParsingError: Error encountered while parsing com.oracle.svm.core.thread.Target_java_lang_VirtualThread.threadState(Target_java_lang_VirtualThread.java:167) HOT 1
- Java Runtime Error (SIGILL) on AWS Graviton using GraalVM JDK 17 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graal.