diff --git a/LibSession-Util b/LibSession-Util index ea1b1dfcf..b20b0ffce 160000 --- a/LibSession-Util +++ b/LibSession-Util @@ -1 +1 @@ -Subproject commit ea1b1dfcf6b0a6ad6e2359df3c296935e695afc8 +Subproject commit b20b0ffce08da126edbad7693a4411170a00b0ce diff --git a/SessionSnodeKit/LibSession/LibSession+Networking.swift b/SessionSnodeKit/LibSession/LibSession+Networking.swift index 1e6e34b1b..0089337e9 100644 --- a/SessionSnodeKit/LibSession/LibSession+Networking.swift +++ b/SessionSnodeKit/LibSession/LibSession+Networking.swift @@ -395,6 +395,14 @@ public extension LibSession { private static func updateNetworkStatus(cStatus: CONNECTION_STATUS) { let status: NetworkStatus = NetworkStatus(status: cStatus) + guard status == .disconnected || !isSuspended.wrappedValue else { + Log.warn("[LibSession] Attempted to update network status to '\(status)' for suspended network, closing connections again.") + + guard let network: UnsafeMutablePointer = networkCache.wrappedValue else { return } + network_close_connections(network) + return + } + // Dispatch async so we don't hold up the libSession thread that triggered the update DispatchQueue.global(qos: .default).async { Log.info("Network status changed to: \(status)") diff --git a/SessionUtilitiesKit/Combine/RetryWithDependencies.swift b/SessionUtilitiesKit/Combine/RetryWithDependencies.swift index 407296a8d..9057b5646 100644 --- a/SessionUtilitiesKit/Combine/RetryWithDependencies.swift +++ b/SessionUtilitiesKit/Combine/RetryWithDependencies.swift @@ -15,8 +15,13 @@ extension Publishers { func receive(subscriber: S) where S : Subscriber, Failure == S.Failure, Output == S.Input { upstream .catch { [upstream, retries, dependencies] error -> AnyPublisher in - guard retries > 0 else { - return Fail(error: error).eraseToAnyPublisher() + guard retries > 0 else { return Fail(error: error).eraseToAnyPublisher() } + + // If we got any of the following errors then we shouldn't bother retrying (the request + // isn't going to work) + switch error as Error { + case NetworkError.suspended: return Fail(error: error).eraseToAnyPublisher() + default: break } return RetryWithDependencies(upstream: upstream, retries: retries - 1, dependencies: dependencies) diff --git a/SessionUtilitiesKit/Crypto/Mnemonic.swift b/SessionUtilitiesKit/Crypto/Mnemonic.swift index 9dd184e5e..32aad3b40 100644 --- a/SessionUtilitiesKit/Crypto/Mnemonic.swift +++ b/SessionUtilitiesKit/Crypto/Mnemonic.swift @@ -120,7 +120,7 @@ public enum Mnemonic { public static func decode(mnemonic: String, language: Language = .english) throws -> String { var words: [String] = mnemonic .components(separatedBy: .whitespacesAndNewlines) - .map { $0.trimmingCharacters(in: .whitespacesAndNewlines) } + .filter { !$0.isEmpty } let truncatedWordSet: [String] = language.loadTruncatedWordSet() let prefixLength: Int = language.prefixLength var result = ""