diff --git a/LibSession-Util b/LibSession-Util index 9d1b1f7e8..d6147ef38 160000 --- a/LibSession-Util +++ b/LibSession-Util @@ -1 +1 @@ -Subproject commit 9d1b1f7e87b1061b051f2fe5e729135a6fd8c299 +Subproject commit d6147ef385e39d3fae64611dcf16ac1e14bab333 diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index 55f394b15..0434bafb9 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -8109,7 +8109,7 @@ CLANG_WARN__ARC_BRIDGE_CAST_NONARC = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 464; + CURRENT_PROJECT_VERSION = 465; ENABLE_BITCODE = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -8187,7 +8187,7 @@ CLANG_WARN__ARC_BRIDGE_CAST_NONARC = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "iPhone Distribution"; - CURRENT_PROJECT_VERSION = 464; + CURRENT_PROJECT_VERSION = 465; ENABLE_BITCODE = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_NO_COMMON_BLOCKS = YES; diff --git a/SessionSnodeKit/LibSession/LibSession+Networking.swift b/SessionSnodeKit/LibSession/LibSession+Networking.swift index 0c6173c4a..125fd1ac0 100644 --- a/SessionSnodeKit/LibSession/LibSession+Networking.swift +++ b/SessionSnodeKit/LibSession/LibSession+Networking.swift @@ -193,7 +193,7 @@ public extension LibSession { guard nodesSize > 0, let cSwarm: UnsafeMutablePointer = nodesPtr - else { return CallbackWrapper.run(ctx, .failure(SnodeAPIError.unableToRetrieveSwarm)) } + else { return CallbackWrapper.run(ctx, .failure(SnodeAPIError.ranOutOfRandomSnodes(nil))) } var nodes: Set = [] (0..= count else { throw SnodeAPIError.unableToRetrieveSwarm } + guard nodes.count >= count else { throw SnodeAPIError.ranOutOfRandomSnodes(nil) } return nodes } @@ -401,6 +401,10 @@ public extension LibSession { Log.warn("[LibSession] Attempted to access suspended network.") return Fail(error: NetworkError.suspended).eraseToAnyPublisher() } + guard Singleton.hasAppContext && (Singleton.appContext.isMainApp || Singleton.appContext.isShareExtension) else { + Log.warn("[LibSession] Attempted to create network in invalid extension.") + return Fail(error: NetworkError.suspended).eraseToAnyPublisher() + } guard networkCache.wrappedValue == nil else { return Just(networkCache.wrappedValue) diff --git a/SessionSnodeKit/Types/SnodeAPIError.swift b/SessionSnodeKit/Types/SnodeAPIError.swift index b101cf2c6..a9ed6a7f0 100644 --- a/SessionSnodeKit/Types/SnodeAPIError.swift +++ b/SessionSnodeKit/Types/SnodeAPIError.swift @@ -57,9 +57,7 @@ public enum SnodeAPIError: Error, CustomStringConvertible { case .ranOutOfRandomSnodes(let maybeError): switch maybeError { case .none: return "Ran out of random snodes (SnodeAPIError.ranOutOfRandomSnodes(nil))." - case .some(let error): - let errorDesc = "\(error)".trimmingCharacters(in: CharacterSet(["."])) - return "Ran out of random snodes (SnodeAPIError.ranOutOfRandomSnodes(\(errorDesc))." + case .some(let error): return "Ran out of random snodes (SnodeAPIError.ranOutOfRandomSnodes(\(error))." } // ONS