当前位置: 首页>>代码示例>>Java>>正文


Java PTRRecord类代码示例

本文整理汇总了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 "";
    }
}
 
开发者ID:amirkibbar,项目名称:plum,代码行数:32,代码来源:DnsResolver.java

示例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;
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:24,代码来源:Helperfunctions.java

示例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();
}
 
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:14,代码来源:DNSJavaNameService.java

示例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);
            }
        }
    }
}
 
开发者ID:eclipse,项目名称:tiaki-java,代码行数:36,代码来源:DnsServicesDiscovery.java

示例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();
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:15,代码来源:DNSJavaNameService.java

示例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;
}
 
开发者ID:jagornet,项目名称:dhcp,代码行数:37,代码来源:ReverseDdnsUpdate.java

示例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;
}
 
开发者ID:twachan,项目名称:James,代码行数:17,代码来源:DNSJavaService.java

示例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;
}
 
开发者ID:cert-se,项目名称:megatron-java,代码行数:13,代码来源:IpAddressUtil.java

示例9: PointerRecord

import org.xbill.DNS.PTRRecord; //导入依赖的package包/类
private PointerRecord(PTRRecord ptrRecord)
{
    super(ptrRecord.getName().toString(),
            ptrRecord.rdataToString(), ptrRecord.getTTL());
}
 
开发者ID:eclipse,项目名称:tiaki-java,代码行数:6,代码来源:PointerRecord.java

示例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;
}
 
开发者ID:jagornet,项目名称:dhcp,代码行数:36,代码来源:ReverseDdnsUpdate.java

示例11: getPTRRecord

import org.xbill.DNS.PTRRecord; //导入依赖的package包/类
public static PTRRecord getPTRRecord(String ipAddress) {
    return null;
}
 
开发者ID:sensepost,项目名称:yeti,代码行数:4,代码来源:DNS.java

示例12: getPTRRecord

import org.xbill.DNS.PTRRecord; //导入依赖的package包/类
public PTRRecord getPTRRecord(String ipAddress) {
    return null;
}
 
开发者ID:sensepost,项目名称:yeti,代码行数:4,代码来源:DataAPI.java

示例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);
}
 
开发者ID:eclipse,项目名称:tiaki-java,代码行数:11,代码来源:PointerRecord.java


注:本文中的org.xbill.DNS.PTRRecord类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。