From c058550feb2425f6adfd6d8e4d47f65a6a4efd31 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Wed, 4 Aug 2021 20:42:54 +0200 Subject: [PATCH] Add -Werror --- submodules/MtProtoKit/BUILD | 3 + .../MtProtoKit/MTApiEnvironment.h | 50 +++++----- .../PublicHeaders/MtProtoKit/MTContext.h | 92 +++++++++---------- .../MtProtoKit/MTDatacenterAddress.h | 10 +- .../PublicHeaders/MtProtoKit/MTEncryption.h | 78 ++++++++-------- .../PublicHeaders/MtProtoKit/MTTransport.h | 36 ++++---- .../MtProtoKit/MTTransportScheme.h | 10 +- .../Sources/AFHTTPRequestOperation.m | 20 ++-- submodules/MtProtoKit/Sources/MTContext.m | 14 +-- .../Sources/MTDiscoverConnectionSignals.h | 6 +- submodules/MtProtoKit/Sources/MTEncryption.m | 2 +- .../Sources/MTNetworkAvailability.m | 1 - .../Sources/MTRequestMessageService.m | 6 +- .../MtProtoKit/Sources/MTTcpConnection.m | 24 ++--- .../MtProtoKit/Sources/MTTcpTransport.m | 6 +- .../Sources/Network/MultipartFetch.swift | 2 +- .../Sources/Network/Network.swift | 2 +- .../SecretChats/SecretChatEncryption.swift | 20 ++-- .../SecretChats/SecretChatRekeySession.swift | 2 +- .../SecretChats/UpdateSecretChat.swift | 2 +- .../Sources/State/CallSessionManager.swift | 12 +-- .../ManagedSecretChatOutgoingOperations.swift | 4 +- .../Sources/State/Serialization.swift | 2 +- .../Sources/ManageSharedAccountInfo.swift | 6 +- 24 files changed, 209 insertions(+), 201 deletions(-) diff --git a/submodules/MtProtoKit/BUILD b/submodules/MtProtoKit/BUILD index b51410879d..db9e8f2755 100644 --- a/submodules/MtProtoKit/BUILD +++ b/submodules/MtProtoKit/BUILD @@ -7,6 +7,9 @@ objc_library( "Sources/**/*.m", "Sources/**/*.h", ]), + copts = [ + "-Werror", + ], hdrs = glob([ "PublicHeaders/**/*.h", ]), diff --git a/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTApiEnvironment.h b/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTApiEnvironment.h index 2180bd63b2..c35dfbcb9e 100644 --- a/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTApiEnvironment.h +++ b/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTApiEnvironment.h @@ -33,13 +33,13 @@ @interface MTSocksProxySettings : NSObject -@property (nonatomic, strong, readonly) NSString *ip; +@property (nonatomic, strong, readonly) NSString * _Nonnull ip; @property (nonatomic, readonly) uint16_t port; -@property (nonatomic, strong, readonly) NSString *username; -@property (nonatomic, strong, readonly) NSString *password; -@property (nonatomic, strong, readonly) NSData *secret; +@property (nonatomic, strong, readonly) NSString * _Nullable username; +@property (nonatomic, strong, readonly) NSString * _Nullable password; +@property (nonatomic, strong, readonly) NSData * _Nullable secret; -- (instancetype)initWithIp:(NSString *)ip port:(uint16_t)port username:(NSString *)username password:(NSString *)password secret:(NSData *)secret; +- (instancetype _Nonnull)initWithIp:(NSString * _Nonnull )ip port:(uint16_t)port username:(NSString * _Nullable)username password:(NSString * _Nullable)password secret:(NSData * _Nullable)secret; @end @@ -47,38 +47,38 @@ @property (nonatomic, readonly) bool reducedBackupDiscoveryTimeout; -- (instancetype)initWithReducedBackupDiscoveryTimeout:(bool)reducedBackupDiscoveryTimeout; +- (instancetype _Nonnull)initWithReducedBackupDiscoveryTimeout:(bool)reducedBackupDiscoveryTimeout; @end @interface MTApiEnvironment : NSObject @property (nonatomic) int32_t apiId; -@property (nonatomic, strong, readonly) NSString *deviceModel; -@property (nonatomic, strong, readonly) NSString *systemVersion; -@property (nonatomic, strong) NSString *appVersion; -@property (nonatomic, strong, readonly) NSString *systemLangCode; -@property (nonatomic, strong) NSNumber *layer; -@property (nonatomic, strong, readonly) NSData *systemCode; +@property (nonatomic, strong, readonly) NSString * _Nullable deviceModel; +@property (nonatomic, strong, readonly) NSString * _Nullable systemVersion; +@property (nonatomic, strong) NSString * _Nullable appVersion; +@property (nonatomic, strong, readonly) NSString * _Nullable systemLangCode; +@property (nonatomic, strong) NSNumber * _Nullable layer; +@property (nonatomic, strong, readonly) NSData * _Nullable systemCode; -@property (nonatomic, strong) NSString *langPack; -@property (nonatomic, strong, readonly) NSString *langPackCode; +@property (nonatomic, strong) NSString * _Nullable langPack; +@property (nonatomic, strong, readonly) NSString * _Nullable langPackCode; -@property (nonatomic, strong, readonly) NSString *apiInitializationHash; +@property (nonatomic, strong, readonly) NSString * _Nullable apiInitializationHash; @property (nonatomic) bool disableUpdates; -@property (nonatomic) NSData *tcpPayloadPrefix; -@property (nonatomic) NSDictionary *datacenterAddressOverrides; -@property (nonatomic) NSString *accessHostOverride; +@property (nonatomic) NSData * _Nullable tcpPayloadPrefix; +@property (nonatomic) NSDictionary * _Nullable datacenterAddressOverrides; +@property (nonatomic) NSString * _Nullable accessHostOverride; -@property (nonatomic, strong, readonly) MTSocksProxySettings *socksProxySettings; -@property (nonatomic, strong, readonly) MTNetworkSettings *networkSettings; +@property (nonatomic, strong, readonly) MTSocksProxySettings * _Nullable socksProxySettings; +@property (nonatomic, strong, readonly) MTNetworkSettings * _Nullable networkSettings; -@property (nonatomic, copy) void (^passwordInputHandler)(void); +@property (nonatomic, copy) void (^ _Nullable passwordInputHandler)(void); -- (MTApiEnvironment *)withUpdatedLangPackCode:(NSString *)langPackCode; -- (MTApiEnvironment *)withUpdatedSocksProxySettings:(MTSocksProxySettings *)socksProxySettings; -- (MTApiEnvironment *)withUpdatedNetworkSettings:(MTNetworkSettings *)networkSettings; -- (MTApiEnvironment *)withUpdatedSystemCode:(NSData *)systemCode; +- (MTApiEnvironment * _Nonnull)withUpdatedLangPackCode:(NSString * _Nullable)langPackCode; +- (MTApiEnvironment * _Nonnull)withUpdatedSocksProxySettings:(MTSocksProxySettings * _Nullable)socksProxySettings; +- (MTApiEnvironment * _Nonnull)withUpdatedNetworkSettings:(MTNetworkSettings * _Nullable)networkSettings; +- (MTApiEnvironment * _Nonnull)withUpdatedSystemCode:(NSData * _Nullable)systemCode; @end diff --git a/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTContext.h b/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTContext.h index c4898b32db..9f687b8774 100644 --- a/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTContext.h +++ b/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTContext.h @@ -19,34 +19,34 @@ @optional -- (void)contextDatacenterAddressSetUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId addressSet:(MTDatacenterAddressSet *)addressSet; -- (void)contextDatacenterAuthInfoUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId authInfo:(MTDatacenterAuthInfo *)authInfo selector:(MTDatacenterAuthInfoSelector)selector; -- (void)contextDatacenterAuthTokenUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId authToken:(id)authToken; -- (void)contextDatacenterTransportSchemesUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId shouldReset:(bool)shouldReset; -- (void)contextIsPasswordRequiredUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId; -- (void)contextDatacenterPublicKeysUpdated:(MTContext *)context datacenterId:(NSInteger)datacenterId publicKeys:(NSArray *)publicKeys; -- (MTSignal *)fetchContextDatacenterPublicKeys:(MTContext *)context datacenterId:(NSInteger)datacenterId; -- (void)contextApiEnvironmentUpdated:(MTContext *)context apiEnvironment:(MTApiEnvironment *)apiEnvironment; -- (MTSignal *)isContextNetworkAccessAllowed:(MTContext *)context; -- (void)contextLoggedOut:(MTContext *)context; +- (void)contextDatacenterAddressSetUpdated:(MTContext * _Nonnull)context datacenterId:(NSInteger)datacenterId addressSet:(MTDatacenterAddressSet * _Nonnull)addressSet; +- (void)contextDatacenterAuthInfoUpdated:(MTContext * _Nonnull)context datacenterId:(NSInteger)datacenterId authInfo:(MTDatacenterAuthInfo * _Nonnull)authInfo selector:(MTDatacenterAuthInfoSelector)selector; +- (void)contextDatacenterAuthTokenUpdated:(MTContext * _Nonnull)context datacenterId:(NSInteger)datacenterId authToken:(id _Nullable)authToken; +- (void)contextDatacenterTransportSchemesUpdated:(MTContext * _Nonnull)context datacenterId:(NSInteger)datacenterId shouldReset:(bool)shouldReset; +- (void)contextIsPasswordRequiredUpdated:(MTContext * _Nonnull)context datacenterId:(NSInteger)datacenterId; +- (void)contextDatacenterPublicKeysUpdated:(MTContext * _Nonnull)context datacenterId:(NSInteger)datacenterId publicKeys:(NSArray * _Nonnull)publicKeys; +- (MTSignal * _Nonnull)fetchContextDatacenterPublicKeys:(MTContext * _Nonnull)context datacenterId:(NSInteger)datacenterId; +- (void)contextApiEnvironmentUpdated:(MTContext * _Nonnull)context apiEnvironment:(MTApiEnvironment * _Nonnull)apiEnvironment; +- (MTSignal * _Nonnull)isContextNetworkAccessAllowed:(MTContext * _Nonnull)context; +- (void)contextLoggedOut:(MTContext * _Nonnull)context; @end @interface MTContextBlockChangeListener : NSObject -@property (nonatomic, copy) void (^contextIsPasswordRequiredUpdated)(MTContext *, NSInteger); -@property (nonatomic, copy) MTSignal *(^fetchContextDatacenterPublicKeys)(MTContext *, NSInteger); -@property (nonatomic, copy) MTSignal *(^isContextNetworkAccessAllowed)(MTContext *); +@property (nonatomic, copy) void (^ _Nullable contextIsPasswordRequiredUpdated)(MTContext * _Nonnull, NSInteger); +@property (nonatomic, copy) MTSignal * _Nonnull (^ _Nullable fetchContextDatacenterPublicKeys)(MTContext * _Nonnull, NSInteger); +@property (nonatomic, copy) MTSignal * _Nonnull(^ _Nullable isContextNetworkAccessAllowed)(MTContext * _Nonnull); @end @interface MTContext : NSObject -@property (nonatomic, strong) id keychain; +@property (nonatomic, strong) id _Nonnull keychain; -@property (nonatomic, strong, readonly) id serialization; -@property (nonatomic, strong) id encryptionProvider; -@property (nonatomic, strong, readonly) MTApiEnvironment *apiEnvironment; +@property (nonatomic, strong, readonly) id _Nonnull serialization; +@property (nonatomic, strong) id _Nonnull encryptionProvider; +@property (nonatomic, strong, readonly) MTApiEnvironment * _Nonnull apiEnvironment; @property (nonatomic, readonly) bool isTestingEnvironment; @property (nonatomic, readonly) bool useTempAuthKeys; @property (nonatomic) int32_t tempKeyExpiration; @@ -54,66 +54,66 @@ + (int32_t)fixedTimeDifference; + (void)setFixedTimeDifference:(int32_t)fixedTimeDifference; -+ (MTQueue *)contextQueue; ++ (MTQueue * _Nonnull)contextQueue; -- (instancetype)initWithSerialization:(id)serialization encryptionProvider:(id)encryptionProvider apiEnvironment:(MTApiEnvironment *)apiEnvironment isTestingEnvironment:(bool)isTestingEnvironment useTempAuthKeys:(bool)useTempAuthKeys; +- (instancetype _Nonnull)initWithSerialization:(id _Nonnull)serialization encryptionProvider:(id _Nonnull)encryptionProvider apiEnvironment:(MTApiEnvironment * _Nonnull)apiEnvironment isTestingEnvironment:(bool)isTestingEnvironment useTempAuthKeys:(bool)useTempAuthKeys; -- (void)performBatchUpdates:(void (^)())block; +- (void)performBatchUpdates:(void (^ _Nonnull)())block; -- (void)addChangeListener:(id)changeListener; -- (void)removeChangeListener:(id)changeListener; +- (void)addChangeListener:(id _Nonnull)changeListener; +- (void)removeChangeListener:(id _Nonnull)changeListener; -- (void)setDiscoverBackupAddressListSignal:(MTSignal *)signal; +- (void)setDiscoverBackupAddressListSignal:(MTSignal * _Nonnull)signal; - (NSTimeInterval)globalTime; - (NSTimeInterval)globalTimeDifference; - (NSTimeInterval)globalTimeOffsetFromUTC; - (void)setGlobalTimeDifference:(NSTimeInterval)globalTimeDifference; -- (void)setSeedAddressSetForDatacenterWithId:(NSInteger)datacenterId seedAddressSet:(MTDatacenterAddressSet *)seedAddressSet; -- (void)updateAddressSetForDatacenterWithId:(NSInteger)datacenterId addressSet:(MTDatacenterAddressSet *)addressSet forceUpdateSchemes:(bool)forceUpdateSchemes; -- (void)addAddressForDatacenterWithId:(NSInteger)datacenterId address:(MTDatacenterAddress *)address; -- (void)updateTransportSchemeForDatacenterWithId:(NSInteger)datacenterId transportScheme:(MTTransportScheme *)transportScheme media:(bool)media isProxy:(bool)isProxy; -- (void)updateAuthInfoForDatacenterWithId:(NSInteger)datacenterId authInfo:(MTDatacenterAuthInfo *)authInfo selector:(MTDatacenterAuthInfoSelector)selector; +- (void)setSeedAddressSetForDatacenterWithId:(NSInteger)datacenterId seedAddressSet:(MTDatacenterAddressSet * _Nonnull)seedAddressSet; +- (void)updateAddressSetForDatacenterWithId:(NSInteger)datacenterId addressSet:(MTDatacenterAddressSet * _Nonnull)addressSet forceUpdateSchemes:(bool)forceUpdateSchemes; +- (void)addAddressForDatacenterWithId:(NSInteger)datacenterId address:(MTDatacenterAddress * _Nonnull)address; +- (void)updateTransportSchemeForDatacenterWithId:(NSInteger)datacenterId transportScheme:(MTTransportScheme * _Nonnull)transportScheme media:(bool)media isProxy:(bool)isProxy; +- (void)updateAuthInfoForDatacenterWithId:(NSInteger)datacenterId authInfo:(MTDatacenterAuthInfo * _Nullable)authInfo selector:(MTDatacenterAuthInfoSelector)selector; - (bool)isPasswordInputRequiredForDatacenterWithId:(NSInteger)datacenterId; - (bool)updatePasswordInputRequiredForDatacenterWithId:(NSInteger)datacenterId required:(bool)required; -- (void)scheduleSessionCleanupForAuthKeyId:(int64_t)authKeyId sessionInfo:(MTSessionInfo *)sessionInfo; -- (void)collectSessionIdsForCleanupWithAuthKeyId:(int64_t)authKeyId completion:(void (^)(NSArray *sessionIds))completion; -- (void)sessionIdsDeletedForAuthKeyId:(int64_t)authKeyId sessionIds:(NSArray *)sessionIds; +- (void)scheduleSessionCleanupForAuthKeyId:(int64_t)authKeyId sessionInfo:(MTSessionInfo * _Nonnull)sessionInfo; +- (void)collectSessionIdsForCleanupWithAuthKeyId:(int64_t)authKeyId completion:(void (^ _Nonnull)(NSArray * _Nonnull sessionIds))completion; +- (void)sessionIdsDeletedForAuthKeyId:(int64_t)authKeyId sessionIds:(NSArray * _Nonnull)sessionIds; -- (NSArray *)knownDatacenterIds; -- (void)enumerateAddressSetsForDatacenters:(void (^)(NSInteger datacenterId, MTDatacenterAddressSet *addressSet, BOOL *stop))block; +- (NSArray * _Nonnull)knownDatacenterIds; +- (void)enumerateAddressSetsForDatacenters:(void (^ _Nonnull)(NSInteger datacenterId, MTDatacenterAddressSet * _Nonnull addressSet, BOOL * _Nullable stop))block; -- (MTDatacenterAddressSet *)addressSetForDatacenterWithId:(NSInteger)datacenterId; -- (void)reportTransportSchemeFailureForDatacenterId:(NSInteger)datacenterId transportScheme:(MTTransportScheme *)transportScheme; -- (void)reportTransportSchemeSuccessForDatacenterId:(NSInteger)datacenterId transportScheme:(MTTransportScheme *)transportScheme; +- (MTDatacenterAddressSet * _Nonnull)addressSetForDatacenterWithId:(NSInteger)datacenterId; +- (void)reportTransportSchemeFailureForDatacenterId:(NSInteger)datacenterId transportScheme:(MTTransportScheme * _Nonnull)transportScheme; +- (void)reportTransportSchemeSuccessForDatacenterId:(NSInteger)datacenterId transportScheme:(MTTransportScheme * _Nonnull)transportScheme; - (void)invalidateTransportSchemesForDatacenterIds:(NSArray * _Nonnull)datacenterIds; - (void)invalidateTransportSchemesForKnownDatacenterIds; - (MTTransportScheme * _Nullable)chooseTransportSchemeForConnectionToDatacenterId:(NSInteger)datacenterId schemes:(NSArray * _Nonnull)schemes; - (NSArray * _Nonnull)transportSchemesForDatacenterWithId:(NSInteger)datacenterId media:(bool)media enforceMedia:(bool)enforceMedia isProxy:(bool)isProxy; - (void)transportSchemeForDatacenterWithIdRequired:(NSInteger)datacenterId media:(bool)media; -- (void)invalidateTransportSchemeForDatacenterId:(NSInteger)datacenterId transportScheme:(MTTransportScheme *)transportScheme isProbablyHttp:(bool)isProbablyHttp media:(bool)media; -- (void)revalidateTransportSchemeForDatacenterId:(NSInteger)datacenterId transportScheme:(MTTransportScheme *)transportScheme media:(bool)media; -- (MTDatacenterAuthInfo *)authInfoForDatacenterWithId:(NSInteger)datacenterId selector:(MTDatacenterAuthInfoSelector)selector; +- (void)invalidateTransportSchemeForDatacenterId:(NSInteger)datacenterId transportScheme:(MTTransportScheme * _Nonnull)transportScheme isProbablyHttp:(bool)isProbablyHttp media:(bool)media; +- (void)revalidateTransportSchemeForDatacenterId:(NSInteger)datacenterId transportScheme:(MTTransportScheme * _Nonnull)transportScheme media:(bool)media; +- (MTDatacenterAuthInfo * _Nullable)authInfoForDatacenterWithId:(NSInteger)datacenterId selector:(MTDatacenterAuthInfoSelector)selector; -- (NSArray *)publicKeysForDatacenterWithId:(NSInteger)datacenterId; -- (void)updatePublicKeysForDatacenterWithId:(NSInteger)datacenterId publicKeys:(NSArray *)publicKeys; +- (NSArray * _Nonnull)publicKeysForDatacenterWithId:(NSInteger)datacenterId; +- (void)updatePublicKeysForDatacenterWithId:(NSInteger)datacenterId publicKeys:(NSArray * _Nonnull)publicKeys; - (void)publicKeysForDatacenterWithIdRequired:(NSInteger)datacenterId; - (void)removeAllAuthTokens; - (void)removeTokenForDatacenterWithId:(NSInteger)datacenterId; -- (id)authTokenForDatacenterWithId:(NSInteger)datacenterId; -- (void)updateAuthTokenForDatacenterWithId:(NSInteger)datacenterId authToken:(id)authToken; +- (id _Nullable)authTokenForDatacenterWithId:(NSInteger)datacenterId; +- (void)updateAuthTokenForDatacenterWithId:(NSInteger)datacenterId authToken:(id _Nullable)authToken; - (void)addressSetForDatacenterWithIdRequired:(NSInteger)datacenterId; - (void)authInfoForDatacenterWithIdRequired:(NSInteger)datacenterId isCdn:(bool)isCdn selector:(MTDatacenterAuthInfoSelector)selector; -- (void)authTokenForDatacenterWithIdRequired:(NSInteger)datacenterId authToken:(id)authToken masterDatacenterId:(NSInteger)masterDatacenterId; +- (void)authTokenForDatacenterWithIdRequired:(NSInteger)datacenterId authToken:(id _Nullable)authToken masterDatacenterId:(NSInteger)masterDatacenterId; -- (void)reportProblemsWithDatacenterAddressForId:(NSInteger)datacenterId address:(MTDatacenterAddress *)address; +- (void)reportProblemsWithDatacenterAddressForId:(NSInteger)datacenterId address:(MTDatacenterAddress * _Nonnull)address; -- (void)updateApiEnvironment:(MTApiEnvironment *(^)(MTApiEnvironment *))f; +- (void)updateApiEnvironment:(MTApiEnvironment * _Nullable (^ _Nonnull)(MTApiEnvironment * _Nullable))f; - (void)beginExplicitBackupAddressDiscovery; diff --git a/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTDatacenterAddress.h b/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTDatacenterAddress.h index b984d825dd..85d5b4ac0a 100644 --- a/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTDatacenterAddress.h +++ b/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTDatacenterAddress.h @@ -4,18 +4,18 @@ @interface MTDatacenterAddress : NSObject -@property (nonatomic, strong, readonly) NSString *host; -@property (nonatomic, strong, readonly) NSString *ip; +@property (nonatomic, strong, readonly) NSString * _Nullable host; +@property (nonatomic, strong, readonly) NSString * _Nullable ip; @property (nonatomic, readonly) uint16_t port; @property (nonatomic, readonly) bool preferForMedia; @property (nonatomic, readonly) bool restrictToTcp; @property (nonatomic, readonly) bool cdn; @property (nonatomic, readonly) bool preferForProxy; -@property (nonatomic, readonly) NSData *secret; +@property (nonatomic, readonly) NSData * _Nullable secret; -- (instancetype)initWithIp:(NSString *)ip port:(uint16_t)port preferForMedia:(bool)preferForMedia restrictToTcp:(bool)restrictToTcp cdn:(bool)cdn preferForProxy:(bool)preferForProxy secret:(NSData *)secret; +- (instancetype _Nonnull)initWithIp:(NSString * _Nonnull)ip port:(uint16_t)port preferForMedia:(bool)preferForMedia restrictToTcp:(bool)restrictToTcp cdn:(bool)cdn preferForProxy:(bool)preferForProxy secret:(NSData * _Nullable)secret; -- (BOOL)isEqualToAddress:(MTDatacenterAddress *)other; +- (BOOL)isEqualToAddress:(MTDatacenterAddress * _Nonnull)other; - (BOOL)isIpv6; @end diff --git a/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTEncryption.h b/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTEncryption.h index e197db45d1..2274923ffb 100644 --- a/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTEncryption.h +++ b/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTEncryption.h @@ -9,66 +9,66 @@ extern "C" { #endif -NSData *MTSha1(NSData *data); -NSData *MTSubdataSha1(NSData *data, NSUInteger offset, NSUInteger length); +NSData * _Nonnull MTSha1(NSData * _Nonnull data); +NSData * _Nonnull MTSubdataSha1(NSData * _Nonnull data, NSUInteger offset, NSUInteger length); -NSData *MTSha256(NSData *data); +NSData * _Nonnull MTSha256(NSData * _Nonnull data); -void MTRawSha1(void const *inData, NSUInteger length, void *outData); -void MTRawSha256(void const *inData, NSUInteger length, void *outData); +void MTRawSha1(void const * _Nonnull inData, NSUInteger length, void * _Nonnull outData); +void MTRawSha256(void const * _Nonnull inData, NSUInteger length, void * _Nonnull outData); -int32_t MTMurMurHash32(const void *bytes, int length); +int32_t MTMurMurHash32(const void * _Nonnull bytes, int length); -void MTAesEncryptInplace(NSMutableData *data, NSData *key, NSData *iv); -void MTAesEncryptInplaceAndModifyIv(NSMutableData *data, NSData *key, NSMutableData *iv); -void MTAesEncryptBytesInplaceAndModifyIv(void *data, NSInteger length, NSData *key, void *iv); -void MTAesEncryptRaw(void const *data, void *outData, NSInteger length, void const *key, void const *iv); -void MTAesDecryptRaw(void const *data, void *outData, NSInteger length, void const *key, void const *iv); -void MTAesDecryptInplaceAndModifyIv(NSMutableData *data, NSData *key, NSMutableData *iv); -void MTAesDecryptBytesInplaceAndModifyIv(void *data, NSInteger length, NSData *key, void *iv); -NSData *MTAesEncrypt(NSData *data, NSData *key, NSData *iv); -NSData *MTAesDecrypt(NSData *data, NSData *key, NSData *iv); -NSData *MTRsaEncrypt(id provider, NSString *publicKey, NSData *data); -NSData *MTExp(id provider, NSData *base, NSData *exp, NSData *modulus); -NSData *MTModSub(id provider, NSData *a, NSData *b, NSData *modulus); -NSData *MTModMul(id provider, NSData *a, NSData *b, NSData *modulus); -NSData *MTMul(id provider, NSData *a, NSData *b); -NSData *MTAdd(id provider, NSData *a, NSData *b); -bool MTFactorize(uint64_t what, uint64_t *resA, uint64_t *resB); -bool MTIsZero(id provider, NSData *value); +void MTAesEncryptInplace(NSMutableData * _Nonnull data, NSData * _Nonnull key, NSData * _Nonnull iv); +void MTAesEncryptInplaceAndModifyIv(NSMutableData * _Nonnull data, NSData * _Nonnull key, NSMutableData * _Nonnull iv); +void MTAesEncryptBytesInplaceAndModifyIv(void * _Nonnull data, NSInteger length, NSData * _Nonnull key, void * _Nonnull iv); +void MTAesEncryptRaw(void const * _Nonnull data, void * _Nonnull outData, NSInteger length, void const * _Nonnull key, void const * _Nonnull iv); +void MTAesDecryptRaw(void const * _Nonnull data, void * _Nonnull outData, NSInteger length, void const * _Nonnull key, void const * _Nonnull iv); +void MTAesDecryptInplaceAndModifyIv(NSMutableData * _Nonnull data, NSData * _Nonnull key, NSMutableData * _Nonnull iv); +void MTAesDecryptBytesInplaceAndModifyIv(void * _Nonnull data, NSInteger length, NSData * _Nonnull key, void * _Nonnull iv); +NSData * _Nullable MTAesEncrypt(NSData * _Nonnull data, NSData * _Nonnull key, NSData * _Nonnull iv); +NSData * _Nullable MTAesDecrypt(NSData * _Nonnull data, NSData * _Nonnull key, NSData * _Nonnull iv); +NSData * _Nullable MTRsaEncrypt(id _Nonnull provider, NSString * _Nonnull publicKey, NSData * _Nonnull data); +NSData * _Nullable MTExp(id _Nonnull provider, NSData * _Nonnull base, NSData * _Nonnull exp, NSData * _Nonnull modulus); +NSData * _Nullable MTModSub(id _Nonnull provider, NSData * _Nonnull a, NSData * _Nonnull b, NSData * _Nonnull modulus); +NSData * _Nullable MTModMul(id _Nonnull provider, NSData * _Nonnull a, NSData * _Nonnull b, NSData * _Nonnull modulus); +NSData * _Nullable MTMul(id _Nonnull provider, NSData * _Nonnull a, NSData * _Nonnull b); +NSData * _Nullable MTAdd(id _Nonnull provider, NSData * _Nonnull a, NSData * _Nonnull b); +bool MTFactorize(uint64_t what, uint64_t * _Nonnull resA, uint64_t * _Nonnull resB); +bool MTIsZero(id _Nonnull provider, NSData * _Nonnull value); -NSData *MTAesCtrDecrypt(NSData *data, NSData *key, NSData *iv); +NSData * _Nullable MTAesCtrDecrypt(NSData * _Nonnull data, NSData * _Nonnull key, NSData * _Nonnull iv); @protocol MTKeychain; bool MTCheckIsSafeG(unsigned int g); -bool MTCheckIsSafeB(id provider, NSData *b, NSData *p); -bool MTCheckIsSafePrime(id provider, NSData *numberBytes, id keychain); -bool MTCheckIsSafeGAOrB(id provider, NSData *gAOrB, NSData *p); -bool MTCheckMod(id provider, NSData *numberBytes, unsigned int g, id keychain); +bool MTCheckIsSafeB(id _Nonnull provider, NSData * _Nonnull b, NSData * _Nonnull p); +bool MTCheckIsSafePrime(id _Nonnull provider, NSData * _Nonnull numberBytes, id _Nonnull keychain); +bool MTCheckIsSafeGAOrB(id _Nonnull provider, NSData * _Nonnull gAOrB, NSData * _Nonnull p); +bool MTCheckMod(id _Nonnull provider, NSData * _Nonnull numberBytes, unsigned int g, id _Nonnull keychain); @interface MTAesCtr : NSObject -- (instancetype)initWithKey:(const void *)key keyLength:(int)keyLength iv:(const void *)iv decrypt:(bool)decrypt; -- (instancetype)initWithKey:(const void *)key keyLength:(int)keyLength iv:(const void *)iv ecount:(void *)ecount num:(uint32_t)num; +- (instancetype _Nonnull)initWithKey:(const void * _Nonnull)key keyLength:(int)keyLength iv:(const void * _Nonnull)iv decrypt:(bool)decrypt; +- (instancetype _Nonnull)initWithKey:(const void * _Nonnull)key keyLength:(int)keyLength iv:(const void * _Nonnull)iv ecount:(void * _Nonnull)ecount num:(uint32_t)num; - (uint32_t)num; -- (void *)ecount; -- (void)getIv:(void *)iv; +- (void * _Nonnull)ecount; +- (void)getIv:(void * _Nonnull)iv; -- (void)encryptIn:(const unsigned char *)in out:(unsigned char *)out len:(size_t)len; +- (void)encryptIn:(const unsigned char * _Nonnull)in out:(unsigned char * _Nonnull)out len:(size_t)len; @end -uint64_t MTRsaFingerprint(id provider, NSString *key); +uint64_t MTRsaFingerprint(id _Nonnull provider, NSString * _Nonnull key); -NSData *MTRsaEncryptPKCS1OAEP(id provider, NSString *key, NSData *data); +NSData * _Nullable MTRsaEncryptPKCS1OAEP(id _Nonnull provider, NSString * _Nonnull key, NSData * _Nonnull data); @interface MTBackupDatacenterAddress : NSObject @property (nonatomic, readonly) int32_t datacenterId; -@property (nonatomic, strong, readonly) NSString *ip; +@property (nonatomic, strong, readonly) NSString * _Nonnull ip; @property (nonatomic, readonly) int32_t port; -@property (nonatomic, strong, readonly) NSData *secret; +@property (nonatomic, strong, readonly) NSData * _Nullable secret; @end @@ -76,11 +76,11 @@ NSData *MTRsaEncryptPKCS1OAEP(id provider, NSString *key, NS @property (nonatomic, readonly) int32_t timestamp; @property (nonatomic, readonly) int32_t expirationDate; -@property (nonatomic, strong, readonly) NSArray *addressList; +@property (nonatomic, strong, readonly) NSArray * _Nonnull addressList; @end -MTBackupDatacenterData *MTIPDataDecode(id provider, NSData *data, NSString *phoneNumber); +MTBackupDatacenterData * _Nullable MTIPDataDecode(id _Nonnull provider, NSData * _Nonnull data, NSString * _Nonnull phoneNumber); NSData * _Nullable MTPBKDF2(NSData * _Nonnull data, NSData * _Nonnull salt, int rounds); diff --git a/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTTransport.h b/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTTransport.h index fcc2d4b241..c1e8923493 100644 --- a/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTTransport.h +++ b/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTTransport.h @@ -19,34 +19,34 @@ @optional -- (void)transportNetworkAvailabilityChanged:(MTTransport *)transport isNetworkAvailable:(bool)isNetworkAvailable; -- (void)transportConnectionStateChanged:(MTTransport *)transport isConnected:(bool)isConnected proxySettings:(MTSocksProxySettings *)proxySettings; -- (void)transportConnectionFailed:(MTTransport *)transport scheme:(MTTransportScheme *)scheme; -- (void)transportConnectionContextUpdateStateChanged:(MTTransport *)transport isUpdatingConnectionContext:(bool)isUpdatingConnectionContext; -- (void)transportConnectionProblemsStatusChanged:(MTTransport *)transport scheme:(MTTransportScheme *)scheme hasConnectionProblems:(bool)hasConnectionProblems isProbablyHttp:(bool)isProbablyHttp; +- (void)transportNetworkAvailabilityChanged:(MTTransport * _Nonnull)transport isNetworkAvailable:(bool)isNetworkAvailable; +- (void)transportConnectionStateChanged:(MTTransport * _Nonnull)transport isConnected:(bool)isConnected proxySettings:(MTSocksProxySettings * _Nullable)proxySettings; +- (void)transportConnectionFailed:(MTTransport * _Nonnull)transport scheme:(MTTransportScheme * _Nonnull)scheme; +- (void)transportConnectionContextUpdateStateChanged:(MTTransport * _Nonnull)transport isUpdatingConnectionContext:(bool)isUpdatingConnectionContext; +- (void)transportConnectionProblemsStatusChanged:(MTTransport * _Nonnull)transport scheme:(MTTransportScheme * _Nonnull)scheme hasConnectionProblems:(bool)hasConnectionProblems isProbablyHttp:(bool)isProbablyHttp; -- (void)transportReadyForTransaction:(MTTransport *)transport scheme:(MTTransportScheme *)scheme transportSpecificTransaction:(MTMessageTransaction *)transportSpecificTransaction forceConfirmations:(bool)forceConfirmations transactionReady:(void (^)(NSArray *))transactionReady; -- (void)transportHasIncomingData:(MTTransport *)transport scheme:(MTTransportScheme *)scheme data:(NSData *)data transactionId:(id)transactionId requestTransactionAfterProcessing:(bool)requestTransactionAfterProcessing decodeResult:(void (^)(id transactionId, bool success))decodeResult; -- (void)transportTransactionsMayHaveFailed:(MTTransport *)transport transactionIds:(NSArray *)transactionIds; -- (void)transportReceivedQuickAck:(MTTransport *)transport quickAckId:(int32_t)quickAckId; -- (void)transportDecodeProgressToken:(MTTransport *)transport scheme:(MTTransportScheme *)scheme data:(NSData *)data token:(int64_t)token completion:(void (^)(int64_t token, id progressToken))completion; -- (void)transportUpdatedDataReceiveProgress:(MTTransport *)transport progressToken:(id)progressToken packetLength:(NSInteger)packetLength progress:(float)progress; +- (void)transportReadyForTransaction:(MTTransport * _Nonnull)transport scheme:(MTTransportScheme * _Nonnull)scheme transportSpecificTransaction:(MTMessageTransaction * _Nonnull)transportSpecificTransaction forceConfirmations:(bool)forceConfirmations transactionReady:(void (^ _Nonnull)(NSArray * _Nonnull))transactionReady; +- (void)transportHasIncomingData:(MTTransport * _Nonnull)transport scheme:(MTTransportScheme * _Nonnull)scheme data:(NSData * _Nonnull)data transactionId:(id _Nonnull)transactionId requestTransactionAfterProcessing:(bool)requestTransactionAfterProcessing decodeResult:(void (^ _Nonnull)(id _Nonnull transactionId, bool success))decodeResult; +- (void)transportTransactionsMayHaveFailed:(MTTransport * _Nonnull)transport transactionIds:(NSArray * _Nonnull)transactionIds; +- (void)transportReceivedQuickAck:(MTTransport * _Nonnull)transport quickAckId:(int32_t)quickAckId; +- (void)transportDecodeProgressToken:(MTTransport * _Nonnull)transport scheme:(MTTransportScheme * _Nonnull)scheme data:(NSData * _Nonnull)data token:(int64_t)token completion:(void (^ _Nonnull)(int64_t token, id _Nonnull progressToken))completion; +- (void)transportUpdatedDataReceiveProgress:(MTTransport * _Nonnull)transport progressToken:(id _Nonnull)progressToken packetLength:(NSInteger)packetLength progress:(float)progress; @end @interface MTTransport : NSObject -@property (nonatomic, weak) id delegate; +@property (nonatomic, weak) id _Nullable delegate; -@property (nonatomic, strong, readonly) MTContext *context; +@property (nonatomic, strong, readonly) MTContext * _Nullable context; @property (nonatomic, readonly) NSInteger datacenterId; -@property (nonatomic, strong, readonly) MTSocksProxySettings *proxySettings; +@property (nonatomic, strong, readonly) MTSocksProxySettings * _Nullable proxySettings; @property (nonatomic) bool simultaneousTransactionsEnabled; @property (nonatomic) bool reportTransportConnectionContextUpdateStates; -- (instancetype)initWithDelegate:(id)delegate context:(MTContext *)context datacenterId:(NSInteger)datacenterId schemes:(NSArray * _Nonnull)schemes proxySettings:(MTSocksProxySettings *)proxySettings usageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo; +- (instancetype _Nonnull)initWithDelegate:(id _Nullable)delegate context:(MTContext * _Nonnull)context datacenterId:(NSInteger)datacenterId schemes:(NSArray * _Nonnull)schemes proxySettings:(MTSocksProxySettings * _Null_unspecified)proxySettings usageCalculationInfo:(MTNetworkUsageCalculationInfo * _Nullable)usageCalculationInfo; -- (void)setUsageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo; +- (void)setUsageCalculationInfo:(MTNetworkUsageCalculationInfo * _Null_unspecified)usageCalculationInfo; - (bool)needsParityCorrection; @@ -54,10 +54,10 @@ - (void)stop; - (void)updateConnectionState; - (void)setDelegateNeedsTransaction; -- (void)_processIncomingData:(NSData *)data scheme:(MTTransportScheme *)scheme transactionId:(id)transactionId requestTransactionAfterProcessing:(bool)requestTransactionAfterProcessing decodeResult:(void (^)(id transactionId, bool success))decodeResult; +- (void)_processIncomingData:(NSData * _Nonnull)data scheme:(MTTransportScheme * _Nonnull)scheme transactionId:(id _Nonnull)transactionId requestTransactionAfterProcessing:(bool)requestTransactionAfterProcessing decodeResult:(void (^ _Nonnull)(id _Nonnull transactionId, bool success))decodeResult; - (void)_networkAvailabilityChanged:(bool)networkAvailable; -- (void)activeTransactionIds:(void (^)(NSArray *activeTransactionId))completion; +- (void)activeTransactionIds:(void (^ _Nonnull)(NSArray * _Nonnull activeTransactionId))completion; - (void)updateSchemes:(NSArray * _Nonnull)schemes; diff --git a/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTTransportScheme.h b/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTTransportScheme.h index 333c2a018f..46b82fd544 100644 --- a/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTTransportScheme.h +++ b/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTTransportScheme.h @@ -10,14 +10,14 @@ @interface MTTransportScheme : NSObject -@property (nonatomic, strong, readonly) Class transportClass; -@property (nonatomic, strong, readonly) MTDatacenterAddress *address; +@property (nonatomic, strong, readonly) Class _Nonnull transportClass; +@property (nonatomic, strong, readonly) MTDatacenterAddress * _Nonnull address; @property (nonatomic, readonly) bool media; -- (instancetype)initWithTransportClass:(Class)transportClass address:(MTDatacenterAddress *)address media:(bool)media; +- (instancetype _Nonnull)initWithTransportClass:(Class _Nonnull)transportClass address:(MTDatacenterAddress * _Nonnull)address media:(bool)media; -- (BOOL)isEqualToScheme:(MTTransportScheme *)other; +- (BOOL)isEqualToScheme:(MTTransportScheme * _Nonnull)other; - (BOOL)isOptimal; -- (NSComparisonResult)compareToScheme:(MTTransportScheme *)other; +- (NSComparisonResult)compareToScheme:(MTTransportScheme * _Nonnull)other; @end diff --git a/submodules/MtProtoKit/Sources/AFHTTPRequestOperation.m b/submodules/MtProtoKit/Sources/AFHTTPRequestOperation.m index 212672ae77..325f4928a9 100644 --- a/submodules/MtProtoKit/Sources/AFHTTPRequestOperation.m +++ b/submodules/MtProtoKit/Sources/AFHTTPRequestOperation.m @@ -92,7 +92,7 @@ static NSString * AFStringFromIndexSet(NSIndexSet *indexSet) { if (self.response && !self.HTTPError) { if (![self hasAcceptableStatusCode]) { NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; - [userInfo setValue:[NSString stringWithFormat:NSLocalizedString(@"Expected status code in (%@), got %d", nil), AFStringFromIndexSet(self.acceptableStatusCodes), [self.response statusCode]] forKey:NSLocalizedDescriptionKey]; + [userInfo setValue:[NSString stringWithFormat:NSLocalizedString(@"Expected status code in (%@), got %ld", nil), AFStringFromIndexSet(self.acceptableStatusCodes), (long)[self.response statusCode]] forKey:NSLocalizedDescriptionKey]; [userInfo setValue:[self.request URL] forKey:NSURLErrorFailingURLErrorKey]; self.HTTPError = [[NSError alloc] initWithDomain:AFNetworkingErrorDomain code:NSURLErrorBadServerResponse userInfo:userInfo]; @@ -176,21 +176,27 @@ static NSString * AFStringFromIndexSet(NSIndexSet *indexSet) { - (void)setCompletionBlockWithSuccess:(void (^)(NSOperation *operation, id responseObject))success failure:(void (^)(NSOperation *operation, NSError *error))failure { + __weak typeof(self) weakSelf = self; self.completionBlock = ^ { - if ([self isCancelled]) { + __strong typeof(weakSelf) strongSelf = weakSelf; + if (!strongSelf) { + return; + } + + if ([strongSelf isCancelled]) { return; } - if (self.error) { + if (strongSelf.error) { if (failure) { - dispatch_group_async(self.dispatchGroup, self.failureCallbackQueue ? self.failureCallbackQueue : dispatch_get_main_queue(), ^{ - failure(self, self.error); + dispatch_group_async(strongSelf.dispatchGroup, strongSelf.failureCallbackQueue ? strongSelf.failureCallbackQueue : dispatch_get_main_queue(), ^{ + failure(strongSelf, strongSelf.error); }); } } else { if (success) { - dispatch_group_async(self.dispatchGroup, self.successCallbackQueue ? self.successCallbackQueue : dispatch_get_main_queue(), ^{ - success(self, self.responseData); + dispatch_group_async(strongSelf.dispatchGroup, strongSelf.successCallbackQueue ? strongSelf.successCallbackQueue : dispatch_get_main_queue(), ^{ + success(strongSelf, strongSelf.responseData); }); } } diff --git a/submodules/MtProtoKit/Sources/MTContext.m b/submodules/MtProtoKit/Sources/MTContext.m index bde013a54e..8216fe97b7 100644 --- a/submodules/MtProtoKit/Sources/MTContext.m +++ b/submodules/MtProtoKit/Sources/MTContext.m @@ -414,11 +414,11 @@ static int32_t fixedTimeDifferenceValue = 0; _cleanupSessionIdsByAuthKeyId = [[NSMutableDictionary alloc] initWithDictionary:cleanupSessionIdsByAuthKeyId]; if (MTLogEnabled()) { - MTLog(@"[MTContext#%x: received keychain globalTimeDifference:%f datacenterAuthInfoById:%@]", (int)self, _globalTimeDifference, _datacenterAuthInfoById); + MTLog(@"[MTContext#%llx: received keychain globalTimeDifference:%f datacenterAuthInfoById:%@]", (intptr_t)self, _globalTimeDifference, _datacenterAuthInfoById); } } else { if (MTLogEnabled()) { - MTLog(@"[MTContext#%x: received keychain nil]", (int)self); + MTLog(@"[MTContext#%llx: received keychain nil]", (intptr_t)self); } } }]; @@ -477,7 +477,7 @@ static int32_t fixedTimeDifferenceValue = 0; _globalTimeDifference = globalTimeDifference; if (MTLogEnabled()) { - MTLog(@"[MTContext#%x: global time difference changed: %.1fs]", (int)self, globalTimeDifference); + MTLog(@"[MTContext#%llx: global time difference changed: %.1fs]", (intptr_t)self, globalTimeDifference); } [_keychain setObject:@(_globalTimeDifference) forKey:@"globalTimeDifference" group:@"temp"]; @@ -499,7 +499,7 @@ static int32_t fixedTimeDifferenceValue = 0; if (addressSet != nil && datacenterId != 0) { if (MTLogEnabled()) { - MTLog(@"[MTContext#%x: address set updated for %d]", (int)self, datacenterId); + MTLog(@"[MTContext#%llx: address set updated for %d]", (intptr_t)self, datacenterId); } bool updateSchemes = forceUpdateSchemes; @@ -592,7 +592,7 @@ static int32_t fixedTimeDifferenceValue = 0; if (updated) { if (MTLogEnabled()) { - MTLog(@"[MTContext#%x: added address %@ for datacenter %d]", (int)self, address, datacenterId); + MTLog(@"[MTContext#%llx: added address %@ for datacenter %d]", (intptr_t)self, address, datacenterId); } _datacenterAddressSetById[@(datacenterId)] = addressSet; @@ -631,7 +631,7 @@ static int32_t fixedTimeDifferenceValue = 0; if (MTLogEnabled()) { MTDatacenterAuthInfo *persistentInfo = _datacenterAuthInfoById[authInfoMapIntegerKey((int32_t)datacenterId, MTDatacenterAuthInfoSelectorPersistent)]; - MTLog(@"[MTContext#%x: auth info updated for %d selector %d to %@ (persistent key id is %llu)]", (int)self, datacenterId, selector, authInfo, persistentInfo.authKeyId); + MTLog(@"[MTContext#%llx: auth info updated for %d selector %d to %@ (persistent key id is %llu)]", (intptr_t)self, datacenterId, selector, authInfo, persistentInfo.authKeyId); } [_keychain setObject:_datacenterAuthInfoById forKey:@"datacenterAuthInfoById" group:@"persistent"]; @@ -706,7 +706,7 @@ static int32_t fixedTimeDifferenceValue = 0; NSArray *currentListeners = [[NSArray alloc] initWithArray:_changeListeners]; if (MTLogEnabled()) { - MTLog(@"[MTContext#%x: %@ transport scheme updated for %d: %@]", (int)self, media ? @"media" : @"generic", datacenterId, transportScheme); + MTLog(@"[MTContext#%llx: %@ transport scheme updated for %d: %@]", (intptr_t)self, media ? @"media" : @"generic", datacenterId, transportScheme); } for (id listener in currentListeners) { diff --git a/submodules/MtProtoKit/Sources/MTDiscoverConnectionSignals.h b/submodules/MtProtoKit/Sources/MTDiscoverConnectionSignals.h index a71313c198..c704342db0 100644 --- a/submodules/MtProtoKit/Sources/MTDiscoverConnectionSignals.h +++ b/submodules/MtProtoKit/Sources/MTDiscoverConnectionSignals.h @@ -11,10 +11,10 @@ typedef struct { @interface MTDiscoverConnectionSignals : NSObject -+ (NSData *)payloadData:(MTPayloadData *)outPayloadData context:(MTContext *)context address:(MTDatacenterAddress *)address; ++ (NSData * _Nonnull)payloadData:(MTPayloadData * _Nonnull)outPayloadData context:(MTContext * _Nonnull)context address:(MTDatacenterAddress * _Nonnull)address; -+ (MTSignal *)discoverSchemeWithContext:(MTContext *)context datacenterId:(NSInteger)datacenterId addressList:(NSArray *)addressList media:(bool)media isProxy:(bool)isProxy; ++ (MTSignal * _Nonnull)discoverSchemeWithContext:(MTContext * _Nonnull)context datacenterId:(NSInteger)datacenterId addressList:(NSArray * _Nonnull)addressList media:(bool)media isProxy:(bool)isProxy; -+ (MTSignal * _Nonnull)checkIfAuthKeyRemovedWithContext:(MTContext * _Nonnull)context datacenterId:(NSInteger)datacenterId authKey:(MTDatacenterAuthKey *)authKey; ++ (MTSignal * _Nonnull)checkIfAuthKeyRemovedWithContext:(MTContext * _Nonnull)context datacenterId:(NSInteger)datacenterId authKey:(MTDatacenterAuthKey * _Nonnull)authKey; @end diff --git a/submodules/MtProtoKit/Sources/MTEncryption.m b/submodules/MtProtoKit/Sources/MTEncryption.m index 348e3065a3..9196eeb348 100644 --- a/submodules/MtProtoKit/Sources/MTEncryption.m +++ b/submodules/MtProtoKit/Sources/MTEncryption.m @@ -600,7 +600,7 @@ bool MTCheckIsSafePrime(id provider, NSData *numberBytes, id id bnNumberMinusOneDivByTwo = [context create]; [context rightShift1Bit:bnNumberMinusOneDivByTwo a:bnNumberMinusOne]; - int result = [context isPrime:bnNumberMinusOneDivByTwo numberOfChecks:30]; + result = [context isPrime:bnNumberMinusOneDivByTwo numberOfChecks:30]; } [keychain setObject:@(result == 1) forKey:primeKey group:@"primes"]; diff --git a/submodules/MtProtoKit/Sources/MTNetworkAvailability.m b/submodules/MtProtoKit/Sources/MTNetworkAvailability.m index 8e45f15cf3..da33990b8c 100644 --- a/submodules/MtProtoKit/Sources/MTNetworkAvailability.m +++ b/submodules/MtProtoKit/Sources/MTNetworkAvailability.m @@ -137,7 +137,6 @@ static void MTNetworkAvailabilityContextRelease(const void *info) [[MTNetworkAvailability networkAvailabilityQueue] dispatchOnQueue:^ { BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0); - BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0); BOOL canConnectionAutomatically = (((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0)); BOOL canConnectWithoutUserInteraction = (canConnectionAutomatically && diff --git a/submodules/MtProtoKit/Sources/MTRequestMessageService.m b/submodules/MtProtoKit/Sources/MTRequestMessageService.m index ac402c9c84..ab20463fb5 100644 --- a/submodules/MtProtoKit/Sources/MTRequestMessageService.m +++ b/submodules/MtProtoKit/Sources/MTRequestMessageService.m @@ -117,7 +117,7 @@ if (request.requestContext.messageId != 0) { if (MTLogEnabled()) { - MTLog(@"[MTRequestMessageService#%x drop %" PRId64 "]", (int)self, request.requestContext.messageId); + MTLog(@"[MTRequestMessageService#%llx drop %" PRId64 "]", (intptr_t)self, request.requestContext.messageId); } } @@ -933,8 +933,8 @@ request.requestContext.responseMessageId = responseMessageId; return true; } else { - MTLog(@"[MTRequestMessageService#%x will not request message %" PRId64 " (transaction was not completed)]", (int)self, messageId); - MTLog(@"[MTRequestMessageService#%x but today it will]", (int)self); + MTLog(@"[MTRequestMessageService#%llx will not request message %" PRId64 " (transaction was not completed)]", (intptr_t)self, messageId); + MTLog(@"[MTRequestMessageService#%llx but today it will]", (intptr_t)self); return true; } } diff --git a/submodules/MtProtoKit/Sources/MTTcpConnection.m b/submodules/MtProtoKit/Sources/MTTcpConnection.m index e5c55842fd..b1c89c85b0 100644 --- a/submodules/MtProtoKit/Sources/MTTcpConnection.m +++ b/submodules/MtProtoKit/Sources/MTTcpConnection.m @@ -106,7 +106,7 @@ static void generate_public_key(unsigned char key[32], id pr } } -typedef enum { +/*typedef enum { HelloGenerationCommandInvalid = 0, HelloGenerationCommandString = 1, HelloGenerationCommandZero = 2, @@ -471,7 +471,7 @@ static NSData *executeGenerationCode(id provider, NSData *do ((uint8_t *)resultData.mutableBytes)[paddingLengthPosition + 1] = ((uint8_t *)&calculatedLength)[0]; return resultData; -} +}*/ @interface MTTcpConnectionData : NSObject @@ -861,14 +861,14 @@ struct ctr_state { if (MTLogEnabled()) { if (strongSelf->_socksIp != nil) { if (strongSelf->_socksUsername.length == 0) { - MTLog(@"[MTTcpConnection#%x connecting to %@:%d via %@:%d]", (int)strongSelf, strongSelf->_scheme.address.ip, (int)strongSelf->_scheme.address.port, strongSelf->_socksIp, (int)strongSelf->_socksPort); + MTLog(@"[MTTcpConnection#%llx connecting to %@:%d via %@:%d]", (intptr_t)strongSelf, strongSelf->_scheme.address.ip, (int)strongSelf->_scheme.address.port, strongSelf->_socksIp, (int)strongSelf->_socksPort); } else { - MTLog(@"[MTTcpConnection#%x connecting to %@:%d via %@:%d using %@:%@]", (int)strongSelf, strongSelf->_scheme.address.ip, (int)strongSelf->_scheme.address.port, strongSelf->_socksIp, (int)strongSelf->_socksPort, strongSelf->_socksUsername, strongSelf->_socksPassword); + MTLog(@"[MTTcpConnection#%llx connecting to %@:%d via %@:%d using %@:%@]", (intptr_t)strongSelf, strongSelf->_scheme.address.ip, (int)strongSelf->_scheme.address.port, strongSelf->_socksIp, (int)strongSelf->_socksPort, strongSelf->_socksUsername, strongSelf->_socksPassword); } } else if (strongSelf->_mtpIp != nil) { - MTLog(@"[MTTcpConnection#%x connecting to %@:%d via mtp://%@:%d:%@]", (int)strongSelf, strongSelf->_scheme.address.ip, (int)strongSelf->_scheme.address.port, strongSelf->_mtpIp, (int)strongSelf->_mtpPort, strongSelf->_mtpSecret); + MTLog(@"[MTTcpConnection#%llx connecting to %@:%d via mtp://%@:%d:%@]", (intptr_t)strongSelf, strongSelf->_scheme.address.ip, (int)strongSelf->_scheme.address.port, strongSelf->_mtpIp, (int)strongSelf->_mtpPort, strongSelf->_mtpSecret); } else { - MTLog(@"[MTTcpConnection#%x connecting to %@:%d]", (int)strongSelf, strongSelf->_scheme.address.ip, (int)strongSelf->_scheme.address.port); + MTLog(@"[MTTcpConnection#%llx connecting to %@:%d]", (intptr_t)strongSelf, strongSelf->_scheme.address.ip, (int)strongSelf->_scheme.address.port); } } @@ -1280,7 +1280,7 @@ struct ctr_state { _responseTimeoutTimer = nil; if (MTLogEnabled()) { - MTLog(@"[MTTcpConnection#%x response timeout]", (int)self); + MTLog(@"[MTTcpConnection#%llx response timeout]", (intptr_t)self); } [self closeAndNotifyWithError:true]; } @@ -1421,7 +1421,7 @@ struct ctr_state { if (resp.Reply != 0x00) { if (MTLogEnabled()) { - MTLog(@"***** %x %s: socks5 connect failed, error 0x%02x", (int)self, __PRETTY_FUNCTION__, resp.Reply); + MTLog(@"***** %llx %s: socks5 connect failed, error 0x%02x", (intptr_t)self, __PRETTY_FUNCTION__, resp.Reply); } [self closeAndNotifyWithError:true]; return; @@ -1772,7 +1772,7 @@ struct ctr_state { } else { if (length > 16 * 1024 * 1024) { if (MTLogEnabled()) { - MTLog(@"[MTTcpConnection#%x received invalid length %d]", (int)self, length); + MTLog(@"[MTTcpConnection#%llx received invalid length %d]", (intptr_t)self, length); } [self closeAndNotifyWithError:true]; } else { @@ -1848,7 +1848,7 @@ struct ctr_state { } } else if (header == 0 && packetData.length < 16) { if (MTLogEnabled()) { - MTLog(@"[MTTcpConnection#%x received nop packet]", (int)self); + MTLog(@"[MTTcpConnection#%llx received nop packet]", (intptr_t)self); } ignorePacket = true; } @@ -1907,12 +1907,12 @@ struct ctr_state { { if (error != nil) { if (MTLogEnabled()) { - MTLog(@"[MTTcpConnection#%x disconnected from %@ (%@)]", (int)self, _scheme.address.ip, error); + MTLog(@"[MTTcpConnection#%llx disconnected from %@ (%@)]", (intptr_t)self, _scheme.address.ip, error); } } else { if (MTLogEnabled()) { - MTLog(@"[MTTcpConnection#%x disconnected from %@]", (int)self, _scheme.address.ip); + MTLog(@"[MTTcpConnection#%llx disconnected from %@]", (intptr_t)self, _scheme.address.ip); } } diff --git a/submodules/MtProtoKit/Sources/MTTcpTransport.m b/submodules/MtProtoKit/Sources/MTTcpTransport.m index 3b0883b3aa..61c650e87f 100644 --- a/submodules/MtProtoKit/Sources/MTTcpTransport.m +++ b/submodules/MtProtoKit/Sources/MTTcpTransport.m @@ -573,7 +573,7 @@ static const NSTimeInterval MTTcpTransportSleepWatchdogTimeout = 60.0; if (!transportContext.didSendActualizationPingAfterConnection) { if (MTLogEnabled()) { - MTLog(@"[MTTcpTransport#%x unlocking transaction processing due to connection context update task]", (int)self); + MTLog(@"[MTTcpTransport#%llx unlocking transaction processing due to connection context update task]", (intptr_t)self); } transportContext.isWaitingForTransactionToBecomeReady = false; transportContext.transactionLockTime = 0.0; @@ -581,7 +581,7 @@ static const NSTimeInterval MTTcpTransportSleepWatchdogTimeout = 60.0; else if (CFAbsoluteTimeGetCurrent() > transportContext.transactionLockTime + 1.0) { if (MTLogEnabled()) { - MTLog(@"[MTTcpTransport#%x unlocking transaction processing due to timeout]", (int)self); + MTLog(@"[MTTcpTransport#%llx unlocking transaction processing due to timeout]", (intptr_t)self); } transportContext.isWaitingForTransactionToBecomeReady = false; transportContext.transactionLockTime = 0.0; @@ -589,7 +589,7 @@ static const NSTimeInterval MTTcpTransportSleepWatchdogTimeout = 60.0; else { if (MTLogEnabled()) { - MTLog(@"[MTTcpTransport#%x skipping transaction request]", (int)self); + MTLog(@"[MTTcpTransport#%llx skipping transaction request]", (intptr_t)self); } transportContext.requestAnotherTransactionWhenReady = true; diff --git a/submodules/TelegramCore/Sources/Network/MultipartFetch.swift b/submodules/TelegramCore/Sources/Network/MultipartFetch.swift index 0b0568b657..6ec67cecc1 100644 --- a/submodules/TelegramCore/Sources/Network/MultipartFetch.swift +++ b/submodules/TelegramCore/Sources/Network/MultipartFetch.swift @@ -364,7 +364,7 @@ private enum MultipartFetchSource { var ivOffset: Int32 = (offset / 16).bigEndian memcpy(bytes.advanced(by: partIvCount - 4), &ivOffset, 4) } - return .single(MTAesCtrDecrypt(bytes.makeData(), key, partIv)) + return .single(MTAesCtrDecrypt(bytes.makeData(), key, partIv)!) } } } diff --git a/submodules/TelegramCore/Sources/Network/Network.swift b/submodules/TelegramCore/Sources/Network/Network.swift index 16d14bf580..62b4749b69 100644 --- a/submodules/TelegramCore/Sources/Network/Network.swift +++ b/submodules/TelegramCore/Sources/Network/Network.swift @@ -493,7 +493,7 @@ func initializedNetwork(accountId: AccountRecordId, arguments: NetworkInitializa context = current context.updateApiEnvironment({ _ in return apiEnvironment}) } else { - context = MTContext(serialization: serialization, encryptionProvider: arguments.encryptionProvider, apiEnvironment: apiEnvironment, isTestingEnvironment: testingEnvironment, useTempAuthKeys: useTempAuthKeys)! + context = MTContext(serialization: serialization, encryptionProvider: arguments.encryptionProvider, apiEnvironment: apiEnvironment, isTestingEnvironment: testingEnvironment, useTempAuthKeys: useTempAuthKeys) store.contexts[key] = context } contextValue = context diff --git a/submodules/TelegramCore/Sources/SecretChats/SecretChatEncryption.swift b/submodules/TelegramCore/Sources/SecretChats/SecretChatEncryption.swift index a46edde5f6..376bca7183 100644 --- a/submodules/TelegramCore/Sources/SecretChats/SecretChatEncryption.swift +++ b/submodules/TelegramCore/Sources/SecretChats/SecretChatEncryption.swift @@ -14,7 +14,7 @@ private func messageKey(key: SecretChatKey, msgKey: UnsafeRawPointer, mode: Secr memcpy(bytes, msgKey, 16) memcpy(bytes.advanced(by: 16), key.key.memory.advanced(by: x), 32) } - let sha1A = MTSha1(sha1AData)! + let sha1A = MTSha1(sha1AData) var sha1BData = Data() sha1BData.count = 16 + 16 + 16 @@ -23,7 +23,7 @@ private func messageKey(key: SecretChatKey, msgKey: UnsafeRawPointer, mode: Secr memcpy(bytes.advanced(by: 16), msgKey, 16) memcpy(bytes.advanced(by: 16 + 16), key.key.memory.advanced(by: 48 + x), 16) } - let sha1B = MTSha1(sha1BData)! + let sha1B = MTSha1(sha1BData) var sha1CData = Data() sha1CData.count = 32 + 16 @@ -31,7 +31,7 @@ private func messageKey(key: SecretChatKey, msgKey: UnsafeRawPointer, mode: Secr memcpy(bytes, key.key.memory.advanced(by: 64 + x), 32) memcpy(bytes.advanced(by: 32), msgKey, 16) } - let sha1C = MTSha1(sha1CData)! + let sha1C = MTSha1(sha1CData) var sha1DData = Data() sha1DData.count = 16 + 32 @@ -39,7 +39,7 @@ private func messageKey(key: SecretChatKey, msgKey: UnsafeRawPointer, mode: Secr memcpy(bytes, msgKey, 16) memcpy(bytes.advanced(by: 16), key.key.memory.advanced(by: 96 + x), 32) } - let sha1D = MTSha1(sha1DData)! + let sha1D = MTSha1(sha1DData) var aesKey = Data() aesKey.count = 8 + 12 + 12 @@ -85,13 +85,13 @@ private func messageKey(key: SecretChatKey, msgKey: UnsafeRawPointer, mode: Secr sha256_a_data.append(msgKey.assumingMemoryBound(to: UInt8.self), count: 16) sha256_a_data.append(key.key.memory.assumingMemoryBound(to: UInt8.self).advanced(by: xValue), count: 36) - let sha256_a = MTSha256(sha256_a_data)! + let sha256_a = MTSha256(sha256_a_data) var sha256_b_data = Data() sha256_b_data.append(key.key.memory.assumingMemoryBound(to: UInt8.self).advanced(by: 40 + xValue), count: 36) sha256_b_data.append(msgKey.assumingMemoryBound(to: UInt8.self), count: 16) - let sha256_b = MTSha256(sha256_b_data)! + let sha256_b = MTSha256(sha256_b_data) var aesKey = Data() aesKey.append(sha256_a.subdata(in: 0 ..< (0 + 8))) @@ -136,7 +136,7 @@ func withDecryptedMessageContents(parameters: SecretChatEncryptionParameters, da return nil } - let calculatedMsgKeyData = MTSubdataSha1(decryptedData, 0, UInt(payloadLength) + 4)! + let calculatedMsgKeyData = MTSubdataSha1(decryptedData, 0, UInt(payloadLength) + 4) let msgKeyMatches = calculatedMsgKeyData.withUnsafeBytes { (bytes: UnsafePointer) -> Bool in return memcmp(bytes.advanced(by: calculatedMsgKeyData.count - 16), msgKey, 16) == 0 } @@ -184,7 +184,7 @@ func withDecryptedMessageContents(parameters: SecretChatEncryptionParameters, da keyLargeData.append(parameters.key.key.memory.assumingMemoryBound(to: UInt8.self).advanced(by: 88 + xValue), count: 32) keyLargeData.append(decryptedData) - let keyLarge = MTSha256(keyLargeData)! + let keyLarge = MTSha256(keyLargeData) let localMessageKey = keyLarge.subdata(in: 8 ..< (8 + 16)) let msgKeyData = Data(bytes: msgKey.assumingMemoryBound(to: UInt8.self), count: 16) @@ -230,7 +230,7 @@ func encryptedMessageContents(parameters: SecretChatEncryptionParameters, data: switch parameters.mode { case .v1: - var msgKey = MTSha1(payloadData)! + var msgKey = MTSha1(payloadData) msgKey.replaceSubrange(0 ..< (msgKey.count - 16), with: Data()) var randomBuf = malloc(16)! @@ -301,7 +301,7 @@ func encryptedMessageContents(parameters: SecretChatEncryptionParameters, data: keyData.append(decryptedData) - let keyLarge = MTSha256(keyData)! + let keyLarge = MTSha256(keyData) let msgKey = keyLarge.subdata(in: 8 ..< (8 + 16)) diff --git a/submodules/TelegramCore/Sources/SecretChats/SecretChatRekeySession.swift b/submodules/TelegramCore/Sources/SecretChats/SecretChatRekeySession.swift index 35aa275bd8..2230accf37 100644 --- a/submodules/TelegramCore/Sources/SecretChats/SecretChatRekeySession.swift +++ b/submodules/TelegramCore/Sources/SecretChats/SecretChatRekeySession.swift @@ -59,7 +59,7 @@ func secretChatAdvanceRekeySessionIfNeeded(encryptionProvider: EncryptionProvide } } - let keyHash = MTSha1(key)! + let keyHash = MTSha1(key) var keyFingerprint: Int64 = 0 keyHash.withUnsafeBytes { (bytes: UnsafePointer) -> Void in diff --git a/submodules/TelegramCore/Sources/SecretChats/UpdateSecretChat.swift b/submodules/TelegramCore/Sources/SecretChats/UpdateSecretChat.swift index 95d67a7b84..5aa27b54f2 100644 --- a/submodules/TelegramCore/Sources/SecretChats/UpdateSecretChat.swift +++ b/submodules/TelegramCore/Sources/SecretChats/UpdateSecretChat.swift @@ -40,7 +40,7 @@ func updateSecretChat(encryptionProvider: EncryptionProvider, accountPeerId: Pee } } - let keyHash = MTSha1(key)! + let keyHash = MTSha1(key) var keyFingerprint: Int64 = 0 keyHash.withUnsafeBytes { (bytes: UnsafePointer) -> Void in diff --git a/submodules/TelegramCore/Sources/State/CallSessionManager.swift b/submodules/TelegramCore/Sources/State/CallSessionManager.swift index 42352162fa..4d884ade9f 100644 --- a/submodules/TelegramCore/Sources/State/CallSessionManager.swift +++ b/submodules/TelegramCore/Sources/State/CallSessionManager.swift @@ -685,14 +685,14 @@ private final class CallSessionManagerContext { } } - let keyHash = MTSha1(key)! + let keyHash = MTSha1(key) var keyId: Int64 = 0 keyHash.withUnsafeBytes { (bytes: UnsafePointer) -> Void in memcpy(&keyId, bytes.advanced(by: keyHash.count - 8), 8) } - let keyVisualHash = MTSha256(key + gA)! + let keyVisualHash = MTSha256(key + gA) context.state = .confirming(id: id, accessHash: accessHash, key: key, keyId: keyId, keyVisualHash: keyVisualHash, disposable: (confirmCallSession(network: self.network, stableId: id, accessHash: accessHash, gA: gA, keyFingerprint: keyId, maxLayer: self.maxLayer, versions: selectedVersions) |> deliverOnMainQueue).start(next: { [weak self] updatedCall in if let strongSelf = self, let context = strongSelf.contexts[internalId], case .confirming = context.state { @@ -888,18 +888,18 @@ private final class CallSessionManagerContext { } } - let keyHash = MTSha1(key)! + let keyHash = MTSha1(key) var keyId: Int64 = 0 keyHash.withUnsafeBytes { (bytes: UnsafePointer) -> Void in memcpy(&keyId, bytes.advanced(by: keyHash.count - 8), 8) } - if MTSha256(gA)! != gAHash { + if MTSha256(gA) != gAHash { return nil } - let keyVisualHash = MTSha256(key + gA)! + let keyVisualHash = MTSha256(key + gA) return (key, keyId, keyVisualHash) } @@ -1161,7 +1161,7 @@ private func requestCallSession(postbox: Postbox, network: Network, peerId: Peer return .single(.failed(.generic)) } - let gAHash = MTSha256(ga)! + let gAHash = MTSha256(ga) var callFlags: Int32 = 0 if isVideo { diff --git a/submodules/TelegramCore/Sources/State/ManagedSecretChatOutgoingOperations.swift b/submodules/TelegramCore/Sources/State/ManagedSecretChatOutgoingOperations.swift index e498b2cc0c..540b4d33f0 100644 --- a/submodules/TelegramCore/Sources/State/ManagedSecretChatOutgoingOperations.swift +++ b/submodules/TelegramCore/Sources/State/ManagedSecretChatOutgoingOperations.swift @@ -219,7 +219,7 @@ private func initialHandshakeAccept(postbox: Postbox, network: Network, peerId: } } - let keyHash = MTSha1(key)! + let keyHash = MTSha1(key) var keyFingerprint: Int64 = 0 keyHash.withUnsafeBytes { (bytes: UnsafePointer) -> Void in @@ -321,7 +321,7 @@ private func pfsAcceptKey(postbox: Postbox, network: Network, peerId: PeerId, la } } - let keyHash = MTSha1(key)! + let keyHash = MTSha1(key) var keyFingerprint: Int64 = 0 keyHash.withUnsafeBytes { (bytes: UnsafePointer) -> Void in diff --git a/submodules/TelegramCore/Sources/State/Serialization.swift b/submodules/TelegramCore/Sources/State/Serialization.swift index 96684c4e81..29367f0741 100644 --- a/submodules/TelegramCore/Sources/State/Serialization.swift +++ b/submodules/TelegramCore/Sources/State/Serialization.swift @@ -258,7 +258,7 @@ public class Serialization: NSObject, MTSerialization { let restrictToTcp = (flags & (1 << 2)) != 0 let isCdn = (flags & (1 << 3)) != 0 let preferForProxy = (flags & (1 << 4)) != 0 - addressDict[id as NSNumber]!.append(MTDatacenterAddress(ip: ipAddress, port: UInt16(port), preferForMedia: preferForMedia, restrictToTcp: restrictToTcp, cdn: isCdn, preferForProxy: preferForProxy, secret: secret?.makeData())!) + addressDict[id as NSNumber]!.append(MTDatacenterAddress(ip: ipAddress, port: UInt16(port), preferForMedia: preferForMedia, restrictToTcp: restrictToTcp, cdn: isCdn, preferForProxy: preferForProxy, secret: secret?.makeData())) break } } diff --git a/submodules/TelegramUI/Sources/ManageSharedAccountInfo.swift b/submodules/TelegramUI/Sources/ManageSharedAccountInfo.swift index 7745eb5493..dcf97d441c 100644 --- a/submodules/TelegramUI/Sources/ManageSharedAccountInfo.swift +++ b/submodules/TelegramUI/Sources/ManageSharedAccountInfo.swift @@ -24,9 +24,9 @@ private func accountInfo(account: Account) -> Signal if let authInfo = context.authInfoForDatacenter(withId: id, selector: .persistent), let authKey = authInfo.authKey { let transportScheme = context.chooseTransportSchemeForConnection(toDatacenterId: id, schemes: context.transportSchemesForDatacenter(withId: id, media: true, enforceMedia: false, isProxy: false)) var addressList: [AccountDatacenterAddress] = [] - if let transportScheme = transportScheme, let address = transportScheme.address, let host = address.host { - let secret: Data? = address.secret - addressList.append(AccountDatacenterAddress(host: host, port: Int32(address.port), isMedia: address.preferForMedia, secret: secret)) + if let transportScheme = transportScheme, let host = transportScheme.address.host { + let secret: Data? = transportScheme.address.secret + addressList.append(AccountDatacenterAddress(host: host, port: Int32(transportScheme.address.port), isMedia: transportScheme.address.preferForMedia, secret: secret)) } var ephemeralMainKey: AccountDatacenterKey?