mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-22 04:27:58 +01:00
Bump MiniDNS to 0.3.0
This commit is contained in:
parent
ce715fc91e
commit
82cbc40327
11 changed files with 43 additions and 43 deletions
|
@ -93,7 +93,7 @@ import org.jxmpp.jid.EntityFullJid;
|
|||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.parts.Resourcepart;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
import org.minidns.dnsname.DNSName;
|
||||
import org.minidns.dnsname.DnsName;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
|
||||
|
@ -614,7 +614,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
}
|
||||
} else {
|
||||
// N.B.: Important to use config.serviceName and not AbstractXMPPConnection.serviceName
|
||||
DNSName dnsName = DNSName.from(config.getXMPPServiceDomain());
|
||||
DnsName dnsName = DnsName.from(config.getXMPPServiceDomain());
|
||||
hostAddresses = DNSUtil.resolveXMPPServiceDomain(dnsName, failedAddresses, config.getDnssecMode());
|
||||
}
|
||||
// Either the populated host addresses are not empty *or* there must be at least one failed address.
|
||||
|
|
|
@ -44,7 +44,7 @@ import org.jxmpp.jid.EntityBareJid;
|
|||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.jxmpp.jid.parts.Resourcepart;
|
||||
import org.jxmpp.stringprep.XmppStringprepException;
|
||||
import org.minidns.dnsname.DNSName;
|
||||
import org.minidns.dnsname.DnsName;
|
||||
|
||||
/**
|
||||
* Configuration to use while establishing the connection to the server.
|
||||
|
@ -67,7 +67,7 @@ public abstract class ConnectionConfiguration {
|
|||
protected final DomainBareJid xmppServiceDomain;
|
||||
|
||||
protected final InetAddress hostAddress;
|
||||
protected final DNSName host;
|
||||
protected final DnsName host;
|
||||
protected final int port;
|
||||
|
||||
private final String keystorePath;
|
||||
|
@ -507,7 +507,7 @@ public abstract class ConnectionConfiguration {
|
|||
private SocketFactory socketFactory;
|
||||
private DomainBareJid xmppServiceDomain;
|
||||
private InetAddress hostAddress;
|
||||
private DNSName host;
|
||||
private DnsName host;
|
||||
private int port = 5222;
|
||||
private boolean allowEmptyOrNullUsername = false;
|
||||
private boolean saslMechanismsSealed;
|
||||
|
@ -625,7 +625,7 @@ public abstract class ConnectionConfiguration {
|
|||
* @return a reference to this builder.
|
||||
*/
|
||||
public B setHost(String host) {
|
||||
DNSName hostDnsName = DNSName.from(host);
|
||||
DnsName hostDnsName = DnsName.from(host);
|
||||
return setHost(hostDnsName);
|
||||
}
|
||||
|
||||
|
@ -637,7 +637,7 @@ public abstract class ConnectionConfiguration {
|
|||
* @param host the DNS name of the host providing the XMPP service.
|
||||
* @return a reference to this builder.
|
||||
*/
|
||||
public B setHost(DNSName host) {
|
||||
public B setHost(DnsName host) {
|
||||
this.host = host;
|
||||
return getThis();
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.jivesoftware.smack.util.dns.HostAddress;
|
|||
import org.jivesoftware.smack.util.dns.SRVRecord;
|
||||
import org.jivesoftware.smack.util.dns.SmackDaneProvider;
|
||||
|
||||
import org.minidns.dnsname.DNSName;
|
||||
import org.minidns.dnsname.DnsName;
|
||||
|
||||
/**
|
||||
* Utility class to perform DNS lookups for XMPP services.
|
||||
|
@ -89,10 +89,10 @@ public class DNSUtil {
|
|||
server(XMPP_SERVER_DNS_SRV_PREFIX),
|
||||
client(XMPP_CLIENT_DNS_SRV_PREFIX),
|
||||
;
|
||||
public final DNSName srvPrefix;
|
||||
public final DnsName srvPrefix;
|
||||
|
||||
DomainType(String srvPrefixString) {
|
||||
srvPrefix = DNSName.from(srvPrefixString);
|
||||
srvPrefix = DnsName.from(srvPrefixString);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ public class DNSUtil {
|
|||
* @return List of HostAddress, which encompasses the hostname and port that the
|
||||
* XMPP server can be reached at for the specified domain.
|
||||
*/
|
||||
public static List<HostAddress> resolveXMPPServiceDomain(DNSName domain, List<HostAddress> failedAddresses, DnssecMode dnssecMode) {
|
||||
public static List<HostAddress> resolveXMPPServiceDomain(DnsName domain, List<HostAddress> failedAddresses, DnssecMode dnssecMode) {
|
||||
return resolveDomain(domain, DomainType.client, failedAddresses, dnssecMode);
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ public class DNSUtil {
|
|||
* @return List of HostAddress, which encompasses the hostname and port that the
|
||||
* XMPP server can be reached at for the specified domain.
|
||||
*/
|
||||
public static List<HostAddress> resolveXMPPServerDomain(DNSName domain, List<HostAddress> failedAddresses, DnssecMode dnssecMode) {
|
||||
public static List<HostAddress> resolveXMPPServerDomain(DnsName domain, List<HostAddress> failedAddresses, DnssecMode dnssecMode) {
|
||||
return resolveDomain(domain, DomainType.server, failedAddresses, dnssecMode);
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ public class DNSUtil {
|
|||
* @param failedAddresses a list that will be populated with host addresses that failed to resolve.
|
||||
* @return a list of resolver host addresses for this domain.
|
||||
*/
|
||||
private static List<HostAddress> resolveDomain(DNSName domain, DomainType domainType,
|
||||
private static List<HostAddress> resolveDomain(DnsName domain, DomainType domainType,
|
||||
List<HostAddress> failedAddresses, DnssecMode dnssecMode) {
|
||||
if (dnsResolver == null) {
|
||||
throw new IllegalStateException("No DNS Resolver active in Smack");
|
||||
|
@ -150,7 +150,7 @@ public class DNSUtil {
|
|||
List<HostAddress> addresses = new ArrayList<HostAddress>();
|
||||
|
||||
// Step one: Do SRV lookups
|
||||
DNSName srvDomain = DNSName.from(domainType.srvPrefix, domain);
|
||||
DnsName srvDomain = DnsName.from(domainType.srvPrefix, domain);
|
||||
|
||||
List<SRVRecord> srvRecords = dnsResolver.lookupSRVRecords(srvDomain, failedAddresses, dnssecMode);
|
||||
if (srvRecords != null && !srvRecords.isEmpty()) {
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.logging.Logger;
|
|||
|
||||
import org.jivesoftware.smack.ConnectionConfiguration.DnssecMode;
|
||||
|
||||
import org.minidns.dnsname.DNSName;
|
||||
import org.minidns.dnsname.DnsName;
|
||||
|
||||
/**
|
||||
* Implementations of this interface define a class that is capable of resolving DNS addresses.
|
||||
|
@ -48,14 +48,14 @@ public abstract class DNSResolver {
|
|||
* @param dnssecMode security mode.
|
||||
* @return The list of SRV records mapped to the service name.
|
||||
*/
|
||||
public final List<SRVRecord> lookupSRVRecords(DNSName name, List<HostAddress> failedAddresses, DnssecMode dnssecMode) {
|
||||
public final List<SRVRecord> lookupSRVRecords(DnsName name, List<HostAddress> failedAddresses, DnssecMode dnssecMode) {
|
||||
checkIfDnssecRequestedAndSupported(dnssecMode);
|
||||
return lookupSRVRecords0(name, failedAddresses, dnssecMode);
|
||||
}
|
||||
|
||||
protected abstract List<SRVRecord> lookupSRVRecords0(DNSName name, List<HostAddress> failedAddresses, DnssecMode dnssecMode);
|
||||
protected abstract List<SRVRecord> lookupSRVRecords0(DnsName name, List<HostAddress> failedAddresses, DnssecMode dnssecMode);
|
||||
|
||||
public final HostAddress lookupHostAddress(DNSName name, int port, List<HostAddress> failedAddresses, DnssecMode dnssecMode) {
|
||||
public final HostAddress lookupHostAddress(DnsName name, int port, List<HostAddress> failedAddresses, DnssecMode dnssecMode) {
|
||||
checkIfDnssecRequestedAndSupported(dnssecMode);
|
||||
List<InetAddress> inetAddresses = lookupHostAddress0(name, failedAddresses, dnssecMode);
|
||||
if (inetAddresses == null || inetAddresses.isEmpty()) {
|
||||
|
@ -78,7 +78,7 @@ public abstract class DNSResolver {
|
|||
* @param dnssecMode the selected DNSSEC mode
|
||||
* @return A list, either empty or non-empty, or <code>null</code>
|
||||
*/
|
||||
protected List<InetAddress> lookupHostAddress0(DNSName name, List<HostAddress> failedAddresses, DnssecMode dnssecMode) {
|
||||
protected List<InetAddress> lookupHostAddress0(DnsName name, List<HostAddress> failedAddresses, DnssecMode dnssecMode) {
|
||||
// Default implementation of a DNS name lookup for A/AAAA records. It is assumed that this method does never
|
||||
// support DNSSEC. Subclasses are free to override this method.
|
||||
if (dnssecMode != DnssecMode.disabled) {
|
||||
|
|
|
@ -26,10 +26,10 @@ import java.util.Map.Entry;
|
|||
|
||||
import org.jivesoftware.smack.SmackException.ConnectionException;
|
||||
|
||||
import org.minidns.dnsname.DNSName;
|
||||
import org.minidns.dnsname.DnsName;
|
||||
|
||||
public class HostAddress {
|
||||
private final DNSName fqdn;
|
||||
private final DnsName fqdn;
|
||||
private final int port;
|
||||
private final Map<InetAddress, Exception> exceptions = new LinkedHashMap<>();
|
||||
private final List<InetAddress> inetAddresses;
|
||||
|
@ -42,7 +42,7 @@ public class HostAddress {
|
|||
* @param inetAddresses list of addresses.
|
||||
* @throws IllegalArgumentException If the port is out of valid range (0 - 65535).
|
||||
*/
|
||||
public HostAddress(DNSName fqdn, int port, List<InetAddress> inetAddresses) {
|
||||
public HostAddress(DnsName fqdn, int port, List<InetAddress> inetAddresses) {
|
||||
if (port < 0 || port > 65535)
|
||||
throw new IllegalArgumentException(
|
||||
"Port must be a 16-bit unsigned integer (i.e. between 0-65535. Port was: " + port);
|
||||
|
@ -65,7 +65,7 @@ public class HostAddress {
|
|||
* @param fqdn the domain name of the host.
|
||||
* @param e the exception causing the failure.
|
||||
*/
|
||||
public HostAddress(DNSName fqdn, Exception e) {
|
||||
public HostAddress(DnsName fqdn, Exception e) {
|
||||
this.fqdn = fqdn;
|
||||
this.port = 5222;
|
||||
inetAddresses = Collections.emptyList();
|
||||
|
@ -88,7 +88,7 @@ public class HostAddress {
|
|||
*
|
||||
* @return the fully qualified domain name or <code>null</code>
|
||||
*/
|
||||
public DNSName getFQDN() {
|
||||
public DnsName getFQDN() {
|
||||
return fqdn;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.util.List;
|
|||
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
import org.minidns.dnsname.DNSName;
|
||||
import org.minidns.dnsname.DnsName;
|
||||
|
||||
/**
|
||||
* A DNS SRV RR.
|
||||
|
@ -46,7 +46,7 @@ public class SRVRecord extends HostAddress implements Comparable<SRVRecord> {
|
|||
* @param inetAddresses list of addresses.
|
||||
* @throws IllegalArgumentException fqdn is null or any other field is not in valid range (0-65535).
|
||||
*/
|
||||
public SRVRecord(DNSName fqdn, int port, int priority, int weight, List<InetAddress> inetAddresses) {
|
||||
public SRVRecord(DnsName fqdn, int port, int priority, int weight, List<InetAddress> inetAddresses) {
|
||||
super(fqdn, port, inetAddresses);
|
||||
StringUtils.requireNotNullOrEmpty(fqdn, "The FQDN must not be null");
|
||||
if (weight < 0 || weight > 65535)
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.jivesoftware.smack.SmackException.ConnectionException;
|
|||
import org.jivesoftware.smack.util.dns.HostAddress;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.minidns.dnsname.DNSName;
|
||||
import org.minidns.dnsname.DnsName;
|
||||
|
||||
public class SmackExceptionTest {
|
||||
|
||||
|
@ -36,14 +36,14 @@ public class SmackExceptionTest {
|
|||
public void testConnectionException() throws UnknownHostException {
|
||||
List<HostAddress> failedAddresses = new LinkedList<HostAddress>();
|
||||
|
||||
DNSName host = DNSName.from("foo.bar.example");
|
||||
DnsName host = DnsName.from("foo.bar.example");
|
||||
InetAddress inetAddress = InetAddress.getByAddress(host.toString(), new byte[] { 0, 0, 0, 0 });
|
||||
List<InetAddress> inetAddresses = Collections.singletonList(inetAddress);
|
||||
HostAddress hostAddress = new HostAddress(host, 1234, inetAddresses);
|
||||
hostAddress.setException(new Exception("Failed for some reason"));
|
||||
failedAddresses.add(hostAddress);
|
||||
|
||||
host = DNSName.from("barz.example");
|
||||
host = DnsName.from("barz.example");
|
||||
inetAddress = InetAddress.getByAddress(host.toString(), new byte[] { 0, 0, 0, 0 });
|
||||
inetAddresses = Collections.singletonList(inetAddress);
|
||||
hostAddress = new HostAddress(host, 5678, inetAddresses);
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.jivesoftware.smack.util.dns.DNSResolver;
|
|||
import org.jivesoftware.smack.util.dns.HostAddress;
|
||||
import org.jivesoftware.smack.util.dns.SRVRecord;
|
||||
|
||||
import org.minidns.dnsname.DNSName;
|
||||
import org.minidns.dnsname.DnsName;
|
||||
import org.xbill.DNS.Lookup;
|
||||
import org.xbill.DNS.Record;
|
||||
import org.xbill.DNS.TextParseException;
|
||||
|
@ -50,7 +50,7 @@ public class DNSJavaResolver extends DNSResolver implements SmackInitializer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<SRVRecord> lookupSRVRecords0(DNSName name, List<HostAddress> failedAddresses, DnssecMode dnssecMode) {
|
||||
protected List<SRVRecord> lookupSRVRecords0(DnsName name, List<HostAddress> failedAddresses, DnssecMode dnssecMode) {
|
||||
List<SRVRecord> res = new ArrayList<>();
|
||||
|
||||
Lookup lookup;
|
||||
|
@ -68,7 +68,7 @@ public class DNSJavaResolver extends DNSResolver implements SmackInitializer {
|
|||
for (Record record : recs) {
|
||||
org.xbill.DNS.SRVRecord srvRecord = (org.xbill.DNS.SRVRecord) record;
|
||||
if (srvRecord != null && srvRecord.getTarget() != null) {
|
||||
DNSName host = DNSName.from(srvRecord.getTarget().toString());
|
||||
DnsName host = DnsName.from(srvRecord.getTarget().toString());
|
||||
int port = srvRecord.getPort();
|
||||
int priority = srvRecord.getPriority();
|
||||
int weight = srvRecord.getWeight();
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.jivesoftware.smack.util.dns.DNSResolver;
|
|||
import org.jivesoftware.smack.util.dns.HostAddress;
|
||||
import org.jivesoftware.smack.util.dns.SRVRecord;
|
||||
|
||||
import org.minidns.dnsname.DNSName;
|
||||
import org.minidns.dnsname.DnsName;
|
||||
|
||||
/**
|
||||
* A DNS resolver (mostly for SRV records), which makes use of the API provided in the javax.* namespace.
|
||||
|
@ -83,7 +83,7 @@ public class JavaxResolver extends DNSResolver implements SmackInitializer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<SRVRecord> lookupSRVRecords0(DNSName name, List<HostAddress> failedAddresses, DnssecMode dnssecMode) {
|
||||
protected List<SRVRecord> lookupSRVRecords0(DnsName name, List<HostAddress> failedAddresses, DnssecMode dnssecMode) {
|
||||
List<SRVRecord> res = null;
|
||||
|
||||
Attribute srvAttribute;
|
||||
|
@ -112,12 +112,12 @@ public class JavaxResolver extends DNSResolver implements SmackInitializer {
|
|||
int weight = Integer.parseInt(srvRecordEntries[srvRecordEntries.length - 3]);
|
||||
String srvTarget = srvRecordEntries[srvRecordEntries.length - 1];
|
||||
// Strip trailing '.' from srvTarget.
|
||||
// Later MiniDNS version may do the right thing when DNSName.from() is called with a DNS name string
|
||||
// Later MiniDNS version may do the right thing when DnsName.from() is called with a DNS name string
|
||||
// having a trailing dot, so this can possibly be removed in future Smack versions.
|
||||
if (srvTarget.length() > 0 && srvTarget.charAt(srvTarget.length() - 1) == '.') {
|
||||
srvTarget = srvTarget.substring(0, srvTarget.length() - 1);
|
||||
}
|
||||
DNSName host = DNSName.from(srvTarget);
|
||||
DnsName host = DnsName.from(srvTarget);
|
||||
|
||||
List<InetAddress> hostAddresses = lookupHostAddress0(host, failedAddresses, dnssecMode);
|
||||
if (shouldContinue(name, host, hostAddresses)) {
|
||||
|
|
|
@ -32,9 +32,9 @@ import org.jivesoftware.smack.util.dns.DNSResolver;
|
|||
import org.jivesoftware.smack.util.dns.HostAddress;
|
||||
import org.jivesoftware.smack.util.dns.SRVRecord;
|
||||
|
||||
import org.minidns.dnsmessage.DNSMessage.RESPONSE_CODE;
|
||||
import org.minidns.dnsmessage.DnsMessage.RESPONSE_CODE;
|
||||
import org.minidns.dnsmessage.Question;
|
||||
import org.minidns.dnsname.DNSName;
|
||||
import org.minidns.dnsname.DnsName;
|
||||
import org.minidns.hla.DnssecResolverApi;
|
||||
import org.minidns.hla.ResolutionUnsuccessfulException;
|
||||
import org.minidns.hla.ResolverApi;
|
||||
|
@ -66,7 +66,7 @@ public class MiniDnsResolver extends DNSResolver implements SmackInitializer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<SRVRecord> lookupSRVRecords0(final DNSName name, List<HostAddress> failedAddresses, DnssecMode dnssecMode) {
|
||||
protected List<SRVRecord> lookupSRVRecords0(final DnsName name, List<HostAddress> failedAddresses, DnssecMode dnssecMode) {
|
||||
final ResolverApi resolver = getResolver(dnssecMode);
|
||||
|
||||
SrvResolverResult result;
|
||||
|
@ -89,7 +89,7 @@ public class MiniDnsResolver extends DNSResolver implements SmackInitializer {
|
|||
|
||||
List<SRVRecord> res = new LinkedList<>();
|
||||
for (SRV srv : result.getAnswers()) {
|
||||
DNSName hostname = srv.target;
|
||||
DnsName hostname = srv.target;
|
||||
List<InetAddress> hostAddresses = lookupHostAddress0(hostname, failedAddresses, dnssecMode);
|
||||
if (shouldContinue(name, hostname, hostAddresses)) {
|
||||
continue;
|
||||
|
@ -103,7 +103,7 @@ public class MiniDnsResolver extends DNSResolver implements SmackInitializer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<InetAddress> lookupHostAddress0(final DNSName name, List<HostAddress> failedAddresses, DnssecMode dnssecMode) {
|
||||
protected List<InetAddress> lookupHostAddress0(final DnsName name, List<HostAddress> failedAddresses, DnssecMode dnssecMode) {
|
||||
final ResolverApi resolver = getResolver(dnssecMode);
|
||||
|
||||
final ResolverResult<A> aResult;
|
||||
|
@ -193,7 +193,7 @@ public class MiniDnsResolver extends DNSResolver implements SmackInitializer {
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean shouldAbortIfNotAuthentic(DNSName name, DnssecMode dnssecMode,
|
||||
private static boolean shouldAbortIfNotAuthentic(DnsName name, DnssecMode dnssecMode,
|
||||
ResolverResult<?> result, List<HostAddress> failedAddresses) {
|
||||
switch (dnssecMode) {
|
||||
case needsDnssec:
|
||||
|
|
|
@ -3,7 +3,7 @@ allprojects {
|
|||
shortVersion = '4.3.0-beta2'
|
||||
isSnapshot = true
|
||||
jxmppVersion = '0.6.0'
|
||||
miniDnsVersion = '0.3.0-alpha1'
|
||||
miniDnsVersion = '0.3.0'
|
||||
smackMinAndroidSdk = 9
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue