Permalink
Browse files

Fix ResolverApi.resolveSrv(DnsName)

  • Loading branch information...
Flowdalic committed Oct 15, 2018
1 parent 3a08dec commit d5b481be6d41bec12741a29a3a5148e4a638020b
@@ -191,8 +191,8 @@ public SrvResolverResult resolveSrv(DnsName srvDnsName) throws IOException {
throw new IllegalArgumentException();
}

DnsLabel service = srvDnsName.getLabel(labelCount);
DnsLabel proto = srvDnsName.getLabel(labelCount - 1);
DnsLabel service = srvDnsName.getLabel(labelCount- 1);
DnsLabel proto = srvDnsName.getLabel(labelCount - 2);
DnsName name = srvDnsName.stripToLabels(labelCount - 2);

SrvServiceProto srvServiceProto = new SrvServiceProto(service, proto);
@@ -12,13 +12,15 @@

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.io.IOException;
import java.util.Set;

import org.minidns.hla.ResolverApi;
import org.minidns.hla.ResolverResult;
import org.minidns.hla.SrvResolverResult;
import org.minidns.record.A;
import org.minidns.record.SRV;

@@ -45,4 +47,11 @@ public static void idnSrvTest() throws IOException {

assertTrue(aRes.wasSuccessful());
}

@IntegrationTest
public static void resolveSrvTest() throws IOException {
SrvResolverResult resolverResult = ResolverApi.INSTANCE.resolveSrv("_xmpp-client._tcp.jabber.org");
Set<SRV> answers = resolverResult.getAnswers();
assertFalse(answers.isEmpty());
}
}

0 comments on commit d5b481b

Please sign in to comment.