本文整理汇总了Java中org.xbill.DNS.CNAMERecord类的典型用法代码示例。如果您正苦于以下问题:Java CNAMERecord类的具体用法?Java CNAMERecord怎么用?Java CNAMERecord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CNAMERecord类属于org.xbill.DNS包,在下文中一共展示了CNAMERecord类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getDynamicMap
import org.xbill.DNS.CNAMERecord; //导入依赖的package包/类
private static HashMap<String, String> getDynamicMap() {
HashMap<String, String> dynamicMap = new HashMap<>();
aDynamics.forEach((host, records) -> {
StringBuilder sb = new StringBuilder();
for (Record record : records) {
if (record instanceof ARecord) {
sb.append(((ARecord) record).getAddress().getHostAddress());
} else if (record instanceof CNAMERecord) {
sb.append(((CNAMERecord) record).getTarget().
toString(true).toLowerCase());
}
sb.append(',');
}
dynamicMap.put(host, sb.substring(0, Math.max(sb.length() - 1, 0)));
});
return dynamicMap;
}
开发者ID:xqbase,项目名称:ddns,代码行数:18,代码来源:DDNS.java
示例2: updateRecords
import org.xbill.DNS.CNAMERecord; //导入依赖的package包/类
private static void updateRecords(Map<String, Record[]> records,
String host, String value, int ttl) throws IOException {
if (value == null) {
records.remove(host);
return;
}
Name origin = new Name((host.endsWith(".") ? host : host + ".").replace('_', '-'));
ArrayList<Record> recordList = new ArrayList<>();
for (String s : value.split("[,;]")) {
if (s.matches(".*[A-Z|a-z].*")) {
CNAMERecord record = new CNAMERecord(origin, DClass.IN, ttl,
new Name(s.endsWith(".") ? s : s + "."));
recordList.add(record);
continue;
}
String[] ss = s.split("\\.");
if (ss.length < 4) {
continue;
}
byte[] ip = new byte[4];
for (int i = 0; i < 4; i ++) {
ip[i] = (byte) Numbers.parseInt(ss[i]);
}
recordList.add(new ARecord(origin, DClass.IN,
ttl, InetAddress.getByAddress(ip)));
}
records.put(host, recordList.toArray(EMPTY_RECORDS));
}
开发者ID:xqbase,项目名称:ddns,代码行数:29,代码来源:DDNS.java
示例3: canResolveRecord
import org.xbill.DNS.CNAMERecord; //导入依赖的package包/类
@Test
public void canResolveRecord() throws Exception {
AcceptanceTestRunner runner = new AcceptanceTestRunner();
runner.runUngarded(new AcceptanceScenario() {
public void run(WebDriver driver, String deployedURL) throws Exception {
int id = new SecureRandom().nextInt();
final String systemTestBase = "system-tests.onomate.test";
final String soaBase = "soa-" + id +"."+ systemTestBase;
final String ns = "ns." + soaBase;
final String contactName = "admin." + soaBase;
final String aTestRecordHost = "record."+soaBase;
final String aRealTestRecord = soaBase;
OnomateAssembly assembly = new OnomateAssembly(driver, deployedURL);
OnomateAssembly.Dashboard board = assembly.gotoLanding().authenticate().newAuthority(soaBase, ns, contactName);
board.authorityByZone(soaBase).details().createRecord(aTestRecordHost, OnomateAssembly.RecordType.CNAME, aRealTestRecord);
Options.set("verbose");
SimpleResolver resolver = new SimpleResolver();
resolver.setAddress(InetAddress.getLocalHost());
resolver.setPort(9101);
Record query = Record.newRecord(Name.fromString(aTestRecordHost + "."), Type.CNAME, DClass.IN);
Message question = Message.newQuery(query);
Message response = resolver.send(question);
Record responses[] = response.getSectionArray(Section.ANSWER);
CNAMERecord record = ((CNAMERecord) responses[0]);
assertEquals(record.getName().toString(), aTestRecordHost+ ".");
assertEquals(record.getTarget().toString(), aRealTestRecord + ".");
}
});
}
开发者ID:meschbach,项目名称:onomate,代码行数:35,代码来源:CreateCNameRecordTests.java
示例4: getCnameForHost
import org.xbill.DNS.CNAMERecord; //导入依赖的package包/类
/**
* Gets the CNAME record for the host.
*
* @param host
* host
* @return CNAME record may return null if not found.
* @throws TextParseException
*/
private String getCnameForHost(final String host) throws TextParseException {
final Lookup lookup = new Lookup(host, Type.CNAME);
lookup.run();
if (lookup.getAnswers().length == 0) {
LOG.log(Level.SEVERE, "unableToFindCNAME", new Object[] {
host
});
return null;
}
return ((CNAMERecord) lookup.getAnswers()[0]).getTarget().toString();
}
开发者ID:trajano,项目名称:wagon-git,代码行数:21,代码来源:GitHubPagesWagon.java
示例5: testCNameLookup
import org.xbill.DNS.CNAMERecord; //导入依赖的package包/类
/**
* Tests the CNAME lookup functionality of dnsjava.
*/
@Test
public void testCNameLookup() throws Exception {
final Lookup lookup = new Lookup("www.trajano.net", Type.CNAME);
lookup.run();
assertEquals("trajano.net.", ((CNAMERecord) lookup.run()[0]).getTarget()
.toString());
}
开发者ID:trajano,项目名称:wagon-git,代码行数:12,代码来源:NetworkLookupTests.java
示例6: expandDomain
import org.xbill.DNS.CNAMERecord; //导入依赖的package包/类
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;
}
}
}
开发者ID:sensepost,项目名称:yeti,代码行数:34,代码来源:TldController.java
示例7: getCNAMERecord
import org.xbill.DNS.CNAMERecord; //导入依赖的package包/类
public static CNAMERecord getCNAMERecord(String hostName) {
return null;
}
开发者ID:sensepost,项目名称:yeti,代码行数:4,代码来源:DNS.java
示例8: getCNAMERecord
import org.xbill.DNS.CNAMERecord; //导入依赖的package包/类
public CNAMERecord getCNAMERecord(String hostName) {
return null;
}
开发者ID:sensepost,项目名称:yeti,代码行数:4,代码来源:DataAPI.java
示例9: validateAnswerAndGetWildcards
import org.xbill.DNS.CNAMERecord; //导入依赖的package包/类
private boolean validateAnswerAndGetWildcards(SMessage response, int qtype, Map<Name, Name> wcs) {
// validate the ANSWER section - this will be the answer itself
DNAMERecord dname = null;
for (SRRset set : response.getSectionRRsets(Section.ANSWER)) {
// Validate the CNAME following a (validated) DNAME is correctly
// synthesized.
if (set.getType() == Type.CNAME && dname != null) {
if (set.size() > 1) {
response.setBogus(R.get("failed.synthesize.multiple"));
return false;
}
CNAMERecord cname = (CNAMERecord)set.first();
try {
Name expected = Name.concatenate(cname.getName().relativize(dname.getName()), dname.getTarget());
if (!expected.equals(cname.getTarget())) {
response.setBogus(R.get("failed.synthesize.nomatch", cname.getTarget(), expected));
return false;
}
}
catch (NameTooLongException e) {
response.setBogus(R.get("failed.synthesize.toolong"));
return false;
}
set.setSecurityStatus(SecurityStatus.SECURE);
dname = null;
continue;
}
// Verify the answer rrset.
KeyEntry ke = this.prepareFindKey(set);
if (!this.processKeyValidate(response, set.getSignerName(), ke)) {
return false;
}
SecurityStatus status = this.valUtils.verifySRRset(set, ke.getRRset());
// If the answer rrset failed to validate, then this message is BAD
if (status != SecurityStatus.SECURE) {
response.setBogus(R.get("failed.answer.positive", set));
return false;
}
// Check to see if the rrset is the result of a wildcard expansion.
// If so, an additional check will need to be made in the authority
// section.
Name wc = null;
try {
wc = ValUtils.rrsetWildcard(set);
}
catch (RuntimeException ex) {
response.setBogus(R.get(ex.getMessage(), set.getName()));
return false;
}
if (wc != null) {
// RFC 4592, Section 4.4 does not allow wildcarded DNAMEs
if (set.getType() == Type.DNAME) {
response.setBogus(R.get("failed.dname.wildcard", set.getName()));
return false;
}
wcs.put(set.getName(), wc);
}
// Notice a DNAME that should be followed by an unsigned CNAME.
if (qtype != Type.DNAME && set.getType() == Type.DNAME) {
dname = (DNAMERecord)set.first();
}
}
return true;
}
开发者ID:ibauersachs,项目名称:dnssecjava,代码行数:74,代码来源:ValidatingResolver.java
注:本文中的org.xbill.DNS.CNAMERecord类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论