diff --git a/Signal/Signal-Prefix.pch b/Signal/Signal-Prefix.pch index 87a691f42..f6a7cf97d 100644 --- a/Signal/Signal-Prefix.pch +++ b/Signal/Signal-Prefix.pch @@ -12,7 +12,8 @@ #ifdef DEBUG static const int ddLogLevel = LOG_LEVEL_VERBOSE; #else - static const int ddLogLevel = LOG_LEVEL_WARN; +// As long as we have call initialization issues we'll log a bit more aggressively + static const int ddLogLevel = LOG_LEVEL_VERBOSE; #endif #endif diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index e47399805..6603ca29b 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -108,7 +108,10 @@ } [[[Environment phoneManager] currentCallObservable] watchLatestValue:^(CallState* latestCall) { - if (latestCall == nil) return; + if (latestCall == nil){ + DDLogError(@"Latest Call is nil."); + return; + } InCallViewController *callViewController = [InCallViewController inCallViewControllerWithCallState:latestCall andOptionallyKnownContact:[latestCall potentiallySpecifiedContact]]; diff --git a/Signal/src/async/Future.m b/Signal/src/async/Future.m index aa6b19ba7..0a2d1fa77 100644 --- a/Signal/src/async/Future.m +++ b/Signal/src/async/Future.m @@ -11,6 +11,7 @@ return v; } +(Future*) failed:(id)value { + DDLogVerbose(@"Future failed: %@", value); FutureSource* v = [FutureSource new]; [v trySetFailure:value]; return v; @@ -22,7 +23,6 @@ }]; } - -(void) finallyDo:(void(^)(Future* completed))callback { require(callback != nil); @synchronized(self) { diff --git a/Signal/src/environment/PreferencesUtil.m b/Signal/src/environment/PreferencesUtil.m index a085da03a..1a0ed13fd 100644 --- a/Signal/src/environment/PreferencesUtil.m +++ b/Signal/src/environment/PreferencesUtil.m @@ -83,6 +83,8 @@ return oldValue; } + DDLogInfo(@"A new %@ key of sie %lu has been generated.", key, (unsigned long)length); + return [CryptoTools generateSecureRandomData:length]; }]; } @@ -116,6 +118,7 @@ } -(void) setLocalNumberTo:(PhoneNumber*)localNumber { require(localNumber != nil); + require([localNumber toE164]!= nil); [self setValueForKey:LOCAL_NUMBER_KEY toValue:[localNumber toE164]]; } diff --git a/Signal/src/environment/PropertyListPreferences.m b/Signal/src/environment/PropertyListPreferences.m index 460a1c2c5..735d7429e 100644 --- a/Signal/src/environment/PropertyListPreferences.m +++ b/Signal/src/environment/PropertyListPreferences.m @@ -56,6 +56,7 @@ @synchronized(self) { if (value == nil) { [dictionary removeObjectForKey:key]; + DDLogWarn(@"Removing object for key: %@ ", key); } else { [dictionary setObject:value forKey:key]; } @@ -80,11 +81,14 @@ @synchronized(self) { if (value == nil) { [UICKeyChainStore removeItemForKey:key]; + DDLogWarn(@"Removing object for key: %@", key); } else { if ([value isKindOfClass:[NSData class]]) { [UICKeyChainStore setData:value forKey:key]; } else if ([value isKindOfClass:[NSString class]]){ [UICKeyChainStore setString:value forKey:key]; + } else{ + DDLogError(@"Unexpected class stored in the Keychain."); } } } diff --git a/Signal/src/network/rtp/srtp/SrtpStream.m b/Signal/src/network/rtp/srtp/SrtpStream.m index 58972c0ad..46d4b6a7a 100644 --- a/Signal/src/network/rtp/srtp/SrtpStream.m +++ b/Signal/src/network/rtp/srtp/SrtpStream.m @@ -6,6 +6,7 @@ #define IV_LENGTH 16 @implementation SrtpStream + +(SrtpStream*) srtpStreamWithCipherKey:(NSData*)cipherKey andMacKey:(NSData*)macKey andCipherIvSalt:(NSData*)cipherIvSalt { require(cipherKey != nil); require(macKey != nil); diff --git a/Signal/src/phone/PhoneNumber.m b/Signal/src/phone/PhoneNumber.m index ced994394..fa3bba88c 100644 --- a/Signal/src/phone/PhoneNumber.m +++ b/Signal/src/phone/PhoneNumber.m @@ -44,9 +44,11 @@ static NSString *const RPDefaultsKeyPhoneNumberCanonical = @"RPDefaultsKeyPhoneN +(PhoneNumber*) phoneNumberFromE164:(NSString*)text { require(text != nil); checkOperation([text hasPrefix:COUNTRY_CODE_PREFIX]); + PhoneNumber *number = [PhoneNumber phoneNumberFromText:text + andRegion:@"ZZ"]; - return [PhoneNumber phoneNumberFromText:text - andRegion:@"ZZ"]; + checkOperation(number != nil); + return number; } +(NSString*) bestEffortFormatPartialUserSpecifiedTextToLookLikeAPhoneNumber:(NSString*)input { @@ -84,6 +86,7 @@ static NSString *const RPDefaultsKeyPhoneNumberCanonical = @"RPDefaultsKeyPhoneN @try { return [self phoneNumberFromText:text andRegion:regionCode]; } @catch (OperationFailed* ex) { + DDLogError(@"Error parsing phone number from region code"); return nil; } } diff --git a/Signal/src/phone/signaling/ResponderSessionDescriptor.m b/Signal/src/phone/signaling/ResponderSessionDescriptor.m index de4633f47..047c9e7b1 100644 --- a/Signal/src/phone/signaling/ResponderSessionDescriptor.m +++ b/Signal/src/phone/signaling/ResponderSessionDescriptor.m @@ -91,6 +91,7 @@ NSData* includedMac = [data takeLast:HMAC_TRUNCATED_SIZE]; NSData* payload = [data skipLast:HMAC_TRUNCATED_SIZE]; NSData* signalingMacKey = [[Environment preferences] getOrGenerateSignalingMacKey]; + require(signalingMacKey != nil); NSData* computedMac = [[payload hmacWithSha1WithKey:signalingMacKey] takeLast:HMAC_TRUNCATED_SIZE]; checkOperation([includedMac isEqualToData_TimingSafe:computedMac]); return payload; diff --git a/Signal/src/phone/signaling/SignalUtil.m b/Signal/src/phone/signaling/SignalUtil.m index dd2a39a54..b9b3d0425 100644 --- a/Signal/src/phone/signaling/SignalUtil.m +++ b/Signal/src/phone/signaling/SignalUtil.m @@ -97,6 +97,8 @@ NSString* query = [NSString stringWithFormat:@"/apn/%@", [deviceToken encodedAsHexString]]; + DDLogInfo(@"Registered APN Device Token with Signal Server"); + return [HttpRequest httpRequestWithBasicAuthenticationAndMethod:@"PUT" andLocation:query]; } diff --git a/Signal/src/view controllers/RegisterViewController.m b/Signal/src/view controllers/RegisterViewController.m index b0e998249..cf6d07b1e 100644 --- a/Signal/src/view controllers/RegisterViewController.m +++ b/Signal/src/view controllers/RegisterViewController.m @@ -142,15 +142,17 @@ }]; Future *futureApnToRegister = [futurePhoneRegistrationVerified then:^(HttpResponse* okResponse) { - // @todo: keep handling code for simulator? return [futureApnId catch:^id(id error) { + DDLogError(@"Could not get APN. Runs in Simulator?"); return nil; }]; }]; return [futureApnToRegister then:^Future*(NSData* deviceToken) { - // @todo: distinguish between simulator no-apn error and other no-apn errors - if (deviceToken == nil) return futureApnToRegister; + if (deviceToken == nil){ + DDLogError(@"Couldn't get a device token for APN. Runs in Simulator?"); + return futureApnToRegister; + } HttpRequest* request = [HttpRequest httpRequestToRegisterForApnSignalingWithDeviceToken:deviceToken]; return [HttpManager asyncOkResponseFromMasterServer:request