forked from LupusNobilis/java-org.hwo
53 lines
976 B
Java
53 lines
976 B
Java
package org.hwo.dnsconf;
|
|
|
|
import java.net.InetAddress;
|
|
import java.net.UnknownHostException;
|
|
|
|
public class DNSConf {
|
|
|
|
|
|
public static String getConfigValue(String application,String name){
|
|
|
|
try {
|
|
String hostname = InetAddress.getLocalHost().getHostName();
|
|
|
|
System.err.println("Hostname:" + hostname);
|
|
|
|
InetAddress a = lookupConfigRoot(hostname);
|
|
if (a != null){
|
|
|
|
}
|
|
|
|
} catch (UnknownHostException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
|
|
return "";
|
|
}
|
|
|
|
public static InetAddress lookupConfigRoot(String dns){
|
|
int idx = dns.indexOf(".");
|
|
if (idx == -1)
|
|
return null;
|
|
|
|
String lookup = dns.substring(idx+1);
|
|
System.err.println("DNSConf: Try: " + lookup);
|
|
|
|
InetAddress a;
|
|
try {
|
|
a = InetAddress.getByName("_dnsconf." + lookup);
|
|
} catch (UnknownHostException e) {
|
|
return lookupConfigRoot(lookup);
|
|
|
|
}
|
|
if (a == null)
|
|
return lookupConfigRoot(lookup);
|
|
|
|
return a;
|
|
};
|
|
|
|
|
|
|
|
}
|