aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorChristian S <christian@pix-art.de>2016-04-22 21:09:53 +0200
committerChristian S <christian@pix-art.de>2016-04-22 21:09:53 +0200
commit1cf06b36562d6ba114477f9fab9e2bd9725b1997 (patch)
tree9c1b637f5a18af0fa7bec9efaaced0e3d4b752c2 /src/main/java
parent1ecb3befed4f726f9334947306773c20c3cd9afa (diff)
added multiple ports to connect to...
...and choose a random port to connect
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/eu/siacs/conversations/Config.java2
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java11
2 files changed, 8 insertions, 5 deletions
diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java
index a2d232fcc..cb22c61dc 100644
--- a/src/main/java/eu/siacs/conversations/Config.java
+++ b/src/main/java/eu/siacs/conversations/Config.java
@@ -37,7 +37,7 @@ public final class Config {
public static final String LOGTAG = "conversations";
public static final String XMPP_IP = "185.26.156.37"; // set to null means disable
- public static final Integer XMPP_Port = 61000; // set to null means disable
+ public static final Integer[] XMPP_Ports = {61000, 65000}; // set to null means disable
public static final String DOMAIN_LOCK = "pix-art.de"; //only allow account creation for this domain
public static final String MAGIC_CREATE_DOMAIN = "pix-art.de";
diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
index afae7b3a7..602aee53a 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -39,6 +39,7 @@ import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
+import java.util.Random;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
@@ -254,14 +255,16 @@ public class XmppConnection implements Runnable {
this.changeStatus(Account.State.CONNECTING);
final boolean useTor = mXmppConnectionService.useTorToConnect() || account.isOnion();
final boolean extended = mXmppConnectionService.showExtendedConnectionOptions();
- if (Config.XMPP_IP != null && Config.XMPP_Port != null) {
+ if (Config.XMPP_IP != null && Config.XMPP_Ports != null) {
+ Integer[] XMPP_Port = Config.XMPP_Ports;
+ Integer Port = XMPP_Port[new Random().nextInt(XMPP_Port.length)];
socket = new Socket();
try {
- socket.connect(new InetSocketAddress(Config.XMPP_IP, Config.XMPP_Port), Config.SOCKET_TIMEOUT * 1000);
+ socket.connect(new InetSocketAddress(Config.XMPP_IP, Port), Config.SOCKET_TIMEOUT * 1000);
} catch (IOException e) {
- throw new UnknownHostException();
+ throw new IOException();
}
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": connect to " + Config.XMPP_IP + ":" + Config.XMPP_Port);
+ Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": connect to " + Config.XMPP_IP + ":" + Port);
startXmpp();
}
else if (useTor) {