mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
Add remote config to split libsignal-net support for standard vs proxied.
This commit is contained in:
committed by
Cody Henthorne
parent
95ff2886cd
commit
303174c864
@@ -316,6 +316,23 @@ public class ApplicationDependencyProvider implements AppDependencies.Provider {
|
||||
return new PendingRetryReceiptCache();
|
||||
}
|
||||
|
||||
private boolean shouldUseLibsignalForWebsocket(@NonNull SignalServiceConfiguration signalServiceConfiguration) {
|
||||
if (RemoteConfig.libSignalWebSocketEnabled()) {
|
||||
if (RemoteConfig.libSignalWebSocketEnabledForProxies()) {
|
||||
return true;
|
||||
} else {
|
||||
// libsignalWebSocketEnabled = true but libsignalWebSocketEnabledForProxies = false
|
||||
if (signalServiceConfiguration.getCensored() ||
|
||||
signalServiceConfiguration.getSignalProxy().isPresent()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public @NonNull SignalWebSocket.AuthenticatedWebSocket provideAuthWebSocket(@NonNull Supplier<SignalServiceConfiguration> signalServiceConfigurationSupplier, @NonNull Supplier<Network> libSignalNetworkSupplier) {
|
||||
SleepTimer sleepTimer = !SignalStore.account().isFcmEnabled() || SignalStore.internal().isWebsocketModeForced() ? new AlarmSleepTimer(context) : new UptimeSleepTimer();
|
||||
@@ -328,7 +345,7 @@ public class ApplicationDependencyProvider implements AppDependencies.Provider {
|
||||
throw new WebSocketUnavailableException("Invalid auth credentials");
|
||||
}
|
||||
|
||||
if (RemoteConfig.libSignalWebSocketEnabled()) {
|
||||
if (shouldUseLibsignalForWebsocket(signalServiceConfigurationSupplier.get())) {
|
||||
Network network = libSignalNetworkSupplier.get();
|
||||
return new LibSignalChatConnection("libsignal-auth",
|
||||
network,
|
||||
@@ -364,7 +381,7 @@ public class ApplicationDependencyProvider implements AppDependencies.Provider {
|
||||
SignalWebSocketHealthMonitor healthMonitor = new SignalWebSocketHealthMonitor(sleepTimer);
|
||||
|
||||
WebSocketFactory unauthFactory = () -> {
|
||||
if (RemoteConfig.libSignalWebSocketEnabled()) {
|
||||
if (shouldUseLibsignalForWebsocket(signalServiceConfigurationSupplier.get())) {
|
||||
Network network = libSignalNetworkSupplier.get();
|
||||
return new LibSignalChatConnection("libsignal-unauth",
|
||||
network,
|
||||
|
||||
@@ -1023,11 +1023,23 @@ object RemoteConfig {
|
||||
value.asLong(8.kibiBytes.inWholeBytes).bytes
|
||||
}
|
||||
|
||||
/** Whether unauthenticated chat web socket is backed by libsignal-net */
|
||||
/** Whether the chat web socket is backed by libsignal for direct connections */
|
||||
@JvmStatic
|
||||
@get:JvmName("libSignalWebSocketEnabled")
|
||||
val libSignalWebSocketEnabled: Boolean by remoteValue(
|
||||
key = "android.libsignalWebSocketEnabled.7",
|
||||
key = "android.libsignalWebSocketEnabled.8",
|
||||
hotSwappable = false
|
||||
) { value ->
|
||||
value.asBoolean(false) || Environment.IS_NIGHTLY
|
||||
}
|
||||
|
||||
/** Whether the chat web socket is backed by libsignal for all connections, including proxied connections.
|
||||
* Note, this does *not* gate HTTP proxies, which are treated as direct connections.
|
||||
* This only has an effect if libSignalWebSocketEnabled is also enabled. */
|
||||
@JvmStatic
|
||||
@get:JvmName("libSignalWebSocketEnabledForProxies")
|
||||
val libSignalWebSocketEnabledForProxies: Boolean by remoteValue(
|
||||
key = "android.libSignalWebSocketEnabledForProxies.8",
|
||||
hotSwappable = false
|
||||
) { value ->
|
||||
value.asBoolean(false) || Environment.IS_NIGHTLY
|
||||
|
||||
Reference in New Issue
Block a user