1
0
Fork 1

Add option to prefer IPv6

This commit is contained in:
Arne 2025-01-02 17:45:26 +01:00
parent d39b72513b
commit f2825612c3
8 changed files with 38 additions and 7 deletions

View file

@ -150,8 +150,8 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 23 minSdkVersion 23
targetSdkVersion 34 targetSdkVersion 34
versionCode 180 versionCode 181
versionName "2.0.3" versionName "2.0.4"
applicationId "de.monocles.chat" applicationId "de.monocles.chat"
def appName = "monocles chat" def appName = "monocles chat"
resValue "string", "app_name", appName resValue "string", "app_name", appName

View file

@ -52,6 +52,7 @@ public class AppSettings {
private static final String ACCEPT_INVITES_FROM_STRANGERS = "accept_invites_from_strangers"; private static final String ACCEPT_INVITES_FROM_STRANGERS = "accept_invites_from_strangers";
private static final String INSTALLATION_ID = "im.conversations.android.install_id"; private static final String INSTALLATION_ID = "im.conversations.android.install_id";
public static final String SECURE_TLS = "secure_tls"; public static final String SECURE_TLS = "secure_tls";
public static final String PREFER_IPV6 = "prefer_ipv6";
private final Context context; private final Context context;
@ -128,6 +129,10 @@ public class AppSettings {
return getBooleanPreference(SECURE_TLS, R.bool.secure_tls); return getBooleanPreference(SECURE_TLS, R.bool.secure_tls);
} }
public boolean preferIPv6() {
return getBooleanPreference(PREFER_IPV6, R.bool.prefer_ipv6);
}
public boolean isCallIntegration() { public boolean isCallIntegration() {
return getBooleanPreference(CALL_INTEGRATION, R.bool.call_integration); return getBooleanPreference(CALL_INTEGRATION, R.bool.call_integration);
} }

View file

@ -88,7 +88,7 @@ public class ConnectionSettingsFragment extends XmppPreferenceFragment {
reconnectAccounts(); reconnectAccounts();
requireService().reinitializeMuclumbusService(); requireService().reinitializeMuclumbusService();
} }
case AppSettings.SHOW_CONNECTION_OPTIONS -> { case AppSettings.SHOW_CONNECTION_OPTIONS, AppSettings.PREFER_IPV6 -> {
reconnectAccounts(); reconnectAccounts();
} }
} }

View file

@ -20,6 +20,7 @@ import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.MoreExecutors;
import eu.siacs.conversations.AppSettings;
import eu.siacs.conversations.Config; import eu.siacs.conversations.Config;
import eu.siacs.conversations.Conversations; import eu.siacs.conversations.Conversations;
import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.Jid;
@ -38,6 +39,7 @@ import org.minidns.record.SRV;
import java.io.IOException; import java.io.IOException;
import java.net.Inet4Address; import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.ArrayList; import java.util.ArrayList;
@ -86,11 +88,21 @@ public class Resolver {
if (left.ip == null && right.ip == null) { if (left.ip == null && right.ip == null) {
return 0; return 0;
} else if (left.ip != null && right.ip != null) { } else if (left.ip != null && right.ip != null) {
if (left.ip instanceof Inet4Address final var appSettings = new AppSettings(Conversations.getContext());
&& right.ip instanceof Inet4Address) { if (appSettings.preferIPv6()) {
return 0; if (left.ip instanceof Inet6Address
&& right.ip instanceof Inet6Address) {
return 0;
} else {
return left.ip instanceof Inet6Address ? -1 : 1;
}
} else { } else {
return left.ip instanceof Inet4Address ? -1 : 1; if (left.ip instanceof Inet4Address
&& right.ip instanceof Inet4Address) {
return 0;
} else {
return left.ip instanceof Inet4Address ? -1 : 1;
}
} }
} else { } else {
return left.ip != null ? -1 : 1; return left.ip != null ? -1 : 1;

View file

@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="?colorControlNormal" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">
<path android:fillColor="@android:color/white" android:pathData="M480,680Q407,680 352.5,634.5Q298,589 284,520L120,520Q103,520 91.5,508.5Q80,497 80,480Q80,463 91.5,451.5Q103,440 120,440L284,440Q298,371 352.5,325.5Q407,280 480,280Q553,280 607.5,325.5Q662,371 676,440L840,440Q857,440 868.5,451.5Q880,463 880,480Q880,497 868.5,508.5Q857,520 840,520L676,520Q662,589 607.5,634.5Q553,680 480,680ZM480,600Q530,600 565,565Q600,530 600,480Q600,430 565,395Q530,360 480,360Q430,360 395,395Q360,430 360,480Q360,530 395,565Q430,600 480,600Z"/>
</vector>

View file

@ -12,4 +12,5 @@
<bool name="showtextformatting">false</bool> <bool name="showtextformatting">false</bool>
<bool name="app_lock_enabled">false</bool> <bool name="app_lock_enabled">false</bool>
<bool name="secure_tls">false</bool> <bool name="secure_tls">false</bool>
<bool name="prefer_ipv6">false</bool>
</resources> </resources>

View file

@ -1404,4 +1404,6 @@
<string name="pref_hide_media_summary">Hide received and sent media from system gallery views</string> <string name="pref_hide_media_summary">Hide received and sent media from system gallery views</string>
<string name="pref_secure_tls_summary">Use only securest TLS ciphers including post quantum key agreement if available on server</string> <string name="pref_secure_tls_summary">Use only securest TLS ciphers including post quantum key agreement if available on server</string>
<string name="pref_secure_tls">Use secure TLS Ciphers only</string> <string name="pref_secure_tls">Use secure TLS Ciphers only</string>
<string name="pref_prefer_ipv6_summary">Prefers IPv6 when connecting</string>
<string name="pref_prefer_ipv6">Prefer IPv6</string>
</resources> </resources>

View file

@ -14,6 +14,12 @@
android:key="use_tor" android:key="use_tor"
android:summary="@string/pref_use_tor_summary" android:summary="@string/pref_use_tor_summary"
android:title="@string/pref_use_tor" /> android:title="@string/pref_use_tor" />
<SwitchPreferenceCompat
android:defaultValue="@bool/prefer_ipv6"
android:icon="@drawable/rounded_commit_24"
android:key="prefer_ipv6"
android:summary="@string/pref_prefer_ipv6_summary"
android:title="@string/pref_prefer_ipv6" />
<EditTextPreference <EditTextPreference
android:defaultValue="@string/default_dns_server_ipv4" android:defaultValue="@string/default_dns_server_ipv4"
android:icon="@drawable/outline_dns_24" android:icon="@drawable/outline_dns_24"