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

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

@ -37,7 +37,7 @@ typedef NS_ENUM(NSInteger, TSWhisperMessageType) {
//#define contactDiscoveryURL @"https://api.directory.signal.org" //#define contactDiscoveryURL @"https://api.directory.signal.org"
//// TODO: The production value is not yet known. //// TODO: The production value is not yet known.
//#define kUDTrustRoot @"BbqY1DzohE4NUZoVF+L18oUPrK3kILllLEJh2UnPSsEx" //#define kUDTrustRoot @"BbqY1DzohE4NUZoVF+L18oUPrK3kILllLEJh2UnPSsEx"
////#define UD_ENABLED //#define USING_PRODUCTION_SERVICE
//#else //#else
@ -49,10 +49,11 @@ typedef NS_ENUM(NSInteger, TSWhisperMessageType) {
#define textSecureCDNReflectorHost @"meek-signal-cdn-staging.appspot.com"; #define textSecureCDNReflectorHost @"meek-signal-cdn-staging.appspot.com";
#define contactDiscoveryURL @"https://api-staging.directory.signal.org" #define contactDiscoveryURL @"https://api-staging.directory.signal.org"
#define kUDTrustRoot @"BbqY1DzohE4NUZoVF+L18oUPrK3kILllLEJh2UnPSsEx" #define kUDTrustRoot @"BbqY1DzohE4NUZoVF+L18oUPrK3kILllLEJh2UnPSsEx"
#define UD_ENABLED
//#endif //#endif
BOOL IsUsingProductionService(void);
#define textSecureAccountsAPI @"v1/accounts" #define textSecureAccountsAPI @"v1/accounts"
#define textSecureAttributesAPI @"/attributes/" #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; static const NSUInteger ddLogLevel = DDLogLevelInfo;
#endif #endif
#import "OWSAnalytics.h" #import "OWSAnalytics.h"
#import "SSKAsserts.h"
#import "TSConstants.h"
#import <SignalCoreKit/NSObject+OWS.h> #import <SignalCoreKit/NSObject+OWS.h>
#import <SignalCoreKit/OWSAsserts.h> #import <SignalCoreKit/OWSAsserts.h>
#import "SSKAsserts.h"

Loading…
Cancel
Save