From: Brian W. <Bri...@no...> - 2007-03-16 17:55:04
|
On Fri, 16 Mar 2007, Rob Podolski wrote: > Hi, > > I want to use a specified (external) public name server to resolve any > given URL into its IP address(es) yielding also the TTL from the name > server. I managed to do this using JNDI, but couldn't get the TTL. > Then I found dnsjava so would like to give it a try. > > Would the following work?? I've tried it but can't vouch for the TTL > coming back upon successive tries. > > SimpleResolver res = new SimpleResolver(<public name server ip address>); > Lookup lookup = new Lookup(<my url>, Type.A); > lookup.setResolver(res); > > Record [] records = lookup.run(); > ARecord aRec = null; > for (int iRec = 0; iRec < records.length; iRec++) { > aRec = (ARecord) records[iRec]; > System.out.println(aRec.getAddress() ); > } > System.out.println(aRec.getTTL() ); > > Does this look right? Any help would be gratefully received. I haven't tested it, but it looks right. You probably want a check that lookup.run() doesn't return null, but that's about the only thing I'd change. Brian |