mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-15 03:59:38 +02:00
Improve Socks5 Bytestreams
- determine all local IPv4 and IPv6 addresses - prevent loopback addresses from appearing as streamhost Some unit tests where changed because they assumed that a host only has one local address. But nowadays hosts often have more, at least because they are IPv4 and IPv6 multi-homed.
This commit is contained in:
parent
650da55b23
commit
b468a29881
5 changed files with 82 additions and 45 deletions
|
@ -799,10 +799,9 @@ public class Socks5ByteStreamManagerTest {
|
|||
|
||||
public void verify(Bytestream request, Bytestream response) {
|
||||
assertEquals(response.getSessionID(), request.getSessionID());
|
||||
assertEquals(2, request.getStreamHosts().size());
|
||||
StreamHost streamHost1 = (StreamHost) request.getStreamHosts().toArray()[0];
|
||||
StreamHost streamHost1 = request.getStreamHosts().get(0);
|
||||
assertEquals(response.getUsedHost().getJID(), streamHost1.getJID());
|
||||
StreamHost streamHost2 = (StreamHost) request.getStreamHosts().toArray()[1];
|
||||
StreamHost streamHost2 = request.getStreamHosts().get(request.getStreamHosts().size() - 1);
|
||||
assertEquals(response.getUsedHost().getJID(), streamHost2.getJID());
|
||||
assertEquals("localAddress", streamHost2.getAddress());
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ 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;
|
||||
|
@ -144,7 +145,13 @@ public class Socks5ProxyTest {
|
|||
proxy.addLocalAddress("same");
|
||||
proxy.addLocalAddress("same");
|
||||
|
||||
assertEquals(2, proxy.getLocalAddresses().size());
|
||||
int sameCount = 0;
|
||||
for(String localAddress : proxy.getLocalAddresses()) {
|
||||
if ("same".equals(localAddress)) {
|
||||
sameCount++;
|
||||
}
|
||||
}
|
||||
assertEquals(1, sameCount);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -297,7 +304,6 @@ public class Socks5ProxyTest {
|
|||
proxy.start();
|
||||
|
||||
assertTrue(proxy.isRunning());
|
||||
|
||||
String digest = new String(new byte[] { (byte) 0xAA });
|
||||
|
||||
// add digest to allow connection
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue