added config param to use a random resource at every bind
This commit is contained in:
parent
4013123279
commit
63cd8e5981
|
@ -43,6 +43,8 @@ public final class Config {
|
|||
public static final String MAGIC_CREATE_DOMAIN = "conversations.im";
|
||||
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
|
||||
public static final boolean HIDE_MESSAGE_TEXT_IN_NOTIFICATION = false;
|
||||
|
|
|
@ -102,7 +102,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) {
|
||||
|
|
|
@ -1070,7 +1070,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) {
|
||||
|
@ -1370,7 +1371,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) {
|
||||
|
|
Loading…
Reference in New Issue