本文整理汇总了Java中org.xbill.DNS.PTRRecord类的典型用法代码示例。如果您正苦于以下问题:Java PTRRecord类的具体用法?Java PTRRecord怎么用?Java PTRRecord使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PTRRecord类属于org.xbill.DNS包,在下文中一共展示了PTRRecord类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reverseLookupByAddress
import org.xbill.DNS.PTRRecord; //导入依赖的package包/类
/**
* reverse lookup an IP address using a specified DNS host and port
*
* @param resolverHost name server hostname or IP address
* @param resolverPort name server port
* @param address the IP address to reverse lookup
* @return a comma separated list of names or an empty string when unable to resolve
*/
public String reverseLookupByAddress(String resolverHost, int resolverPort, InetAddress address) {
try {
SimpleResolver resolver = new SimpleResolver(resolverHost);
resolver.setPort(resolverPort);
Lookup lookup = new Lookup(fromAddress(address), PTR);
Record[] records = lookup.run();
if (records != null) {
List<String> addresses =
of(records)
.filter(it -> it instanceof PTRRecord)
.map(it -> ((PTRRecord) it).getTarget().toString())
.collect(toList());
return collectionToCommaDelimitedString(addresses);
} else {
return "";
}
} catch (UnknownHostException e) {
log.warn("unable to resolve using SRV record " + address, e);
return "";
}
}
示例2: reverseDNSLookup
import org.xbill.DNS.PTRRecord; //导入依赖的package包/类
public static String reverseDNSLookup(final InetAddress adr)
{
try
{
final Name name = ReverseMap.fromAddress(adr);
final Lookup lookup = new Lookup(name, Type.PTR);
lookup.setResolver(new SimpleResolver());
lookup.setCache(null);
final Record[] records = lookup.run();
if (lookup.getResult() == Lookup.SUCCESSFUL)
for (final Record record : records)
if (record instanceof PTRRecord)
{
final PTRRecord ptr = (PTRRecord) record;
return ptr.getTarget().toString();
}
}
catch (final Exception e)
{
}
return null;
}
示例3: getHostByAddr
import org.xbill.DNS.PTRRecord; //导入依赖的package包/类
/**
* Performs a reverse DNS lookup.
* @param addr The ip address to lookup.
* @return The host name found for the ip address.
*/
public String
getHostByAddr(byte [] addr) throws UnknownHostException {
Name name = ReverseMap.fromAddress(InetAddress.getByAddress(addr));
Record [] records = new Lookup(name, Type.PTR).run();
if (records == null)
throw new UnknownHostException();
return ((PTRRecord) records[0]).getTarget().toString();
}
示例4: parseRecords
import org.xbill.DNS.PTRRecord; //导入依赖的package包/类
/**
* Scrapes the Discovery Service Records according to their nature.
*
* @param records An array of <code>Record</code> retrieve upon a lookup
* @param set A <code>ResourcesContainer</code>
* @param pht A Resource Record Type holder
*/
private void parseRecords(Record[] records, final RecordsContainer set, RrHolderType pht)
{
if (records != null) {
for (Record record : records) {
if ((record instanceof PTRRecord && pht == RrHolderType.ZONES) ||
(record instanceof PTRRecord && pht == RrHolderType.NAMES)) {
String zone = PointerRecord.build((PTRRecord) record).getRData();
if (zone != null) {
set.getLabels().add(zone);
}
} else if (record instanceof PTRRecord && pht == RrHolderType.TYPES) {
set.getLabels().add(PointerRecord.build((PTRRecord) record).getServiceType());
} else if (record instanceof SRVRecord) {
ServiceRecord svcRecord = ServiceRecord.build((SRVRecord) record);
if (svcRecord != null) {
set.getRecords().add(svcRecord);
}
} else if (record instanceof TXTRecord) {
set.getTexts().add(TextRecord.build((TXTRecord) record));
} else {
errorsTrace.get().put(
ExceptionsUtil.traceKey(record.toString(), "",
"Parsing-Service-Records"),
StatusCode.RESOURCE_UNEXPECTED);
}
}
}
}
示例5: getHostByAddr
import org.xbill.DNS.PTRRecord; //导入依赖的package包/类
/**
* Performs a reverse DNS lookup.
*
* @param addr
* The ip address to lookup.
* @return The host name found for the ip address.
*/
public String getHostByAddr(byte[] addr) throws UnknownHostException {
Name name = ReverseMap.fromAddress(InetAddress.getByAddress(addr));
Record[] records = new Lookup(name, Type.PTR).run();
if (records == null)
throw new UnknownHostException();
return ((PTRRecord) records[0]).getTarget().toString();
}
示例6: sendAdd
import org.xbill.DNS.PTRRecord; //导入依赖的package包/类
public boolean sendAdd() throws TextParseException, IOException
{
boolean rc = false;
Resolver res = createResolver();
String revIp = buildReverseIpString();
Name owner = new Name(revIp.toString());
PTRRecord ptr = new PTRRecord(owner, DClass.IN, ttl, new Name(fqdn));
Name _zone = buildZoneName(revIp);
Update update = new Update(_zone);
update.delete(owner);
update.add(ptr);
if (log.isDebugEnabled()) {
log.debug("Sending reverse DDNS update (replace) to server=" + server + ":\n" +
update.toString());
}
else if (log.isInfoEnabled()) {
log.info("Sending reverse DDNS update (replace): " + ptr.toString());
}
Message response = res.send(update);
if (response.getRcode() == Rcode.NOERROR) {
log.info("Reverse DDNS update (replace) succeeded: " + ptr.toString());
rc = true;
}
else {
log.error("Reverse DDNS update (replace) failed (rcode=" +
Rcode.string(response.getRcode()) + "): " + ptr.toString());
}
return rc;
}
示例7: getHostName
import org.xbill.DNS.PTRRecord; //导入依赖的package包/类
/**
* @see org.apache.james.dnsservice.api.DNSService#getHostName(java.net.InetAddress)
*/
public String getHostName(InetAddress addr) {
String result = null;
Name name = ReverseMap.fromAddress(addr);
Record[] records = lookupNoException(name.toString(), Type.PTR, "PTR");
if (records == null) {
result = addr.getHostAddress();
} else {
PTRRecord ptr = (PTRRecord) records[0];
result = ptr.getTarget().toString();
}
return result;
}
示例8: reverseDnsLookupUsingDnsJavaExtendedResolver
import org.xbill.DNS.PTRRecord; //导入依赖的package包/类
private static String reverseDnsLookupUsingDnsJavaExtendedResolver(long ipAddress) throws UnknownHostException {
byte[] address = convertLongAddressToBuf(ipAddress);
Name name = ReverseMap.fromAddress(InetAddress.getByAddress(address));
Record[] records = new Lookup(name, Type.PTR).run();
if (records == null) {
throw new UnknownHostException();
}
String result = ((PTRRecord)records[0]).getTarget().toString();
// remove trailing "."
result = result.endsWith(".") ? result.substring(0, result.length() - 1) : result;
return result;
}
示例9: PointerRecord
import org.xbill.DNS.PTRRecord; //导入依赖的package包/类
private PointerRecord(PTRRecord ptrRecord)
{
super(ptrRecord.getName().toString(),
ptrRecord.rdataToString(), ptrRecord.getTTL());
}
示例10: sendDelete
import org.xbill.DNS.PTRRecord; //导入依赖的package包/类
public boolean sendDelete() throws TextParseException, IOException
{
boolean rc = false;
Resolver res = createResolver();
String revIp = buildReverseIpString();
Name owner = new Name(revIp);
PTRRecord ptr = new PTRRecord(owner, DClass.IN, 0, new Name(fqdn));
Name _zone = buildZoneName(revIp);
Update update = new Update(_zone);
update.delete(ptr);
if (log.isDebugEnabled()) {
log.debug("Sending reverse DDNS update (delete) to server=" + server + ":\n" +
update.toString());
}
else if (log.isInfoEnabled()) {
log.info("Sending reverse DDNS update (delete): " + ptr.toString());
}
Message response = res.send(update);
if (response.getRcode() == Rcode.NOERROR) {
log.info("Reverse DDNS update (delete) succeeded: " + ptr.toString());
rc = true;
}
else {
log.error("Reverse DDNS update (delete) failed (rcode=" +
Rcode.string(response.getRcode()) + "): " + ptr.toString());
}
return rc;
}
示例11: getPTRRecord
import org.xbill.DNS.PTRRecord; //导入依赖的package包/类
public static PTRRecord getPTRRecord(String ipAddress) {
return null;
}
示例12: getPTRRecord
import org.xbill.DNS.PTRRecord; //导入依赖的package包/类
public PTRRecord getPTRRecord(String ipAddress) {
return null;
}
示例13: build
import org.xbill.DNS.PTRRecord; //导入依赖的package包/类
/**
* Static builder. It wraps out a {@link PTRRecord} by extracting relevant data.
*
* @param ptrRecord A {@link PTRRecord} instance to be worked out
* @return An instance of <code>PointerRecor</code>
*/
public final static PointerRecord build(PTRRecord ptrRecord)
{
return new PointerRecord(ptrRecord);
}