From 2225b0b6d5586d608b15d4e1ac13faa99b8971bf Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 30 Nov 2015 16:01:48 +0100 Subject: add error state for unavailable tor network --- .../eu/siacs/conversations/utils/SocksSocketFactory.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/main/java/eu/siacs/conversations/utils') diff --git a/src/main/java/eu/siacs/conversations/utils/SocksSocketFactory.java b/src/main/java/eu/siacs/conversations/utils/SocksSocketFactory.java index 6d9340ab0..768e9f17b 100644 --- a/src/main/java/eu/siacs/conversations/utils/SocksSocketFactory.java +++ b/src/main/java/eu/siacs/conversations/utils/SocksSocketFactory.java @@ -1,14 +1,11 @@ package eu.siacs.conversations.utils; -import android.util.Log; - import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Socket; -import java.net.UnknownHostException; import java.nio.ByteBuffer; import eu.siacs.conversations.Config; @@ -37,7 +34,11 @@ public class SocksSocketFactory { public static Socket createSocket(InetSocketAddress address, String destination, int port) throws IOException { Socket socket = new Socket(); - socket.connect(address, Config.CONNECT_TIMEOUT * 1000); + try { + socket.connect(address, Config.CONNECT_TIMEOUT * 1000); + } catch (IOException e) { + throw new SocksProxyNotFoundException(); + } createSocksConnection(socket, destination, port); return socket; } @@ -49,4 +50,8 @@ public class SocksSocketFactory { static class SocksConnectionException extends IOException { } + + public static class SocksProxyNotFoundException extends IOException { + + } } -- cgit v1.2.3