static {
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.dns.DnsContextFactory");
- // env.put(Context.AUTHORITATIVE, "true");
- // env.put(Context.PROVIDER_URL, "dns://ns.dyn.dogcraft.de");
try {
context = new InitialDirContext(env);
} catch (NamingException e) {
env.put(Context.AUTHORITATIVE, "true");
env.put(Context.PROVIDER_URL, "dns://" + server);
InitialDirContext context = new InitialDirContext(env);
+ try {
- Attributes dnsLookup = context.getAttributes(name, new String[] {
- "TXT"
- });
+ Attributes dnsLookup = context.getAttributes(name, new String[] {
+ "TXT"
+ });
+ return extractTextEntries(dnsLookup.get("TXT"));
+ } finally {
+ context.close();
+ }
- return extractTextEntries(dnsLookup.get("TXT"));
}
private static String[] extractTextEntries(Attribute nsRecords) throws NamingException {