• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SOARecord类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.xbill.DNS.SOARecord的典型用法代码示例。如果您正苦于以下问题:Java SOARecord类的具体用法?Java SOARecord怎么用?Java SOARecord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SOARecord类属于org.xbill.DNS包,在下文中一共展示了SOARecord类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: dnsServerRespondsWithAuthority

import org.xbill.DNS.SOARecord; //导入依赖的package包/类
@Test
public void dnsServerRespondsWithAuthority() 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;

            OnomateAssembly assembly = new OnomateAssembly(driver, deployedURL);
            OnomateAssembly.Dashboard board = assembly.gotoLanding().authenticate().newAuthority(soaBase, ns, contactName);
            board.authorityByZone(soaBase).waitOnPersisted();

            Lookup lookup = new Lookup(soaBase, Type.SOA);
            SimpleResolver resolver = new SimpleResolver();
            resolver.setAddress(InetAddress.getLocalHost());
            resolver.setPort(9101);
            lookup.setResolver(resolver);
            lookup.setCache(null);
            Record[] results = lookup.run();
            assertEquals(lookup.getResult(), Lookup.SUCCESSFUL, "Resolution Successful");
            assertNotNull(results);
            assertEquals(results.length, 1);
            SOARecord record = ((SOARecord) results[0]);
            assertEquals(record.getAdmin().toString(), contactName + ".");
            assertEquals(record.getHost().toString(), ns + ".");
            assertEquals(record.getName().toString(), soaBase + ".");
        }
    });
}
 
开发者ID:meschbach,项目名称:onomate,代码行数:34,代码来源:CreateAuthorityTests.java


示例2: expandDomain

import org.xbill.DNS.SOARecord; //导入依赖的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


示例3: getSOARecord

import org.xbill.DNS.SOARecord; //导入依赖的package包/类
public static SOARecordResult getSOARecord(String domainName) {
    SOARecordResult newDomain = null;
    try {
        Record[] recs = new Lookup(domainName, Type.SOA).run();
        if (recs != null) {
            domainName = ((SOARecord) recs[0]).getName().canonicalize().toString(true);
            newDomain = new SOARecordResult(domainName);
            newDomain.setNameServer(((SOARecord) recs[0]).getHost().toString(true));
            newDomain.setAdminName(((SOARecord) recs[0]).getAdmin().toString(true));
        }
    } catch (TextParseException tpe) {
        Logger.getLogger(DNS.class.getName()).log(Level.SEVERE, null, tpe);
    }
    return newDomain;
}
 
开发者ID:sensepost,项目名称:yeti,代码行数:16,代码来源:DNS.java


示例4: testBlockedDnsQuery

import org.xbill.DNS.SOARecord; //导入依赖的package包/类
@Test
public void testBlockedDnsQuery() throws Exception {
    Message message = Message.newQuery(new ARecord(new Name("blocked.example.com."),
            0x01,
            3600,
            Inet4Address.getByAddress(new byte[]{0, 0, 0, 0})
    ));

    UdpPacket.Builder payLoadBuilder = new UdpPacket.Builder()
            .srcPort(UdpPort.DOMAIN)
            .dstPort(UdpPort.DOMAIN)
            .srcAddr(InetAddress.getByAddress(new byte[]{8, 8, 4, 4}))
            .dstAddr(InetAddress.getByAddress(new byte[]{8, 8, 8, 8}))
            .correctChecksumAtBuild(true)
            .correctLengthAtBuild(true)
            .payloadBuilder(
                    new UnknownPacket.Builder()
                            .rawData(message.toWire())
            );

    IpPacket ipOutPacket = new IpV4Packet.Builder()
            .version(IpVersion.IPV4)
            .tos(IpV4Rfc791Tos.newInstance((byte) 0))
            .protocol(IpNumber.UDP)
            .srcAddr((Inet4Address) Inet4Address.getByAddress(new byte[]{8, 8, 4, 4}))
            .dstAddr((Inet4Address) Inet4Address.getByAddress(new byte[]{8, 8, 8, 8}))
            .correctChecksumAtBuild(true)
            .correctLengthAtBuild(true)
            .payloadBuilder(payLoadBuilder)
            .build();

    dnsPacketProxy.handleDnsRequest(ipOutPacket.getRawData());

    assertNotNull(mockEventLoop.lastResponse);
    assertNull(mockEventLoop.lastOutgoing);
    assertTrue(mockEventLoop.lastResponse instanceof IpPacket);
    assertTrue(mockEventLoop.lastResponse.getPayload() instanceof UdpPacket);

    Message responseMsg = new Message(mockEventLoop.lastResponse.getPayload().getPayload().getRawData());
    assertEquals(NOERROR, responseMsg.getHeader().getRcode());
    assertArrayEquals(new Record[] {}, responseMsg.getSectionArray(Section.ANSWER));
    assertNotEquals(0, responseMsg.getSectionArray(Section.AUTHORITY).length);
    assertTrue(responseMsg.getSectionArray(Section.AUTHORITY)[0] instanceof SOARecord);
    assertTrue(responseMsg.getSectionArray(Section.AUTHORITY)[0].getTTL() > 0);
}
 
开发者ID:julian-klode,项目名称:dns66,代码行数:46,代码来源:DnsPacketProxyTest.java


示例5: testBlockedInet6DnsQuery

import org.xbill.DNS.SOARecord; //导入依赖的package包/类
@Test
public void testBlockedInet6DnsQuery() throws Exception {
    Message message = Message.newQuery(new ARecord(new Name("blocked.example.com."),
            0x01,
            3600,
            Inet4Address.getByAddress(new byte[]{0, 0, 0, 0})
    ));

    UdpPacket.Builder payLoadBuilder = new UdpPacket.Builder()
            .srcPort(UdpPort.DOMAIN)
            .dstPort(UdpPort.DOMAIN)
            .srcAddr((Inet6Address) Inet6Address.getByName("::0"))
            .dstAddr((Inet6Address) Inet6Address.getByName("::1"))
            .correctChecksumAtBuild(true)
            .correctLengthAtBuild(true)
            .payloadBuilder(
                    new UnknownPacket.Builder()
                            .rawData(message.toWire())
            );

    IpPacket ipOutPacket = new IpV6Packet.Builder()
            .version(IpVersion.IPV6)
            .trafficClass(IpV6SimpleTrafficClass.newInstance((byte) 0))
            .flowLabel(IpV6SimpleFlowLabel.newInstance(0))
            .nextHeader(IpNumber.UDP)
            .srcAddr((Inet6Address) Inet6Address.getByName("::0"))
            .dstAddr((Inet6Address) Inet6Address.getByName("::1"))
            .correctLengthAtBuild(true)
            .payloadBuilder(payLoadBuilder)
            .build();

    dnsPacketProxy.handleDnsRequest(ipOutPacket.getRawData());

    assertNotNull(mockEventLoop.lastResponse);
    assertNull(mockEventLoop.lastOutgoing);
    assertTrue(mockEventLoop.lastResponse instanceof IpPacket);
    assertTrue(mockEventLoop.lastResponse.getPayload() instanceof UdpPacket);

    Message responseMsg = new Message(mockEventLoop.lastResponse.getPayload().getPayload().getRawData());
    assertEquals(NOERROR, responseMsg.getHeader().getRcode());
    assertArrayEquals(new Record[] {}, responseMsg.getSectionArray(Section.ANSWER));
    assertNotEquals(0, responseMsg.getSectionArray(Section.AUTHORITY).length);
    assertTrue(responseMsg.getSectionArray(Section.AUTHORITY)[0] instanceof SOARecord);
    assertTrue(responseMsg.getSectionArray(Section.AUTHORITY)[0].getTTL() > 0);
}
 
开发者ID:julian-klode,项目名称:dns66,代码行数:46,代码来源:DnsPacketProxyTest.java


示例6: beforeTestMethod

import org.xbill.DNS.SOARecord; //导入依赖的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


示例7: addNegative

import org.xbill.DNS.SOARecord; //导入依赖的package包/类
public synchronized void addNegative(Name arg0, int arg1, SOARecord arg2, int arg3) {
    throw new UnsupportedOperationException("ZoneCache is a mock used only for testing purpose");
}
 
开发者ID:twachan,项目名称:James,代码行数:4,代码来源:DNSJavaServiceTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JProductAttEdit类代码示例发布时间:2022-05-22
下一篇:
Java GenericService类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap