aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-11-30 16:01:48 +0100
committerChristian S <christian@pix-art.de>2015-12-04 20:06:02 +0100
commitcf3f83f308a5e3fb1e8a27323411e6b95681f949 (patch)
treedd5e1596a0ffd7427f2707c35b66d3c1c934195a /src/main/java/eu
parent608c4ef248087f8856b1975a227072300375f8ef (diff)
add error state for unavailable tor network
Diffstat (limited to 'src/main/java/eu')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Account.java6
-rw-r--r--src/main/java/eu/siacs/conversations/utils/SocksSocketFactory.java13
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java8
3 files changed, 14 insertions, 13 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Account.java b/src/main/java/eu/siacs/conversations/entities/Account.java
index 062c0d253..75e6b2a00 100644
--- a/src/main/java/eu/siacs/conversations/entities/Account.java
+++ b/src/main/java/eu/siacs/conversations/entities/Account.java
@@ -83,7 +83,7 @@ public class Account extends AbstractEntity {
REGISTRATION_NOT_SUPPORTED(true),
SECURITY_ERROR(true),
INCOMPATIBLE_SERVER(true),
- DNS_TIMEOUT(true);
+ TOR_NOT_AVAILABLE(true);
private final boolean isError;
@@ -127,8 +127,8 @@ public class Account extends AbstractEntity {
return R.string.account_status_security_error;
case INCOMPATIBLE_SERVER:
return R.string.account_status_incompatible_server;
- case DNS_TIMEOUT:
- return R.string.account_status_dns_timeout;
+ case TOR_NOT_AVAILABLE:
+ return R.string.account_status_tor_unavailable;
default:
return R.string.account_status_unknown;
}
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 {
+
+ }
}
diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
index 388f65722..9ec4d9bbb 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -29,7 +29,6 @@ import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.net.URL;
-import java.nio.ByteBuffer;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.Principal;
@@ -318,8 +317,8 @@ public class XmppConnection implements Runnable {
this.changeStatus(Account.State.UNAUTHORIZED);
} catch (final UnknownHostException | ConnectException e) {
this.changeStatus(Account.State.SERVER_NOT_FOUND);
- } catch (final DnsTimeoutException e) {
- this.changeStatus(Account.State.DNS_TIMEOUT);
+ } catch (final SocksSocketFactory.SocksProxyNotFoundException e) {
+ this.changeStatus(Account.State.TOR_NOT_AVAILABLE);
} catch (final IOException | XmlPullParserException | NoSuchAlgorithmException e) {
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": " + e.getMessage());
this.changeStatus(Account.State.OFFLINE);
@@ -1327,9 +1326,6 @@ public class XmppConnection implements Runnable {
}
- private class DnsTimeoutException extends IOException {
-
- }
public enum Identity {
FACEBOOK,
SLACK,