本文整理汇总了Java中org.xbill.DNS.AAAARecord类的典型用法代码示例。如果您正苦于以下问题:Java AAAARecord类的具体用法?Java AAAARecord怎么用?Java AAAARecord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AAAARecord类属于org.xbill.DNS包,在下文中一共展示了AAAARecord类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: resolve
import org.xbill.DNS.AAAARecord; //导入依赖的package包/类
public static String resolve(String host, int addrType) {
try {
Lookup lookup = new Lookup(host, addrType);
SimpleResolver resolver = new SimpleResolver("114.114.114.114");
resolver.setTimeout(5);
lookup.setResolver(resolver);
Record[] result = lookup.run();
if (result == null) return null;
List<Record> records = java.util.Arrays.asList(result);
java.util.Collections.shuffle(records);
for (Record record : records) {
if (addrType == Type.A) {
return ((ARecord) record).getAddress().getHostAddress();
} else if (addrType == Type.AAAA) {
return ((AAAARecord) record).getAddress().getHostAddress();
}
}
} catch (Exception ex) {
return null;
}
return null;
}
开发者ID:lparam,项目名称:xTun-android,代码行数:26,代码来源:Utils.java
示例2: testQueryAddressesIpv6
import org.xbill.DNS.AAAARecord; //导入依赖的package包/类
@Test
public void testQueryAddressesIpv6() throws SendException {
new Expectations() {
{
lookup.run();
result =
new Record[] { new AAAARecord(HOST6_EXAMPLE_COM_NAME,
0, 0, IPV6)
};
}
};
InetAddress[] addresses =
addressLookup.queryAddresses(HOST1_EXAMPLE_COM_NAME);
InetAddress[] expected = new InetAddress[] { IPV6 };
assertArrayEquals(expected, addresses);
}
开发者ID:hontvari,项目名称:mireka,代码行数:21,代码来源:AddressLookupTest.java
示例3: findAddresses
import org.xbill.DNS.AAAARecord; //导入依赖的package包/类
private String[] findAddresses(Name target, Record[] records) {
ArrayList<String> addresses = new ArrayList<String>();
for (Record record : records) {
if (target == null || target.equals(record.getName())) {
int recordType = record.getType();
if (Type.A == recordType)
addresses.add(((ARecord)record).getAddress().getHostAddress());
else if (Type.AAAA == recordType)
addresses.add(((AAAARecord)record).getAddress().getHostAddress());
}
}
if (addresses.size() == 0)
return null;
return addresses.toArray(new String[addresses.size()]);
}
开发者ID:wnagele,项目名称:dnsjava-recursive-resolver,代码行数:17,代码来源:RecursiveResolver.java
示例4: getAAAARecord
import org.xbill.DNS.AAAARecord; //导入依赖的package包/类
public static List<ForwardLookupResult> getAAAARecord(String hostName, String domainName) throws TextParseException {
List<ForwardLookupResult> entries = null;
if (hostName != null && !hostName.isEmpty() && domainName != null && !domainName.isEmpty()) {
Record[] recs = new Lookup(hostName, Type.AAAA).run();
if (recs != null) {
if (recs.length > 0) {
entries = new ArrayList<>();
for (Record record : recs) {
ForwardLookupResult foundSubDomain = new ForwardLookupResult(domainName);
foundSubDomain.setHostName(hostName);
String ipAddress = ((AAAARecord) record).getAddress().getHostAddress();
foundSubDomain.setIpAddress(ipAddress);
foundSubDomain.setLookupType("A");
entries.add(foundSubDomain);
}
}
}
}
return entries;
}
开发者ID:sensepost,项目名称:yeti,代码行数:21,代码来源:ForwardLookupHelper.java
示例5: makeV6AddressSet
import org.xbill.DNS.AAAARecord; //导入依赖的package包/类
private RRset makeV6AddressSet(HostResource host) {
RRset addressSet = new RRset();
for (InetAddress address : host.getInetAddresses()) {
if (address instanceof Inet6Address) {
AAAARecord record =
new AAAARecord(
toAbsoluteName(host.getFullyQualifiedHostName()),
DClass.IN,
dnsDefaultATtl.getStandardSeconds(),
address);
addressSet.addRR(record);
}
}
return addressSet;
}
开发者ID:google,项目名称:nomulus,代码行数:16,代码来源:DnsUpdateWriter.java
示例6: convertAddressRecordsToAddresses
import org.xbill.DNS.AAAARecord; //导入依赖的package包/类
private InetAddress[] convertAddressRecordsToAddresses(Record[] records) {
InetAddress[] addresses = new InetAddress[records.length];
for (int i = 0; i < records.length; i++) {
Record record = records[i];
if (record instanceof ARecord) {
addresses[i] = ((ARecord) record).getAddress();
} else if (record instanceof AAAARecord) {
addresses[i] = ((AAAARecord) record).getAddress();
} else {
throw new RuntimeException();
}
}
return addresses;
}
开发者ID:hontvari,项目名称:mireka,代码行数:15,代码来源:AddressLookup.java
示例7: testGetSectionByType
import org.xbill.DNS.AAAARecord; //导入依赖的package包/类
@Test()
public void testGetSectionByType() throws UnknownHostException {
Message m = new Message();
Record r1 = new ARecord(Name.root, DClass.IN, 0, InetAddress.getByAddress(new byte[]{0,0,0,0}));
m.addRecord(r1, Section.ANSWER);
Record r2 = new AAAARecord(Name.root, DClass.IN, 0, InetAddress.getByAddress(new byte[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}));
m.addRecord(r2, Section.ANSWER);
SMessage sm = new SMessage(m);
SRRset[] result = sm.getSectionRRsets(Section.ANSWER, Type.A);
assertEquals(1, result.length);
assertEquals(Type.A, result[0].getType());
}
开发者ID:ibauersachs,项目名称:dnssecjava,代码行数:13,代码来源:TestSMessage.java
示例8: createRequisitionNode
import org.xbill.DNS.AAAARecord; //导入依赖的package包/类
/**
* Creates an instance of the JaxB annotated RequisionNode class.
*
* @param rec
* @return a populated RequisitionNode based on defaults and data from the
* A record returned from a DNS zone transfer query.
*/
private RequisitionNode createRequisitionNode(Record rec) {
String addr = null;
if ("A".equals(Type.string(rec.getType()))) {
ARecord arec = (ARecord)rec;
addr = StringUtils.stripStart(arec.getAddress().toString(), "/");
} else if ("AAAA".equals(Type.string(rec.getType()))) {
AAAARecord aaaarec = (AAAARecord)rec;
addr = aaaarec.rdataToString();
} else {
throw new IllegalArgumentException("Invalid record type " + Type.string(rec.getType()) + ". A or AAAA expected.");
}
RequisitionNode n = new RequisitionNode();
String host = rec.getName().toString();
String nodeLabel = StringUtils.stripEnd(StringUtils.stripStart(host, "."), ".");
n.setBuilding(getForeignSource());
switch(m_foreignIdHashSource) {
case 1:
n.setForeignId(computeHashCode(nodeLabel));
log().debug("Generating foreignId from hash of nodelabel " + nodeLabel);
break;
case 2:
n.setForeignId(computeHashCode(addr));
log().debug("Generating foreignId from hash of ipAddress " + addr);
break;
case 3:
n.setForeignId(computeHashCode(nodeLabel+addr));
log().debug("Generating foreignId from hash of nodelabel+ipAddress " + nodeLabel + addr);
break;
default:
n.setForeignId(computeHashCode(nodeLabel));
log().debug("Default case: Generating foreignId from hash of nodelabel " + nodeLabel);
break;
}
n.setNodeLabel(nodeLabel);
RequisitionInterface i = new RequisitionInterface();
i.setDescr("DNS-" + Type.string(rec.getType()));
i.setIpAddr(addr);
i.setSnmpPrimary(PrimaryType.PRIMARY);
i.setManaged(Boolean.TRUE);
i.setStatus(Integer.valueOf(1));
for (String service : m_services) {
service = service.trim();
i.insertMonitoredService(new RequisitionMonitoredService(service));
log().debug("Adding provisioned service " + service);
}
n.putInterface(i);
return n;
}
开发者ID:qoswork,项目名称:opennmszh,代码行数:64,代码来源:DnsRequisitionUrlConnection.java
示例9: beforeTestMethod
import org.xbill.DNS.AAAARecord; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void beforeTestMethod(final TestContext testContext) throws Exception {
super.beforeTestMethod(testContext);
final JUnitDNSServer config = findTestAnnotation(JUnitDNSServer.class, testContext);
if (config == null) {
return;
}
LogUtils.infof(this, "initializing DNS on port %d", config.port());
m_server = new DNSServer();
m_server.addPort(config.port());
for (final DNSZone dnsZone : config.zones()) {
String name = dnsZone.name();
if (!name.endsWith(".")) {
name = name + ".";
}
final Name zoneName = Name.fromString(name, Name.root);
LogUtils.debugf(this, "zoneName = %s", zoneName);
final Zone zone = new Zone(zoneName, new Record[] {
new SOARecord(zoneName, DClass.IN, DEFAULT_TTL, zoneName, Name.fromString("admin." + name), 1, DEFAULT_TTL, DEFAULT_TTL, DEFAULT_TTL, DEFAULT_TTL),
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()))
});
LogUtils.debugf(this, "zone = %s", zone);
for (final DNSEntry entry : dnsZone.entries()) {
LogUtils.debugf(this, "adding entry: %s", entry);
String hostname = entry.hostname();
final Name recordName = Name.fromString(hostname, zoneName);
LogUtils.debugf(this, "name = %s", recordName);
if (entry.ipv6()) {
zone.addRecord(new AAAARecord(recordName, DClass.IN, DEFAULT_TTL, InetAddressUtils.addr(entry.address())));
} else {
zone.addRecord(new ARecord(recordName, DClass.IN, DEFAULT_TTL, InetAddressUtils.addr(entry.address())));
}
}
m_server.addZone(zone);
}
LogUtils.debugf(this, "starting DNS server");
m_server.start();
try {
Thread.sleep(50);
} catch (final InterruptedException e) {
LogUtils.debugf(this, e, "interrupted while waiting for server to come up");
Thread.currentThread().interrupt();
}
}
开发者ID:qoswork,项目名称:opennmszh,代码行数:57,代码来源:JUnitDNSServerExecutionListener.java
示例10: getIPV6ByName
import org.xbill.DNS.AAAARecord; //导入依赖的package包/类
public Inet6Address
getIPV6ByName(
String query )
throws UnknownHostException
{
try{
Lookup a6_l = new Lookup( query, Type.AAAA );
setCache( null, a6_l );
a6_l.run();
Record[] a6_results = a6_l.getAnswers();
if ( a6_results != null ){
for ( Record r: a6_results ){
AAAARecord a6_record = (AAAARecord)r;
return((Inet6Address)a6_record.getAddress());
}
}
throw( new UnknownHostException( query ));
}catch( Exception e ){
throw( new UnknownHostException( query + ": " + Debug.getNestedExceptionMessage( e )));
}
}
开发者ID:vuze,项目名称:vuze-remote-for-android,代码行数:33,代码来源:DNSProvider.java
注:本文中的org.xbill.DNS.AAAARecord类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论