mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-12 14:01:08 +01:00
Introduce util.InternetAddress
and use it where sensible. Also fixes a few unit tests along the way.
This commit is contained in:
parent
4334ca33ff
commit
b288768f77
11 changed files with 462 additions and 268 deletions
|
|
@ -17,6 +17,7 @@
|
|||
package org.jivesoftware.smackx.jingle.transports.jingle_s5b;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
|
@ -162,7 +163,7 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
|
|||
private UsedCandidate connectToTheirCandidate(JingleS5BTransportCandidate candidate)
|
||||
throws InterruptedException, TimeoutException, SmackException, XMPPException, IOException {
|
||||
Bytestream.StreamHost streamHost = candidate.getStreamHost();
|
||||
String address = streamHost.getAddress();
|
||||
InetAddress address = streamHost.getAddress().asInetAddress();
|
||||
Socks5Client socks5Client = new Socks5Client(streamHost, theirProposal.getDestinationAddress());
|
||||
Socket socket = socks5Client.getSocket(10 * 1000);
|
||||
LOGGER.log(Level.INFO, "Connected to their StreamHost " + address + " using dstAddr "
|
||||
|
|
@ -173,7 +174,7 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
|
|||
private UsedCandidate connectToOurCandidate(JingleS5BTransportCandidate candidate)
|
||||
throws InterruptedException, TimeoutException, SmackException, XMPPException, IOException {
|
||||
Bytestream.StreamHost streamHost = candidate.getStreamHost();
|
||||
String address = streamHost.getAddress();
|
||||
InetAddress address = streamHost.getAddress().asInetAddress();
|
||||
Socks5ClientForInitiator socks5Client = new Socks5ClientForInitiator(
|
||||
streamHost, ourProposal.getDestinationAddress(), jingleSession.getConnection(),
|
||||
ourProposal.getStreamId(), jingleSession.getRemote());
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements;
|
||||
|
||||
import org.jivesoftware.smack.util.InternetAddress;
|
||||
import org.jivesoftware.smack.util.Objects;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
|
@ -40,14 +41,17 @@ public final class JingleS5BTransportCandidate extends JingleContentTransportCan
|
|||
public static final String ATTR_TYPE = "type";
|
||||
|
||||
private final String cid;
|
||||
private final String host;
|
||||
private final InternetAddress host;
|
||||
private final Jid jid;
|
||||
private final int port;
|
||||
private final int priority;
|
||||
private final Type type;
|
||||
|
||||
public JingleS5BTransportCandidate(String candidateId, String host, Jid jid, int port, int priority, Type type) {
|
||||
public JingleS5BTransportCandidate(String candidateId, String hostString, Jid jid, int port, int priority, Type type) {
|
||||
this(candidateId, InternetAddress.from(hostString), jid, port, priority, type);
|
||||
}
|
||||
|
||||
public JingleS5BTransportCandidate(String candidateId, InternetAddress host, Jid jid, int port, int priority, Type type) {
|
||||
Objects.requireNonNull(candidateId);
|
||||
Objects.requireNonNull(host);
|
||||
Objects.requireNonNull(jid);
|
||||
|
|
@ -102,7 +106,7 @@ public final class JingleS5BTransportCandidate extends JingleContentTransportCan
|
|||
return cid;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
public InternetAddress getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
|
|
@ -149,7 +153,7 @@ public final class JingleS5BTransportCandidate extends JingleContentTransportCan
|
|||
|
||||
public static final class Builder {
|
||||
private String cid;
|
||||
private String host;
|
||||
private InternetAddress host;
|
||||
private Jid jid;
|
||||
private int port = -1;
|
||||
private int priority = -1;
|
||||
|
|
@ -163,7 +167,12 @@ public final class JingleS5BTransportCandidate extends JingleContentTransportCan
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder setHost(String host) {
|
||||
public Builder setHost(String host) {
|
||||
InternetAddress inetAddress = InternetAddress.from(host);
|
||||
return setHost(inetAddress);
|
||||
}
|
||||
|
||||
public Builder setHost(InternetAddress host) {
|
||||
this.host = host;
|
||||
return this;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue