MCPcopy Create free account
hub / github.com/DeNA/PacketProxy / lookupHostName

Method lookupHostName

src/main/java/core/org/xbill/DNS/Address.java:234–260  ·  view source on GitHub ↗
(String name, boolean all)

Source from the content-addressed store, hash-verified

232}
233
234private static Record []
235lookupHostName(String name, boolean all) throws UnknownHostException {
236 try {
237 Lookup lookup = new Lookup(name, Type.A);
238 Record [] a = lookup.run();
239 if (a == null) {
240 if (lookup.getResult() == Lookup.TYPE_NOT_FOUND) {
241 Record [] aaaa = new Lookup(name, Type.AAAA).run();
242 if (aaaa != null)
243 return aaaa;
244 }
245 throw new UnknownHostException("unknown host");
246 }
247 if (! all)
248 return a;
249 Record [] aaaa = new Lookup(name, Type.AAAA).run();
250 if (aaaa == null)
251 return a;
252 Record [] merged = new Record[a.length + aaaa.length];
253 System.arraycopy(a, 0, merged, 0, a.length);
254 System.arraycopy(aaaa, 0, merged, a.length, aaaa.length);
255 return merged;
256 }
257 catch (TextParseException e) {
258 throw new UnknownHostException("invalid name");
259 }
260}
261
262private static InetAddress
263addrFromRecord(String name, Record r) throws UnknownHostException {

Callers 2

getByNameMethod · 0.95
getAllByNameMethod · 0.95

Calls 3

runMethod · 0.95
getResultMethod · 0.95
runMethod · 0.45

Tested by

no test coverage detected