mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-26 12:37:58 +01:00
Cleanup Bytestream and Streamhost
remove unnecessary setPort() setter.
This commit is contained in:
parent
b468a29881
commit
62893376dd
6 changed files with 24 additions and 38 deletions
|
@ -674,10 +674,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
|||
continue outerloop;
|
||||
}
|
||||
}
|
||||
StreamHost streamHost = new StreamHost(this.connection.getUser(),
|
||||
address);
|
||||
streamHost.setPort(port);
|
||||
streamHosts.add(streamHost);
|
||||
streamHosts.add(new StreamHost(connection.getUser(), address, port));
|
||||
}
|
||||
return streamHosts;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,6 @@ public class Bytestream extends IQ {
|
|||
* The default constructor
|
||||
*/
|
||||
public Bytestream() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -59,7 +58,6 @@ public class Bytestream extends IQ {
|
|||
* @see #setSessionID(String)
|
||||
*/
|
||||
public Bytestream(final String SID) {
|
||||
super();
|
||||
setSessionID(SID);
|
||||
}
|
||||
|
||||
|
@ -123,8 +121,7 @@ public class Bytestream extends IQ {
|
|||
* @return The added stream host.
|
||||
*/
|
||||
public StreamHost addStreamHost(final String JID, final String address, final int port) {
|
||||
StreamHost host = new StreamHost(JID, address);
|
||||
host.setPort(port);
|
||||
StreamHost host = new StreamHost(JID, address, port);
|
||||
addStreamHost(host);
|
||||
|
||||
return host;
|
||||
|
@ -276,7 +273,11 @@ public class Bytestream extends IQ {
|
|||
|
||||
private final String addy;
|
||||
|
||||
private int port = 0;
|
||||
private final int port;
|
||||
|
||||
public StreamHost(String jid, String address) {
|
||||
this(jid, address, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
|
@ -284,9 +285,10 @@ public class Bytestream extends IQ {
|
|||
* @param JID The JID of the stream host.
|
||||
* @param address The internet address of the stream host.
|
||||
*/
|
||||
public StreamHost(final String JID, final String address) {
|
||||
public StreamHost(final String JID, final String address, int port) {
|
||||
this.JID = JID;
|
||||
this.addy = address;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -307,15 +309,6 @@ public class Bytestream extends IQ {
|
|||
return addy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the port of the stream host.
|
||||
*
|
||||
* @param port The port on which the potential stream host would accept the connection.
|
||||
*/
|
||||
public void setPort(final int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the port on which the potential stream host would accept the connection.
|
||||
*
|
||||
|
|
|
@ -813,8 +813,9 @@ public class Socks5ByteStreamManagerTest {
|
|||
|
||||
// connect to proxy as target
|
||||
socks5Proxy.addTransfer(digest);
|
||||
StreamHost streamHost = new StreamHost(targetJID, socks5Proxy.getLocalAddresses().get(0));
|
||||
streamHost.setPort(socks5Proxy.getPort());
|
||||
StreamHost streamHost = new StreamHost(targetJID,
|
||||
socks5Proxy.getLocalAddresses().get(0),
|
||||
socks5Proxy.getPort());
|
||||
Socks5Client socks5Client = new Socks5Client(streamHost, digest);
|
||||
InputStream inputStream = socks5Client.getSocket(2000).getInputStream();
|
||||
|
||||
|
|
|
@ -95,8 +95,8 @@ public class Socks5ClientForInitiatorTest {
|
|||
|
||||
// build stream host information for local SOCKS5 proxy
|
||||
StreamHost streamHost = new StreamHost(connection.getUser(),
|
||||
socks5Proxy.getLocalAddresses().get(0));
|
||||
streamHost.setPort(socks5Proxy.getPort());
|
||||
socks5Proxy.getLocalAddresses().get(0),
|
||||
socks5Proxy.getPort());
|
||||
|
||||
// create digest to get the socket opened by target
|
||||
String digest = Socks5Utils.createDigest(sessionID, initiatorJID, targetJID);
|
||||
|
@ -142,8 +142,8 @@ public class Socks5ClientForInitiatorTest {
|
|||
|
||||
// build stream host information
|
||||
final StreamHost streamHost = new StreamHost(connection.getUser(),
|
||||
socks5Proxy.getLocalAddresses().get(0));
|
||||
streamHost.setPort(socks5Proxy.getPort());
|
||||
socks5Proxy.getLocalAddresses().get(0),
|
||||
socks5Proxy.getPort());
|
||||
|
||||
// target connects to local SOCKS5 proxy
|
||||
Thread targetThread = new Thread() {
|
||||
|
@ -216,8 +216,8 @@ public class Socks5ClientForInitiatorTest {
|
|||
Socks5TestProxy socks5Proxy = Socks5TestProxy.getProxy(proxyPort);
|
||||
socks5Proxy.start();
|
||||
|
||||
StreamHost streamHost = new StreamHost(proxyJID, socks5Proxy.getAddress());
|
||||
streamHost.setPort(socks5Proxy.getPort());
|
||||
StreamHost streamHost = new StreamHost(proxyJID,
|
||||
socks5Proxy.getAddress(), socks5Proxy.getPort());
|
||||
|
||||
// create digest to get the socket opened by target
|
||||
String digest = Socks5Utils.createDigest(sessionID, initiatorJID, targetJID);
|
||||
|
@ -276,8 +276,8 @@ public class Socks5ClientForInitiatorTest {
|
|||
Socks5TestProxy socks5Proxy = Socks5TestProxy.getProxy(proxyPort);
|
||||
socks5Proxy.start();
|
||||
|
||||
StreamHost streamHost = new StreamHost(proxyJID, socks5Proxy.getAddress());
|
||||
streamHost.setPort(socks5Proxy.getPort());
|
||||
StreamHost streamHost = new StreamHost(proxyJID,
|
||||
socks5Proxy.getAddress(), socks5Proxy.getPort());
|
||||
|
||||
// create digest to get the socket opened by target
|
||||
String digest = Socks5Utils.createDigest(sessionID, initiatorJID, targetJID);
|
||||
|
|
|
@ -72,8 +72,7 @@ public class Socks5ClientTest {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
StreamHost streamHost = new StreamHost(proxyJID, serverAddress);
|
||||
streamHost.setPort(serverPort);
|
||||
StreamHost streamHost = new StreamHost(proxyJID, serverAddress, serverPort);
|
||||
|
||||
Socks5Client socks5Client = new Socks5Client(streamHost, digest);
|
||||
|
||||
|
@ -131,8 +130,7 @@ public class Socks5ClientTest {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
StreamHost streamHost = new StreamHost(proxyJID, serverAddress);
|
||||
streamHost.setPort(serverPort);
|
||||
StreamHost streamHost = new StreamHost(proxyJID, serverAddress, serverPort);
|
||||
|
||||
Socks5Client socks5Client = new Socks5Client(streamHost, digest);
|
||||
try {
|
||||
|
@ -194,8 +192,7 @@ public class Socks5ClientTest {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
StreamHost streamHost = new StreamHost(proxyJID, serverAddress);
|
||||
streamHost.setPort(serverPort);
|
||||
StreamHost streamHost = new StreamHost(proxyJID, serverAddress, serverPort);
|
||||
|
||||
Socks5Client socks5Client = new Socks5Client(streamHost, digest);
|
||||
try {
|
||||
|
@ -261,8 +258,7 @@ public class Socks5ClientTest {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
StreamHost streamHost = new StreamHost(proxyJID, serverAddress);
|
||||
streamHost.setPort(serverPort);
|
||||
StreamHost streamHost = new StreamHost(proxyJID, serverAddress, serverPort);
|
||||
|
||||
Socks5Client socks5Client = new Socks5Client(streamHost, digest);
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ import java.net.Socket;
|
|||
import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.After;
|
||||
|
|
Loading…
Reference in a new issue