Search in sources :

Example 66 with Name

use of org.xbill.DNS.Name in project datarouter by hotpads.

the class DnsUpdater method addCname.

public String addCname(String subdomain, String target) throws TextParseException {
    Name zone = new Name(settings.zone.get());
    if (!target.endsWith(".")) {
        target = target + ".";
    }
    var update = new Update(zone);
    Message response;
    try {
        update.add(new Name(subdomain, zone), Type.CNAME, 300, target);
        SimpleResolver resolver = makeResolver();
        response = resolver.send(update);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    checkSuccess(response);
    return response.toString();
}
Also used : Message(org.xbill.DNS.Message) IOException(java.io.IOException) Update(org.xbill.DNS.Update) SimpleResolver(org.xbill.DNS.SimpleResolver) Name(org.xbill.DNS.Name)

Example 67 with Name

use of org.xbill.DNS.Name in project nhin-d by DirectProject.

the class DNSConnectionTest method testDNSSocketConnectionUDPWithProxyStore.

public void testDNSSocketConnectionUDPWithProxyStore() throws Exception {
    DNSServerSettings settings = new DNSServerSettings();
    settings.setPort(AvailablePortFinder.getNextAvailable(1024));
    DNSServer server = new DNSServer(new ProxyDNSStore(), settings);
    server.start();
    // give the server a couple seconds to start
    Thread.sleep(2000);
    // turn on debug settings for the DNS client
    Options.set("verbose", "true");
    Lookup lu = new Lookup(new Name("google.com"), Type.A);
    ExtendedResolver resolver = new ExtendedResolver(IPUtils.getDNSLocalIps());
    resolver.setTCP(false);
    resolver.setPort(settings.getPort());
    // default retries is 3, limite to 2
    lu.setResolver(resolver);
    Record[] retRecords = lu.run();
    assertNotNull(retRecords);
    server.stop();
    Thread.sleep(2000);
}
Also used : ExtendedResolver(org.xbill.DNS.ExtendedResolver) Lookup(org.xbill.DNS.Lookup) Record(org.xbill.DNS.Record) Name(org.xbill.DNS.Name)

Example 68 with Name

use of org.xbill.DNS.Name in project nhin-d by DirectProject.

the class DNSConnectionTest method testDNSSocketConnectionTCPWithProxyStore.

public void testDNSSocketConnectionTCPWithProxyStore() throws Exception {
    DNSServerSettings settings = new DNSServerSettings();
    settings.setPort(AvailablePortFinder.getNextAvailable(1024));
    DNSServer server = new DNSServer(new ProxyDNSStore(), settings);
    server.start();
    // give the server a couple seconds to start
    Thread.sleep(2000);
    // turn on debug settings for the DNS client
    Options.set("verbose", "true");
    Lookup lu = new Lookup(new Name("google.com"), Type.A);
    ExtendedResolver resolver = new ExtendedResolver(IPUtils.getDNSLocalIps());
    resolver.setTCP(true);
    resolver.setPort(settings.getPort());
    // default retries is 3, limite to 2
    lu.setResolver(resolver);
    Record[] retRecords = lu.run();
    assertNotNull(retRecords);
    server.stop();
    Thread.sleep(2000);
}
Also used : ExtendedResolver(org.xbill.DNS.ExtendedResolver) Lookup(org.xbill.DNS.Lookup) Record(org.xbill.DNS.Record) Name(org.xbill.DNS.Name)

Example 69 with Name

use of org.xbill.DNS.Name in project nhin-d by DirectProject.

the class RESTSmtpAgentConfigFunctional_Test method setUp.

/**
     * Initialize the servers- LDAP and HTTP.
     */
@SuppressWarnings("unchecked")
@Override
public void setUp() throws Exception {
    // check for Windows... it doens't like file://<drive>... turns it into FTP
    File file = new File("./src/test/resources/bundles/testBundle.p7b");
    if (file.getAbsolutePath().contains(":/"))
        filePrefix = "file:///";
    else
        filePrefix = "file:///";
    CertCacheFactory.getInstance().flushAll();
    /*
		 * Setup the LDAP Server
		 */
    MutablePartitionConfiguration pcfg = new MutablePartitionConfiguration();
    pcfg.setName("lookupTest");
    pcfg.setSuffix("cn=lookupTest");
    // Create some indices
    Set<String> indexedAttrs = new HashSet<String>();
    indexedAttrs.add("objectClass");
    indexedAttrs.add("cn");
    pcfg.setIndexedAttributes(indexedAttrs);
    // Create a first entry associated to the partition
    Attributes attrs = new BasicAttributes(true);
    // First, the objectClass attribute
    Attribute attr = new BasicAttribute("objectClass");
    attr.add("top");
    attrs.put(attr);
    // Associate this entry to the partition
    pcfg.setContextEntry(attrs);
    // As we can create more than one partition, we must store
    // each created partition in a Set before initialization
    Set<MutablePartitionConfiguration> pcfgs = new HashSet<MutablePartitionConfiguration>();
    pcfgs.add(pcfg);
    //
    //
    //
    // add the lookupTestPublic
    //
    //
    pcfg = new MutablePartitionConfiguration();
    pcfg.setName("lookupTestPublic");
    pcfg.setSuffix("cn=lookupTestPublic");
    // Create some indices
    indexedAttrs = new HashSet<String>();
    indexedAttrs.add("objectClass");
    indexedAttrs.add("cn");
    pcfg.setIndexedAttributes(indexedAttrs);
    // Create a first entry associated to the partition
    attrs = new BasicAttributes(true);
    // First, the objectClass attribute
    attr = new BasicAttribute("objectClass");
    attr.add("top");
    attrs.put(attr);
    // Associate this entry to the partition
    pcfg.setContextEntry(attrs);
    // As we can create more than one partition, we must store
    // each created partition in a Set before initialization
    pcfgs.add(pcfg);
    configuration.setContextPartitionConfigurations(pcfgs);
    this.configuration.setWorkingDirectory(new File("LDAP-TEST"));
    // add the private key schema
    ///
    Set<AbstractBootstrapSchema> schemas = configuration.getBootstrapSchemas();
    schemas.add(new PrivkeySchema());
    configuration.setBootstrapSchemas(schemas);
    super.setUp();
    // import the ldif file
    InputStream stream = TestUtils.class.getResourceAsStream("/ldifs/privCertsOnly.ldif");
    if (stream == null)
        throw new IOException("Failed to load ldif file");
    importLdif(stream);
    // setup the mock DNS SRV adapter
    mockLookup = mock(Lookup.class);
    LookupFactory.getFactory().addOverrideImplementation(mockLookup);
    SRVRecord srvRecord = new SRVRecord(new Name("_ldap._tcp.example.com."), DClass.IN, 3600, 0, 1, port, new Name("localhost."));
    when(mockLookup.run()).thenReturn(new Record[] { srvRecord });
    // create the web service and proxy
    ConfigServiceRunner.startConfigService();
    proxy = new ConfigurationServiceProxy(ConfigServiceRunner.getConfigServiceURL());
    certService = new DefaultCertificateService(ConfigServiceRunner.getRestAPIBaseURL(), HttpClientFactory.createHttpClient(), new OpenServiceSecurityManager());
}
Also used : BasicAttribute(javax.naming.directory.BasicAttribute) BasicAttributes(javax.naming.directory.BasicAttributes) Attribute(javax.naming.directory.Attribute) BasicAttribute(javax.naming.directory.BasicAttribute) DefaultCertificateService(org.nhind.config.rest.impl.DefaultCertificateService) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) BasicAttributes(javax.naming.directory.BasicAttributes) Attributes(javax.naming.directory.Attributes) OpenServiceSecurityManager(org.nhindirect.common.rest.OpenServiceSecurityManager) IOException(java.io.IOException) PrivkeySchema(org.nhindirect.ldap.PrivkeySchema) Name(org.xbill.DNS.Name) AbstractBootstrapSchema(org.apache.directory.server.core.schema.bootstrap.AbstractBootstrapSchema) MutablePartitionConfiguration(org.apache.directory.server.core.configuration.MutablePartitionConfiguration) Lookup(org.nhindirect.stagent.cert.impl.util.Lookup) SRVRecord(org.xbill.DNS.SRVRecord) File(java.io.File) ConfigurationServiceProxy(org.nhind.config.ConfigurationServiceProxy) HashSet(java.util.HashSet)

Example 70 with Name

use of org.xbill.DNS.Name in project opennms by OpenNMS.

the class DNSServer method addAdditional2.

private void addAdditional2(final Message response, final int section, final int flags) {
    final Record[] records = response.getSectionArray(section);
    for (int i = 0; i < records.length; i++) {
        final Record r = records[i];
        final Name glueName = r.getAdditionalName();
        if (glueName != null)
            addGlue(response, glueName, flags);
    }
}
Also used : CNAMERecord(org.xbill.DNS.CNAMERecord) TSIGRecord(org.xbill.DNS.TSIGRecord) OPTRecord(org.xbill.DNS.OPTRecord) Record(org.xbill.DNS.Record) DNAMERecord(org.xbill.DNS.DNAMERecord) Name(org.xbill.DNS.Name)

Aggregations

Name (org.xbill.DNS.Name)110 Record (org.xbill.DNS.Record)38 Message (org.xbill.DNS.Message)19 SRVRecord (org.xbill.DNS.SRVRecord)18 ArrayList (java.util.ArrayList)13 IOException (java.io.IOException)12 UnknownHostException (java.net.UnknownHostException)11 Lookup (org.xbill.DNS.Lookup)10 TextParseException (org.xbill.DNS.TextParseException)10 ARecord (org.xbill.DNS.ARecord)9 CNAMERecord (org.xbill.DNS.CNAMERecord)9 ExtendedResolver (org.xbill.DNS.ExtendedResolver)9 RRset (org.xbill.DNS.RRset)9 SimpleResolver (org.xbill.DNS.SimpleResolver)9 Zone (org.xbill.DNS.Zone)9 NSRecord (org.xbill.DNS.NSRecord)8 TSIG (org.xbill.DNS.TSIG)7 TXTRecord (org.xbill.DNS.TXTRecord)7 HashSet (java.util.HashSet)6 Iterator (java.util.Iterator)6