/** * Creates a DNS A record. * * @param name the record name. * @param target the record target/value. * @return an A record. */ @Override public ARecord create(Name name, InetAddress target) { return new ARecord(name, DClass.IN, ttl, target); } }
Record getObject() { return new ARecord(); }
Record getObject() { return new ARecord(); }
Record getObject() { return new ARecord(); }
Record getObject() { return new ARecord(); }
@Nonnull public static ARecord a(@Nonnull Name name, @Nonnegative long ttl, @Nonnull InetAddress address) { return new ARecord(name, DClass.IN, ttl, address); }
/** * Creates a DNS A type record. * @param name The record name. Generally a fully qualified domain name such as host.example.com. * @param ttl The time to live in seconds. * @param ip The ip4 address that the name will resolve. * @return A DNSRecord representing an A type record. * @throws ConfigurationStoreException */ public static DNSRecord createARecord(String name, long ttl, String ip) throws DNSRecordCreationException { if (!name.endsWith(".")) name = name + "."; try { ARecord rec = new ARecord(Name.fromString(name), DClass.IN, ttl, InetAddress.getByName(ip)); return fromWire(rec.toWireCanonical()); } catch (Exception e) { throw new DNSRecordCreationException("Failed to create DNS A record: " + e.getMessage(), e); } }
/** * Creates a DNS A type record. * @param name The record name. Generally a fully qualified domain name such as host.example.com. * @param ttl The time to live in seconds. * @param ip The ip4 address that the name will resolve. * @return A DNSRecord representing an A type record. * @throws ConfigurationStoreException */ public static DNSRecord createARecord(String name, long ttl, String ip) throws ConfigurationStoreException { if (!name.endsWith(".")) name = name + "."; try { ARecord rec = new ARecord(Name.fromString(name), DClass.IN, ttl, InetAddress.getByName(ip)); return DNSRecord.fromWire(rec.toWireCanonical()); } catch (Exception e) { throw new ConfigurationStoreException("Failed to create DNS A record: " + e.getMessage(), e); } }
@Test public void testDnsQuery() throws Exception { Message message = Message.newQuery(new ARecord(new Name("notblocked.example.com."), 0x01, 3600,
@Test public void testBlockedDnsQuery() throws Exception { Message message = Message.newQuery(new ARecord(new Name("blocked.example.com."), 0x01, 3600,
additionalRecords.add(new ARecord(service.getHost(), DClass.IN + CACHE_FLUSH, DEFAULT_A_TTL, addresses[index])); } else
new NSRecord(zoneName, DClass.IN, DEFAULT_TTL, Name.fromString("resolver1.opendns.com.")), new NSRecord(zoneName, DClass.IN, DEFAULT_TTL, Name.fromString("resolver2.opendns.com.")), new ARecord(zoneName, DClass.IN, DEFAULT_TTL, InetAddressUtils.addr(dnsZone.v4address())), new AAAARecord(zoneName, DClass.IN, DEFAULT_TTL, InetAddressUtils.addr(dnsZone.v6address())) }); switch (entry.type()) { case "A": zone.addRecord(new ARecord(recordName, DClass.value(entry.dclass()), DEFAULT_TTL, InetAddressUtils.addr(entry.data()))); break; case "AAAA":
PrivateKey priv = factory.generatePrivate(privateSpec); ARecord aRecord = new ARecord(Name.fromString("some.test."), DClass.IN, 0, InetAddress.getByName("192.168.0.1")); Calendar cal = Calendar.getInstance();
@Test public void testBlockedInet6DnsQuery() throws Exception { Message message = Message.newQuery(new ARecord(new Name("blocked.example.com."), 0x01, 3600,
@Override public Message send(Message query) throws IOException { final String HOSTNAME = "localhost."; if (query.getQuestion().getName().toString().equals(Constants.TEST_QUERY)) { Record question = Record.newRecord(query.getQuestion().getName(), Type.SRV, DClass.IN); Message queryMessage = Message.newQuery(question); Message result = new Message(); result.setHeader(queryMessage.getHeader()); result.addRecord(question, Section.QUESTION); result.addRecord(new SRVRecord(query.getQuestion().getName(), DClass.IN, 1, 1, 1, Constants.NODE_0_TRANSPORT_TCP_PORT, Name.fromString(HOSTNAME)), Section.ANSWER); result.addRecord(new SRVRecord(query.getQuestion().getName(), DClass.IN, 1, 1, 1, Constants.NODE_1_TRANSPORT_TCP_PORT, Name.fromString(HOSTNAME)), Section.ANSWER); result.addRecord(new SRVRecord(query.getQuestion().getName(), DClass.IN, 1, 1, 1, Constants.NODE_2_TRANSPORT_TCP_PORT, Name.fromString(HOSTNAME)), Section.ANSWER); result.addRecord(new SRVRecord(query.getQuestion().getName(), DClass.IN, 1, 1, 1, Constants.NODE_3_TRANSPORT_TCP_PORT, Name.fromString(HOSTNAME)), Section.ANSWER); result.addRecord(new SRVRecord(query.getQuestion().getName(), DClass.IN, 1, 1, 1, Constants.NODE_4_TRANSPORT_TCP_PORT, Name.fromString(HOSTNAME)), Section.ANSWER); return result; } if (query.getQuestion().getName().toString().equals(HOSTNAME)) { Record question = Record.newRecord(query.getQuestion().getName(), Type.A, DClass.IN); Message queryMessage = Message.newQuery(question); Message result = new Message(); result.setHeader(queryMessage.getHeader()); result.addRecord(question, Section.QUESTION); result.addRecord(new ARecord(query.getQuestion().getName(), DClass.IN, 1, InetAddress.getLoopbackAddress()), Section.ANSWER); return result; } throw new IllegalArgumentException("Unknown test query: " + query.getQuestion().getName().toString()); } };