Example usage for io.netty.handler.codec.dns DnsRecordType SRV

List of usage examples for io.netty.handler.codec.dns DnsRecordType SRV

Introduction

In this page you can find the example usage for io.netty.handler.codec.dns DnsRecordType SRV.

Prototype

DnsRecordType SRV

To view the source code for io.netty.handler.codec.dns DnsRecordType SRV.

Click Source Link

Document

Service locator RFC 2782 Generalized service location record, used for newer protocols instead of creating protocol-specific records such as MX.

Usage

From source file:com.linecorp.armeria.client.endpoint.dns.DnsServiceEndpointGroup.java

License:Apache License

DnsServiceEndpointGroup(EventLoop eventLoop, int minTtl, int maxTtl,
        DnsServerAddressStreamProvider serverAddressStreamProvider, Backoff backoff, String hostname) {
    super(eventLoop, minTtl, maxTtl, serverAddressStreamProvider, backoff,
            ImmutableList.of(new DefaultDnsQuestion(hostname, DnsRecordType.SRV)), unused -> {
            });/*from   ww w  . ja v a  2  s.  c om*/
    start();
}

From source file:com.linecorp.armeria.client.endpoint.dns.DnsServiceEndpointGroup.java

License:Apache License

@Override
ImmutableSortedSet<Endpoint> onDnsRecords(List<DnsRecord> records, int ttl) throws Exception {
    final ImmutableSortedSet.Builder<Endpoint> builder = ImmutableSortedSet.naturalOrder();
    for (DnsRecord r : records) {
        if (!(r instanceof DnsRawRecord) || r.type() != DnsRecordType.SRV) {
            continue;
        }//from   w ww. ja  va 2  s  .  c  o  m

        final ByteBuf content = ((ByteBufHolder) r).content();
        if (content.readableBytes() <= 6) { // Too few bytes
            warnInvalidRecord(DnsRecordType.SRV, content);
            continue;
        }

        content.markReaderIndex();
        content.skipBytes(2); // priority unused
        final int weight = content.readUnsignedShort();
        final int port = content.readUnsignedShort();

        final Endpoint endpoint;
        try {
            final String target = stripTrailingDot(DefaultDnsRecordDecoder.decodeName(content));
            endpoint = port > 0 ? Endpoint.of(target, port) : Endpoint.of(target);
        } catch (Exception e) {
            content.resetReaderIndex();
            warnInvalidRecord(DnsRecordType.SRV, content);
            continue;
        }

        builder.add(endpoint.withWeight(weight));
    }

    final ImmutableSortedSet<Endpoint> endpoints = builder.build();
    if (logger().isDebugEnabled()) {
        logger().debug("{} Resolved: {} (TTL: {})", logPrefix(),
                endpoints.stream().map(e -> e.authority() + '/' + e.weight()).collect(Collectors.joining(", ")),
                ttl);
    }

    return endpoints;
}

From source file:io.vertx.core.dns.impl.DnsClientImpl.java

License:Open Source License

@Override
public DnsClient resolveSRV(String name, Handler<AsyncResult<List<SrvRecord>>> handler) {
    lookupList(name, handler, DnsRecordType.SRV);
    return this;
}