aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/de/pixart/messenger/Config.java2
-rw-r--r--src/main/java/de/pixart/messenger/utils/CryptoHelper.java2
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/XmppConnection.java5
3 files changed, 6 insertions, 3 deletions
diff --git a/src/main/java/de/pixart/messenger/Config.java b/src/main/java/de/pixart/messenger/Config.java
index 67577be03..dca2c3728 100644
--- a/src/main/java/de/pixart/messenger/Config.java
+++ b/src/main/java/de/pixart/messenger/Config.java
@@ -50,6 +50,8 @@ public final class Config {
public static final boolean SINGLE_ACCOUNT = true; //set to true to allow only one account
public static final boolean DISALLOW_REGISTRATION_IN_UI = false; //hide the register checkbox
+ public static final boolean USE_RANDOM_RESOURCE_ON_EVERY_BIND = false;
+
public static final boolean ALLOW_NON_TLS_CONNECTIONS = false; //very dangerous. you should have a good reason to set this to true
public static final boolean FORCE_ORBOT = false; // always use TOR
diff --git a/src/main/java/de/pixart/messenger/utils/CryptoHelper.java b/src/main/java/de/pixart/messenger/utils/CryptoHelper.java
index f9abe8c90..c203aa930 100644
--- a/src/main/java/de/pixart/messenger/utils/CryptoHelper.java
+++ b/src/main/java/de/pixart/messenger/utils/CryptoHelper.java
@@ -101,7 +101,7 @@ public final class CryptoHelper {
public static String random(int length, SecureRandom random) {
final byte[] bytes = new byte[length];
random.nextBytes(bytes);
- return Base64.encodeToString(bytes, Base64.NO_PADDING | Base64.NO_WRAP);
+ return Base64.encodeToString(bytes, Base64.NO_PADDING | Base64.NO_WRAP | Base64.URL_SAFE);
}
public static String prettifyFingerprint(String fingerprint) {
diff --git a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
index a64175cb3..6bd4904bf 100644
--- a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
+++ b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
@@ -1100,7 +1100,8 @@ public class XmppConnection implements Runnable {
}
clearIqCallbacks();
final IqPacket iq = new IqPacket(IqPacket.TYPE.SET);
- iq.addChild("bind", Namespace.BIND).addChild("resource").setContent(account.getResource());
+ final String resource = Config.USE_RANDOM_RESOURCE_ON_EVERY_BIND ? nextRandomId() : account.getResource();
+ iq.addChild("bind", Namespace.BIND).addChild("resource").setContent(resource);
this.sendUnmodifiedIqPacket(iq, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(final Account account, final IqPacket packet) {
@@ -1400,7 +1401,7 @@ public class XmppConnection implements Runnable {
}
private String nextRandomId() {
- return CryptoHelper.random(50,mXmppConnectionService.getRNG());
+ return CryptoHelper.random(10, mXmppConnectionService.getRNG());
}
public String sendIqPacket(final IqPacket packet, final OnIqPacketReceived callback) {