类org.xbill.DNS.CNAMERecord源码实例Demo

下面列出了怎么用org.xbill.DNS.CNAMERecord的API类实例代码及写法,或者点击链接到github查看源代码。

/**
 * Follow the CNAME breadcrumb trail and find any which can't resolve
 * @param hostName a string of the hostname, or fqdn, to lookup 
 * @return a set of strings which list the CNAME entries which could not be resolved
 */
public Set<String> getBadCnames(String hostName){
    Set<String> retval = new TreeSet<String>();
    try {
        Lookup thisLookup = new Lookup(hostName, CNAME);
        thisLookup.setResolver(myResolver);
        Record[] results = thisLookup.run();
        if (results != null){
            List<Record> records = Arrays.asList(results);
            for (Record record : records){
                CNAMERecord thisRecord = (CNAMERecord) record;
                String target = thisRecord.getTarget().toString();
                if (hasRecordsOfType(target, CNAME)){
                    // check for more cnames down the tree
                    retval.addAll(getBadCnames(target));
                } else {
                    if (!(hasRecordsOfType(target, A) || hasRecordsOfType(target, AAAA))){
                        // This one doesn't point to anything
                        retval.add(target);
                    }
                }
            }
        }
    }
    catch (TextParseException e){
        System.err.println("[SRI][-] There was an error parsing the name " + hostName);
    }
    return retval;
}
 
源代码2 项目: yeti   文件: TldController.java
public void expandDomain(String domainToCheck) throws TextParseException {
    String domainName = null;

    // Check for domain name alias - CNAME
    Record[] recs = new Lookup(domainToCheck, Type.CNAME).run();
    if (recs != null && recs.length != 0) {
        domainName = ((CNAMERecord) recs[0]).getName().canonicalize().toString(true);
        Log.debug("Found: " + domainName + "CNAME rec: " + domainName);
    }

    // Now get the SOA record that would signify a domain exists
    recs = new Lookup(domainToCheck, Type.SOA).run();
    for (int idx = 0; idx < retryCount; idx++) {
        if (recs != null) {
            if (domainName == null) {
                domainName = ((SOARecord) recs[0]).getName().canonicalize().toString(true);
                Log.debug("Found: " + domainName + " SOA rec: " + domainName);
            }

            DomainResult newDomain = new DomainResult(domainName);
            newDomain.setNameServer(((SOARecord) recs[0]).getHost().toString(true));
            newDomain.setAdminName(((SOARecord) recs[0]).getAdmin().toString(true));
            String name = domainToCheck.split("\\.", 2)[0];
            String tld = domainToCheck.split("\\.", 2)[1];
            newDomain.setRegistrant(NetworkTools.getHostNameWhoisResult(name, tld, true));
            Map<String, String> attrs = new HashMap<>();
            attrs.put(DataStore.DNS_RECORD, DataStore.SOA);
            newDomain.setAttributes(attrs);
            addResult(newDomain);
            break;
        }
    }
}
 
源代码3 项目: yeti   文件: DNS.java
public static CNAMERecord getCNAMERecord(String hostName) {
    return null;
}
 
源代码4 项目: yeti   文件: DataAPI.java
public CNAMERecord getCNAMERecord(String hostName) {
    return null;
}