Suppress UD against production service to avoid de-registration.

pull/1/head
Matthew Chen 7 years ago
parent f2a1df4e99
commit 1f37980a0d

@ -26,6 +26,8 @@ public enum UnidentifiedAccessMode: Int {
@objc func trustRoot() -> ECPublicKey
@objc func isUDEnabled() -> Bool
// MARK: - Recipient State
@objc
@ -173,6 +175,9 @@ public class OWSUDManagerImpl: NSObject, OWSUDManager {
// if we have a valid profile key for them.
@objc
public func udAccessKeyForRecipient(_ recipientId: RecipientIdentifier) -> SMKUDAccessKey? {
guard isUDEnabled() else {
return nil
}
let theirAccessMode = unidentifiedAccessMode(recipientId: recipientId)
if theirAccessMode == .unrestricted {
return SMKUDAccessKey(randomKeyData: ())
@ -281,6 +286,11 @@ public class OWSUDManagerImpl: NSObject, OWSUDManager {
}
}
@objc
public func isUDEnabled() -> Bool {
return !IsUsingProductionService()
}
@objc
public func trustRoot() -> ECPublicKey {
guard let trustRootData = NSData(fromBase64String: kUDTrustRoot) else {

@ -264,6 +264,10 @@ NSString *const kNSNotification_OWSWebSocketStateDidChange = @"kNSNotification_O
return OWSWebsocketSecurityPolicy.sharedPolicy;
}
- (id<OWSUDManager>)udManager {
return SSKEnvironment.shared.udManager;
}
#pragma mark -
// We want to observe these notifications lazily to avoid accessing
@ -1024,12 +1028,10 @@ NSString *const kNSNotification_OWSWebSocketStateDidChange = @"kNSNotification_O
}
#endif
#ifndef UD_ENABLED
if (self.webSocketType == OWSWebSocketTypeUD) {
if (!self.udManager.isUDEnabled && self.webSocketType == OWSWebSocketTypeUD) {
OWSLogWarn(@"Suppressing UD socket in prod.");
return;
}
#endif
if (!AppReadiness.isAppReady) {
static dispatch_once_t onceToken;

@ -37,7 +37,7 @@ typedef NS_ENUM(NSInteger, TSWhisperMessageType) {
//#define contactDiscoveryURL @"https://api.directory.signal.org"
//// TODO: The production value is not yet known.
//#define kUDTrustRoot @"BbqY1DzohE4NUZoVF+L18oUPrK3kILllLEJh2UnPSsEx"
////#define UD_ENABLED
//#define USING_PRODUCTION_SERVICE
//#else
@ -49,10 +49,11 @@ typedef NS_ENUM(NSInteger, TSWhisperMessageType) {
#define textSecureCDNReflectorHost @"meek-signal-cdn-staging.appspot.com";
#define contactDiscoveryURL @"https://api-staging.directory.signal.org"
#define kUDTrustRoot @"BbqY1DzohE4NUZoVF+L18oUPrK3kILllLEJh2UnPSsEx"
#define UD_ENABLED
//#endif
BOOL IsUsingProductionService(void);
#define textSecureAccountsAPI @"v1/accounts"
#define textSecureAttributesAPI @"/attributes/"

@ -0,0 +1,14 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "TSConstants.h"
BOOL IsUsingProductionService()
{
#ifdef USING_PRODUCTION_SERVICE
return YES;
#else
return NO;
#endif
}

@ -12,6 +12,7 @@ static const NSUInteger ddLogLevel = DDLogLevelAll;
static const NSUInteger ddLogLevel = DDLogLevelInfo;
#endif
#import "OWSAnalytics.h"
#import "SSKAsserts.h"
#import "TSConstants.h"
#import <SignalCoreKit/NSObject+OWS.h>
#import <SignalCoreKit/OWSAsserts.h>
#import "SSKAsserts.h"

Loading…
Cancel
Save