1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-01 16:32:08 +01:00

Cleanup Bytestream and Streamhost

remove unnecessary setPort() setter.
This commit is contained in:
Florian Schmaus 2014-08-19 19:22:08 +02:00
parent b468a29881
commit 62893376dd
6 changed files with 24 additions and 38 deletions

View file

@ -674,10 +674,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
continue outerloop; continue outerloop;
} }
} }
StreamHost streamHost = new StreamHost(this.connection.getUser(), streamHosts.add(new StreamHost(connection.getUser(), address, port));
address);
streamHost.setPort(port);
streamHosts.add(streamHost);
} }
return streamHosts; return streamHosts;
} }

View file

@ -49,7 +49,6 @@ public class Bytestream extends IQ {
* The default constructor * The default constructor
*/ */
public Bytestream() { public Bytestream() {
super();
} }
/** /**
@ -59,7 +58,6 @@ public class Bytestream extends IQ {
* @see #setSessionID(String) * @see #setSessionID(String)
*/ */
public Bytestream(final String SID) { public Bytestream(final String SID) {
super();
setSessionID(SID); setSessionID(SID);
} }
@ -123,8 +121,7 @@ public class Bytestream extends IQ {
* @return The added stream host. * @return The added stream host.
*/ */
public StreamHost addStreamHost(final String JID, final String address, final int port) { public StreamHost addStreamHost(final String JID, final String address, final int port) {
StreamHost host = new StreamHost(JID, address); StreamHost host = new StreamHost(JID, address, port);
host.setPort(port);
addStreamHost(host); addStreamHost(host);
return host; return host;
@ -276,7 +273,11 @@ public class Bytestream extends IQ {
private final String addy; private final String addy;
private int port = 0; private final int port;
public StreamHost(String jid, String address) {
this(jid, address, 0);
}
/** /**
* Default constructor. * Default constructor.
@ -284,9 +285,10 @@ public class Bytestream extends IQ {
* @param JID The JID of the stream host. * @param JID The JID of the stream host.
* @param address The internet address 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.JID = JID;
this.addy = address; this.addy = address;
this.port = port;
} }
/** /**
@ -307,15 +309,6 @@ public class Bytestream extends IQ {
return addy; 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. * Returns the port on which the potential stream host would accept the connection.
* *

View file

@ -813,8 +813,9 @@ public class Socks5ByteStreamManagerTest {
// connect to proxy as target // connect to proxy as target
socks5Proxy.addTransfer(digest); socks5Proxy.addTransfer(digest);
StreamHost streamHost = new StreamHost(targetJID, socks5Proxy.getLocalAddresses().get(0)); StreamHost streamHost = new StreamHost(targetJID,
streamHost.setPort(socks5Proxy.getPort()); socks5Proxy.getLocalAddresses().get(0),
socks5Proxy.getPort());
Socks5Client socks5Client = new Socks5Client(streamHost, digest); Socks5Client socks5Client = new Socks5Client(streamHost, digest);
InputStream inputStream = socks5Client.getSocket(2000).getInputStream(); InputStream inputStream = socks5Client.getSocket(2000).getInputStream();

View file

@ -95,8 +95,8 @@ public class Socks5ClientForInitiatorTest {
// build stream host information for local SOCKS5 proxy // build stream host information for local SOCKS5 proxy
StreamHost streamHost = new StreamHost(connection.getUser(), StreamHost streamHost = new StreamHost(connection.getUser(),
socks5Proxy.getLocalAddresses().get(0)); socks5Proxy.getLocalAddresses().get(0),
streamHost.setPort(socks5Proxy.getPort()); socks5Proxy.getPort());
// create digest to get the socket opened by target // create digest to get the socket opened by target
String digest = Socks5Utils.createDigest(sessionID, initiatorJID, targetJID); String digest = Socks5Utils.createDigest(sessionID, initiatorJID, targetJID);
@ -142,8 +142,8 @@ public class Socks5ClientForInitiatorTest {
// build stream host information // build stream host information
final StreamHost streamHost = new StreamHost(connection.getUser(), final StreamHost streamHost = new StreamHost(connection.getUser(),
socks5Proxy.getLocalAddresses().get(0)); socks5Proxy.getLocalAddresses().get(0),
streamHost.setPort(socks5Proxy.getPort()); socks5Proxy.getPort());
// target connects to local SOCKS5 proxy // target connects to local SOCKS5 proxy
Thread targetThread = new Thread() { Thread targetThread = new Thread() {
@ -216,8 +216,8 @@ public class Socks5ClientForInitiatorTest {
Socks5TestProxy socks5Proxy = Socks5TestProxy.getProxy(proxyPort); Socks5TestProxy socks5Proxy = Socks5TestProxy.getProxy(proxyPort);
socks5Proxy.start(); socks5Proxy.start();
StreamHost streamHost = new StreamHost(proxyJID, socks5Proxy.getAddress()); StreamHost streamHost = new StreamHost(proxyJID,
streamHost.setPort(socks5Proxy.getPort()); socks5Proxy.getAddress(), socks5Proxy.getPort());
// create digest to get the socket opened by target // create digest to get the socket opened by target
String digest = Socks5Utils.createDigest(sessionID, initiatorJID, targetJID); String digest = Socks5Utils.createDigest(sessionID, initiatorJID, targetJID);
@ -276,8 +276,8 @@ public class Socks5ClientForInitiatorTest {
Socks5TestProxy socks5Proxy = Socks5TestProxy.getProxy(proxyPort); Socks5TestProxy socks5Proxy = Socks5TestProxy.getProxy(proxyPort);
socks5Proxy.start(); socks5Proxy.start();
StreamHost streamHost = new StreamHost(proxyJID, socks5Proxy.getAddress()); StreamHost streamHost = new StreamHost(proxyJID,
streamHost.setPort(socks5Proxy.getPort()); socks5Proxy.getAddress(), socks5Proxy.getPort());
// create digest to get the socket opened by target // create digest to get the socket opened by target
String digest = Socks5Utils.createDigest(sessionID, initiatorJID, targetJID); String digest = Socks5Utils.createDigest(sessionID, initiatorJID, targetJID);

View file

@ -72,8 +72,7 @@ public class Socks5ClientTest {
@Override @Override
public void run() { public void run() {
StreamHost streamHost = new StreamHost(proxyJID, serverAddress); StreamHost streamHost = new StreamHost(proxyJID, serverAddress, serverPort);
streamHost.setPort(serverPort);
Socks5Client socks5Client = new Socks5Client(streamHost, digest); Socks5Client socks5Client = new Socks5Client(streamHost, digest);
@ -131,8 +130,7 @@ public class Socks5ClientTest {
@Override @Override
public void run() { public void run() {
StreamHost streamHost = new StreamHost(proxyJID, serverAddress); StreamHost streamHost = new StreamHost(proxyJID, serverAddress, serverPort);
streamHost.setPort(serverPort);
Socks5Client socks5Client = new Socks5Client(streamHost, digest); Socks5Client socks5Client = new Socks5Client(streamHost, digest);
try { try {
@ -194,8 +192,7 @@ public class Socks5ClientTest {
@Override @Override
public void run() { public void run() {
StreamHost streamHost = new StreamHost(proxyJID, serverAddress); StreamHost streamHost = new StreamHost(proxyJID, serverAddress, serverPort);
streamHost.setPort(serverPort);
Socks5Client socks5Client = new Socks5Client(streamHost, digest); Socks5Client socks5Client = new Socks5Client(streamHost, digest);
try { try {
@ -261,8 +258,7 @@ public class Socks5ClientTest {
@Override @Override
public void run() { public void run() {
StreamHost streamHost = new StreamHost(proxyJID, serverAddress); StreamHost streamHost = new StreamHost(proxyJID, serverAddress, serverPort);
streamHost.setPort(serverPort);
Socks5Client socks5Client = new Socks5Client(streamHost, digest); Socks5Client socks5Client = new Socks5Client(streamHost, digest);

View file

@ -30,7 +30,6 @@ import java.net.Socket;
import java.net.SocketException; import java.net.SocketException;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import org.junit.After; import org.junit.After;