disable omemo by default for *.covid.monal.im domains
This commit is contained in:
parent
d37140ebf0
commit
9a7fc3d9b8
|
@ -3,9 +3,11 @@ package eu.siacs.conversations;
|
|||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import eu.siacs.conversations.crypto.XmppDomainVerifier;
|
||||
import eu.siacs.conversations.xmpp.Jid;
|
||||
import eu.siacs.conversations.xmpp.chatstate.ChatState;
|
||||
|
||||
|
@ -98,7 +100,7 @@ public final class Config {
|
|||
|
||||
//remove *other* omemo devices from *your* device list announcement after not seeing any activity from them for 42 days. They will automatically add themselves after coming back online.
|
||||
public static final long OMEMO_AUTO_EXPIRY = 42 * MILLISECONDS_IN_DAY;
|
||||
|
||||
|
||||
public static final boolean REMOVE_BROKEN_DEVICES = false;
|
||||
public static final boolean OMEMO_PADDING = false;
|
||||
public static final boolean PUT_AUTH_TAG_INTO_KEY = true;
|
||||
|
@ -176,7 +178,14 @@ public final class Config {
|
|||
|
||||
//if the contacts domain matches one of the following domains OMEMO won’t be turned on automatically
|
||||
//can be used for well known, widely used gateways
|
||||
public static final List<String> CONTACT_DOMAINS = Collections.singletonList("cheogram.com");
|
||||
private static final List<String> CONTACT_DOMAINS = Arrays.asList(
|
||||
"cheogram.com",
|
||||
"*.covid.monal.im"
|
||||
);
|
||||
|
||||
public static boolean matchesContactDomain(final String domain) {
|
||||
return XmppDomainVerifier.matchDomain(domain, CONTACT_DOMAINS);
|
||||
}
|
||||
}
|
||||
|
||||
private Config() {
|
||||
|
|
|
@ -71,8 +71,8 @@ public class XmppDomainVerifier implements DomainHostnameVerifier {
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean matchDomain(String needle, List<String> haystack) {
|
||||
for (String entry : haystack) {
|
||||
public static boolean matchDomain(final String needle, final List<String> haystack) {
|
||||
for (final String entry : haystack) {
|
||||
if (entry.startsWith("*.")) {
|
||||
int offset = 0;
|
||||
while (offset < needle.length()) {
|
||||
|
@ -80,16 +80,13 @@ public class XmppDomainVerifier implements DomainHostnameVerifier {
|
|||
if (i < 0) {
|
||||
break;
|
||||
}
|
||||
Log.d(LOGTAG, "comparing " + needle.substring(i) + " and " + entry.substring(1));
|
||||
if (needle.substring(i).equalsIgnoreCase(entry.substring(1))) {
|
||||
Log.d(LOGTAG, "domain " + needle + " matched " + entry);
|
||||
return true;
|
||||
}
|
||||
offset = i + 1;
|
||||
}
|
||||
} else {
|
||||
if (entry.equalsIgnoreCase(needle)) {
|
||||
Log.d(LOGTAG, "domain " + needle + " matched " + entry);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
|||
}
|
||||
final String contact = conversation.getJid().getDomain().toEscapedString();
|
||||
final String account = conversation.getAccount().getServer();
|
||||
if (Config.OMEMO_EXCEPTIONS.CONTACT_DOMAINS.contains(contact) || Config.OMEMO_EXCEPTIONS.ACCOUNT_DOMAINS.contains(account)) {
|
||||
if (Config.OMEMO_EXCEPTIONS.matchesContactDomain(contact) || Config.OMEMO_EXCEPTIONS.ACCOUNT_DOMAINS.contains(account)) {
|
||||
return false;
|
||||
}
|
||||
return conversation.isSingleOrPrivateAndNonAnonymous() || conversation.getBooleanAttribute(ATTRIBUTE_FORMERLY_PRIVATE_NON_ANONYMOUS, false);
|
||||
|
|
Loading…
Reference in New Issue