diff options
author | Christian Schneppe <christian@pix-art.de> | 2019-09-03 19:50:42 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2019-09-03 19:50:42 +0200 |
commit | 71e4bcf9cb807e2f3954a5e968a44a409aaeebd7 (patch) | |
tree | e1f92e73467a3c5cad8da7943fbc8dbf0eb1f6be /src/main/java/de/pixart/messenger/utils/SocksSocketFactory.java | |
parent | edcfdb974dc544c0e79e457f50c12e5942619251 (diff) |
bare minimum direct connections
Diffstat (limited to 'src/main/java/de/pixart/messenger/utils/SocksSocketFactory.java')
-rw-r--r-- | src/main/java/de/pixart/messenger/utils/SocksSocketFactory.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/utils/SocksSocketFactory.java b/src/main/java/de/pixart/messenger/utils/SocksSocketFactory.java index e3465fb9b..0bc27749a 100644 --- a/src/main/java/de/pixart/messenger/utils/SocksSocketFactory.java +++ b/src/main/java/de/pixart/messenger/utils/SocksSocketFactory.java @@ -18,6 +18,9 @@ public class SocksSocketFactory { proxyOs.write(new byte[]{0x05, 0x01, 0x00}); byte[] response = new byte[2]; proxyIs.read(response); + if (response[0] != 0x05 || response[1] != 0x00) { + throw new SocksConnectionException(); + } byte[] dest = destination.getBytes(); ByteBuffer request = ByteBuffer.allocate(7 + dest.length); request.put(new byte[]{0x05, 0x01, 0x00, 0x03}); @@ -32,6 +35,15 @@ public class SocksSocketFactory { } } + public static boolean contains(byte needle, byte[] haystack) { + for(byte hay : haystack) { + if (hay == needle) { + return true; + } + } + return false; + } + public static Socket createSocket(InetSocketAddress address, String destination, int port) throws IOException { Socket socket = new Socket(); try { |