1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 00:59:39 +02:00

Introduce Smack's Modular Connection Architecture

This is a complete redesign of what was previously
XmppNioTcpConnection. The new architecture allows to extend an XMPP
client to server (c2s) connection with new transport bindings and
other extensions.
This commit is contained in:
Florian Schmaus 2020-04-04 13:03:31 +02:00
parent cec312fe64
commit cc636fff21
142 changed files with 6819 additions and 4068 deletions

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2013-2018 Florian Schmaus
* Copyright 2013-2020 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
*/
package org.jivesoftware.smack.util.dns.dnsjava;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
@ -24,10 +23,10 @@ import org.jivesoftware.smack.ConnectionConfiguration.DnssecMode;
import org.jivesoftware.smack.initializer.SmackInitializer;
import org.jivesoftware.smack.util.DNSUtil;
import org.jivesoftware.smack.util.dns.DNSResolver;
import org.jivesoftware.smack.util.dns.HostAddress;
import org.jivesoftware.smack.util.dns.SRVRecord;
import org.jivesoftware.smack.util.rce.RemoteConnectionEndpointLookupFailure;
import org.minidns.dnsname.DnsName;
import org.minidns.record.SRV;
import org.xbill.DNS.Lookup;
import org.xbill.DNS.Record;
import org.xbill.DNS.TextParseException;
@ -50,21 +49,26 @@ public class DNSJavaResolver extends DNSResolver implements SmackInitializer {
}
@Override
protected List<SRVRecord> lookupSRVRecords0(DnsName name, List<HostAddress> failedAddresses, DnssecMode dnssecMode) {
List<SRVRecord> res = new ArrayList<>();
protected List<SRV> lookupSrvRecords0(DnsName name, List<RemoteConnectionEndpointLookupFailure> lookupFailures,
DnssecMode dnssecMode) {
Lookup lookup;
try {
lookup = new Lookup(name.ace, Type.SRV);
}
catch (TextParseException e) {
throw new IllegalStateException(e);
RemoteConnectionEndpointLookupFailure failure = new RemoteConnectionEndpointLookupFailure.DnsLookupFailure(
name, e);
lookupFailures.add(failure);
return null;
}
Record[] recs = lookup.run();
if (recs == null)
return res;
if (recs == null) {
// TODO: When does this happen? Do we want/need to record a lookup failure?
return null;
}
List<SRV> res = new ArrayList<>();
for (Record record : recs) {
org.xbill.DNS.SRVRecord srvRecord = (org.xbill.DNS.SRVRecord) record;
if (srvRecord != null && srvRecord.getTarget() != null) {
@ -73,12 +77,7 @@ public class DNSJavaResolver extends DNSResolver implements SmackInitializer {
int priority = srvRecord.getPriority();
int weight = srvRecord.getWeight();
List<InetAddress> hostAddresses = lookupHostAddress0(host, failedAddresses, dnssecMode);
if (shouldContinue(name, host, hostAddresses)) {
continue;
}
SRVRecord r = new SRVRecord(host, port, priority, weight, hostAddresses);
SRV r = new SRV(priority, weight, port, host);
res.add(r);
}
}