kopia lustrzana https://github.com/ryukoposting/Signal-Android
Improve network reliability.
rodzic
f0b3aa66f7
commit
5bc44fa586
|
@ -132,8 +132,7 @@ public class BackgroundMessageRetriever {
|
|||
* care of it.
|
||||
*/
|
||||
public static boolean shouldIgnoreFetch() {
|
||||
return ApplicationDependencies.getAppForegroundObserver().isForegrounded() &&
|
||||
ApplicationDependencies.getSignalServiceNetworkAccess().supportsWebsockets();
|
||||
return ApplicationDependencies.getAppForegroundObserver().isForegrounded();
|
||||
}
|
||||
|
||||
private static String logSuffix(long startTime) {
|
||||
|
|
|
@ -132,7 +132,7 @@ public class IncomingMessageObserver {
|
|||
}
|
||||
|
||||
public boolean isDecryptionDrained() {
|
||||
return decryptionDrained || !networkAccess.supportsWebsockets();
|
||||
return decryptionDrained;
|
||||
}
|
||||
|
||||
public void notifyDecryptionsDrained() {
|
||||
|
@ -174,13 +174,12 @@ public class IncomingMessageObserver {
|
|||
Log.d(TAG, "Removed old keep web socket open requests.");
|
||||
}
|
||||
|
||||
Log.d(TAG, String.format("Network: %s, Foreground: %s, FCM: %s, Stay open requests: [%s], Censored: %s, Supports websockets: %s, Registered: %s, Proxy: %s, Force websocket: %s",
|
||||
hasNetwork, appVisible, fcmEnabled, Util.join(keepAliveTokens.entrySet(), ","), networkAccess.isCensored(), networkAccess.supportsWebsockets(), registered, hasProxy, forceWebsocket));
|
||||
Log.d(TAG, String.format("Network: %s, Foreground: %s, FCM: %s, Stay open requests: [%s], Censored: %s, Registered: %s, Proxy: %s, Force websocket: %s",
|
||||
hasNetwork, appVisible, fcmEnabled, Util.join(keepAliveTokens.entrySet(), ","), networkAccess.isCensored(), registered, hasProxy, forceWebsocket));
|
||||
|
||||
return registered &&
|
||||
(appVisible || !fcmEnabled || forceWebsocket || Util.hasItems(keepAliveTokens)) &&
|
||||
hasNetwork &&
|
||||
networkAccess.supportsWebsockets();
|
||||
hasNetwork;
|
||||
}
|
||||
|
||||
private synchronized void waitForConnectionNecessary() {
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.thoughtcrime.securesms.util.Base64
|
|||
import org.whispersystems.signalservice.api.push.TrustStore
|
||||
import org.whispersystems.signalservice.internal.configuration.SignalCdnUrl
|
||||
import org.whispersystems.signalservice.internal.configuration.SignalCdsiUrl
|
||||
import org.whispersystems.signalservice.internal.configuration.SignalContactDiscoveryUrl
|
||||
import org.whispersystems.signalservice.internal.configuration.SignalKeyBackupServiceUrl
|
||||
import org.whispersystems.signalservice.internal.configuration.SignalServiceConfiguration
|
||||
import org.whispersystems.signalservice.internal.configuration.SignalServiceUrl
|
||||
|
@ -70,11 +69,11 @@ open class SignalServiceNetworkAccess(context: Context) {
|
|||
private const val COUNTRY_CODE_UKRAINE = 380
|
||||
|
||||
private const val G_HOST = "reflector-nrgwuv7kwq-uc.a.run.app"
|
||||
private const val F_SERVICE_HOST = "textsecure-service.whispersystems.org.global.prod.fastly.net"
|
||||
private const val F_SERVICE_HOST = "chat-signal.global.ssl.fastly.net"
|
||||
private const val F_STORAGE_HOST = "storage.signal.org.global.prod.fastly.net"
|
||||
private const val F_CDN_HOST = "cdn.signal.org.global.prod.fastly.net"
|
||||
private const val F_CDN2_HOST = "cdn2.signal.org.global.prod.fastly.net"
|
||||
private const val F_DIRECTORY_HOST = "api.directory.signal.org.global.prod.fastly.net"
|
||||
private const val F_CDSI_HOST = "cdsi-signal.global.ssl.fastly.net"
|
||||
private const val F_KBS_HOST = "api.backup.signal.org.global.prod.fastly.net"
|
||||
|
||||
private val GMAPS_CONNECTION_SPEC = ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
|
||||
|
@ -166,15 +165,13 @@ open class SignalServiceNetworkAccess(context: Context) {
|
|||
0 to fUrls.map { SignalCdnUrl(it, F_CDN_HOST, fTrustStore, APP_CONNECTION_SPEC) }.toTypedArray(),
|
||||
2 to fUrls.map { SignalCdnUrl(it, F_CDN2_HOST, fTrustStore, APP_CONNECTION_SPEC) }.toTypedArray(),
|
||||
),
|
||||
fUrls.map { SignalContactDiscoveryUrl(it, F_DIRECTORY_HOST, fTrustStore, APP_CONNECTION_SPEC) }.toTypedArray(),
|
||||
fUrls.map { SignalKeyBackupServiceUrl(it, F_KBS_HOST, fTrustStore, APP_CONNECTION_SPEC) }.toTypedArray(),
|
||||
fUrls.map { SignalStorageUrl(it, F_STORAGE_HOST, fTrustStore, APP_CONNECTION_SPEC) }.toTypedArray(),
|
||||
arrayOf(SignalCdsiUrl(BuildConfig.SIGNAL_CDSI_URL, serviceTrustStore)),
|
||||
fUrls.map { SignalCdsiUrl(it, F_CDSI_HOST, fTrustStore, APP_CONNECTION_SPEC) }.toTypedArray(),
|
||||
interceptors,
|
||||
Optional.of(DNS),
|
||||
Optional.empty(),
|
||||
zkGroupServerPublicParams,
|
||||
false
|
||||
)
|
||||
|
||||
private val censorshipConfiguration: Map<Int, SignalServiceConfiguration> = mapOf(
|
||||
|
@ -218,7 +215,6 @@ open class SignalServiceNetworkAccess(context: Context) {
|
|||
0 to arrayOf(SignalCdnUrl(BuildConfig.SIGNAL_CDN_URL, serviceTrustStore)),
|
||||
2 to arrayOf(SignalCdnUrl(BuildConfig.SIGNAL_CDN2_URL, serviceTrustStore))
|
||||
),
|
||||
arrayOf(SignalContactDiscoveryUrl(BuildConfig.SIGNAL_CONTACT_DISCOVERY_URL, serviceTrustStore)),
|
||||
arrayOf(SignalKeyBackupServiceUrl(BuildConfig.SIGNAL_KEY_BACKUP_URL, serviceTrustStore)),
|
||||
arrayOf(SignalStorageUrl(BuildConfig.STORAGE_URL, serviceTrustStore)),
|
||||
arrayOf(SignalCdsiUrl(BuildConfig.SIGNAL_CDSI_URL, serviceTrustStore)),
|
||||
|
@ -226,7 +222,6 @@ open class SignalServiceNetworkAccess(context: Context) {
|
|||
Optional.of(DNS),
|
||||
if (SignalStore.proxy().isProxyEnabled) Optional.ofNullable(SignalStore.proxy().proxy) else Optional.empty(),
|
||||
zkGroupServerPublicParams,
|
||||
true
|
||||
)
|
||||
|
||||
open fun getConfiguration(): SignalServiceConfiguration {
|
||||
|
@ -269,17 +264,12 @@ open class SignalServiceNetworkAccess(context: Context) {
|
|||
return defaultCensoredCountryCodes.contains(countryCode)
|
||||
}
|
||||
|
||||
fun supportsWebsockets(): Boolean {
|
||||
return !isCensored() || getConfiguration().supportsWebSockets()
|
||||
}
|
||||
|
||||
private fun buildGConfiguration(
|
||||
hostConfigs: List<HostConfig>
|
||||
): SignalServiceConfiguration {
|
||||
val serviceUrls: Array<SignalServiceUrl> = hostConfigs.map { SignalServiceUrl("${it.baseUrl}/service", it.host, gTrustStore, it.connectionSpec) }.toTypedArray()
|
||||
val cdnUrls: Array<SignalCdnUrl> = hostConfigs.map { SignalCdnUrl("${it.baseUrl}/cdn", it.host, gTrustStore, it.connectionSpec) }.toTypedArray()
|
||||
val cdn2Urls: Array<SignalCdnUrl> = hostConfigs.map { SignalCdnUrl("${it.baseUrl}/cdn2", it.host, gTrustStore, it.connectionSpec) }.toTypedArray()
|
||||
val cdsUrls: Array<SignalContactDiscoveryUrl> = hostConfigs.map { SignalContactDiscoveryUrl("${it.baseUrl}/directory", it.host, gTrustStore, it.connectionSpec) }.toTypedArray()
|
||||
val kbsUrls: Array<SignalKeyBackupServiceUrl> = hostConfigs.map { SignalKeyBackupServiceUrl("${it.baseUrl}/backup", it.host, gTrustStore, it.connectionSpec) }.toTypedArray()
|
||||
val storageUrls: Array<SignalStorageUrl> = hostConfigs.map { SignalStorageUrl("${it.baseUrl}/storage", it.host, gTrustStore, it.connectionSpec) }.toTypedArray()
|
||||
val cdsiUrls: Array<SignalCdsiUrl> = hostConfigs.map { SignalCdsiUrl("${it.baseUrl}/cdsi", it.host, gTrustStore, it.connectionSpec) }.toTypedArray()
|
||||
|
@ -290,7 +280,6 @@ open class SignalServiceNetworkAccess(context: Context) {
|
|||
0 to cdnUrls,
|
||||
2 to cdn2Urls
|
||||
),
|
||||
cdsUrls,
|
||||
kbsUrls,
|
||||
storageUrls,
|
||||
cdsiUrls,
|
||||
|
@ -298,7 +287,6 @@ open class SignalServiceNetworkAccess(context: Context) {
|
|||
Optional.of(DNS),
|
||||
Optional.empty(),
|
||||
zkGroupServerPublicParams,
|
||||
true
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -475,50 +475,6 @@ public class SignalServiceAccountManager {
|
|||
}
|
||||
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
public Map<String, ACI> getRegisteredUsers(KeyStore iasKeyStore, Set<String> e164numbers, String mrenclave)
|
||||
throws IOException, Quote.InvalidQuoteFormatException, UnauthenticatedQuoteException, SignatureException, UnauthenticatedResponseException, InvalidKeyException
|
||||
{
|
||||
if (e164numbers.isEmpty()) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
try {
|
||||
String authorization = this.pushServiceSocket.getContactDiscoveryAuthorization();
|
||||
Map<String, RemoteAttestation> attestations = RemoteAttestationUtil.getAndVerifyMultiRemoteAttestation(pushServiceSocket,
|
||||
PushServiceSocket.ClientSet.ContactDiscovery,
|
||||
iasKeyStore,
|
||||
mrenclave,
|
||||
mrenclave,
|
||||
authorization);
|
||||
|
||||
List<String> addressBook = new ArrayList<>(e164numbers.size());
|
||||
|
||||
for (String e164number : e164numbers) {
|
||||
addressBook.add(e164number.substring(1));
|
||||
}
|
||||
|
||||
List<String> cookies = attestations.values().iterator().next().getCookies();
|
||||
DiscoveryRequest request = ContactDiscoveryCipher.createDiscoveryRequest(addressBook, attestations);
|
||||
DiscoveryResponse response = this.pushServiceSocket.getContactDiscoveryRegisteredUsers(authorization, request, cookies, mrenclave);
|
||||
byte[] data = ContactDiscoveryCipher.getDiscoveryResponseData(response, attestations.values());
|
||||
|
||||
HashMap<String, ACI> results = new HashMap<>(addressBook.size());
|
||||
DataInputStream uuidInputStream = new DataInputStream(new ByteArrayInputStream(data));
|
||||
|
||||
for (String candidate : addressBook) {
|
||||
long candidateUuidHigh = uuidInputStream.readLong();
|
||||
long candidateUuidLow = uuidInputStream.readLong();
|
||||
if (candidateUuidHigh != 0 || candidateUuidLow != 0) {
|
||||
results.put('+' + candidate, ACI.from(new UUID(candidateUuidHigh, candidateUuidLow)));
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
} catch (InvalidCiphertextException e) {
|
||||
throw new UnauthenticatedResponseException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public CdsiV2Service.Response getRegisteredUsersWithCdsi(Set<String> previousE164s,
|
||||
Set<String> newE164s,
|
||||
Map<ServiceId, ProfileKey> serviceIds,
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
package org.whispersystems.signalservice.internal.configuration;
|
||||
|
||||
|
||||
import org.whispersystems.signalservice.api.push.TrustStore;
|
||||
|
||||
import okhttp3.ConnectionSpec;
|
||||
|
||||
public class SignalContactDiscoveryUrl extends SignalUrl {
|
||||
|
||||
public SignalContactDiscoveryUrl(String url, TrustStore trustStore) {
|
||||
super(url, trustStore);
|
||||
}
|
||||
|
||||
public SignalContactDiscoveryUrl(String url, String hostHeader, TrustStore trustStore, ConnectionSpec connectionSpec) {
|
||||
super(url, hostHeader, trustStore, connectionSpec);
|
||||
}
|
||||
}
|
|
@ -13,7 +13,6 @@ public final class SignalServiceConfiguration {
|
|||
|
||||
private final SignalServiceUrl[] signalServiceUrls;
|
||||
private final Map<Integer, SignalCdnUrl[]> signalCdnUrlMap;
|
||||
private final SignalContactDiscoveryUrl[] signalContactDiscoveryUrls;
|
||||
private final SignalCdsiUrl[] signalCdsiUrls;
|
||||
private final SignalKeyBackupServiceUrl[] signalKeyBackupServiceUrls;
|
||||
private final SignalStorageUrl[] signalStorageUrls;
|
||||
|
@ -21,23 +20,19 @@ public final class SignalServiceConfiguration {
|
|||
private final Optional<Dns> dns;
|
||||
private final Optional<SignalProxy> proxy;
|
||||
private final byte[] zkGroupServerPublicParams;
|
||||
private final boolean supportsWebSocket;
|
||||
|
||||
public SignalServiceConfiguration(SignalServiceUrl[] signalServiceUrls,
|
||||
Map<Integer, SignalCdnUrl[]> signalCdnUrlMap,
|
||||
SignalContactDiscoveryUrl[] signalContactDiscoveryUrls,
|
||||
SignalKeyBackupServiceUrl[] signalKeyBackupServiceUrls,
|
||||
SignalStorageUrl[] signalStorageUrls,
|
||||
SignalCdsiUrl[] signalCdsiUrls,
|
||||
List<Interceptor> networkInterceptors,
|
||||
Optional<Dns> dns,
|
||||
Optional<SignalProxy> proxy,
|
||||
byte[] zkGroupServerPublicParams,
|
||||
boolean supportsWebSocket)
|
||||
byte[] zkGroupServerPublicParams)
|
||||
{
|
||||
this.signalServiceUrls = signalServiceUrls;
|
||||
this.signalCdnUrlMap = signalCdnUrlMap;
|
||||
this.signalContactDiscoveryUrls = signalContactDiscoveryUrls;
|
||||
this.signalCdsiUrls = signalCdsiUrls;
|
||||
this.signalKeyBackupServiceUrls = signalKeyBackupServiceUrls;
|
||||
this.signalStorageUrls = signalStorageUrls;
|
||||
|
@ -45,7 +40,6 @@ public final class SignalServiceConfiguration {
|
|||
this.dns = dns;
|
||||
this.proxy = proxy;
|
||||
this.zkGroupServerPublicParams = zkGroupServerPublicParams;
|
||||
this.supportsWebSocket = supportsWebSocket;
|
||||
}
|
||||
|
||||
public SignalServiceUrl[] getSignalServiceUrls() {
|
||||
|
@ -56,10 +50,6 @@ public final class SignalServiceConfiguration {
|
|||
return signalCdnUrlMap;
|
||||
}
|
||||
|
||||
public SignalContactDiscoveryUrl[] getSignalContactDiscoveryUrls() {
|
||||
return signalContactDiscoveryUrls;
|
||||
}
|
||||
|
||||
public SignalCdsiUrl[] getSignalCdsiUrls() {
|
||||
return signalCdsiUrls;
|
||||
}
|
||||
|
@ -87,8 +77,4 @@ public final class SignalServiceConfiguration {
|
|||
public Optional<SignalProxy> getSignalProxy() {
|
||||
return proxy;
|
||||
}
|
||||
|
||||
public boolean supportsWebSockets() {
|
||||
return supportsWebSocket;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -292,7 +292,6 @@ public class PushServiceSocket {
|
|||
|
||||
private final ServiceConnectionHolder[] serviceClients;
|
||||
private final Map<Integer, ConnectionHolder[]> cdnClientsMap;
|
||||
private final ConnectionHolder[] contactDiscoveryClients;
|
||||
private final ConnectionHolder[] keyBackupServiceClients;
|
||||
private final ConnectionHolder[] storageClients;
|
||||
|
||||
|
@ -313,7 +312,6 @@ public class PushServiceSocket {
|
|||
this.automaticNetworkRetry = automaticNetworkRetry;
|
||||
this.serviceClients = createServiceConnectionHolders(configuration.getSignalServiceUrls(), configuration.getNetworkInterceptors(), configuration.getDns(), configuration.getSignalProxy());
|
||||
this.cdnClientsMap = createCdnClientsMap(configuration.getSignalCdnUrlMap(), configuration.getNetworkInterceptors(), configuration.getDns(), configuration.getSignalProxy());
|
||||
this.contactDiscoveryClients = createConnectionHolders(configuration.getSignalContactDiscoveryUrls(), configuration.getNetworkInterceptors(), configuration.getDns(), configuration.getSignalProxy());
|
||||
this.keyBackupServiceClients = createConnectionHolders(configuration.getSignalKeyBackupServiceUrls(), configuration.getNetworkInterceptors(), configuration.getDns(), configuration.getSignalProxy());
|
||||
this.storageClients = createConnectionHolders(configuration.getSignalStorageUrls(), configuration.getNetworkInterceptors(), configuration.getDns(), configuration.getSignalProxy());
|
||||
this.random = new SecureRandom();
|
||||
|
@ -1155,14 +1153,6 @@ public class PushServiceSocket {
|
|||
}
|
||||
}
|
||||
|
||||
public DiscoveryResponse getContactDiscoveryRegisteredUsers(String authorizationToken, DiscoveryRequest request, List<String> cookies, String mrenclave)
|
||||
throws IOException
|
||||
{
|
||||
try (Response response = makeRequest(ClientSet.ContactDiscovery, authorizationToken, cookies, "/v1/discovery/" + mrenclave, "PUT", JsonUtil.toJson(request))) {
|
||||
return readBodyJson(response, DiscoveryResponse.class);
|
||||
}
|
||||
}
|
||||
|
||||
public KeyBackupResponse putKbsData(String authorizationToken, KeyBackupRequest request, List<String> cookies, String mrenclave)
|
||||
throws IOException
|
||||
{
|
||||
|
@ -1842,8 +1832,6 @@ public class PushServiceSocket {
|
|||
|
||||
private ConnectionHolder[] clientsFor(ClientSet clientSet) {
|
||||
switch (clientSet) {
|
||||
case ContactDiscovery:
|
||||
return contactDiscoveryClients;
|
||||
case KeyBackup:
|
||||
return keyBackupServiceClients;
|
||||
default:
|
||||
|
@ -2319,7 +2307,7 @@ public class PushServiceSocket {
|
|||
public void handle(int responseCode, ResponseBody body) { }
|
||||
}
|
||||
|
||||
public enum ClientSet { ContactDiscovery, KeyBackup }
|
||||
public enum ClientSet { KeyBackup }
|
||||
|
||||
public CredentialResponse retrieveGroupsV2Credentials(long todaySeconds)
|
||||
throws IOException
|
||||
|
|
Ładowanie…
Reference in New Issue