mirror of
https://github.com/GLEGram/GLEGram-iOS.git
synced 2026-04-27 21:37:16 +02:00
4647310322
Based on Swiftgram 12.5 (Telegram iOS 12.5). All GLEGram features ported and organized in GLEGram/ folder. Features: Ghost Mode, Saved Deleted Messages, Content Protection Bypass, Font Replacement, Fake Profile, Chat Export, Plugin System, and more. See CHANGELOG_12.5.md for full details.
33 lines
1.4 KiB
Swift
33 lines
1.4 KiB
Swift
import Foundation
|
|
import Postbox
|
|
import SwiftSignalKit
|
|
import MtProtoKit
|
|
|
|
public func updateProxySettingsInteractively(accountManager: AccountManager<TelegramAccountManagerTypes>, _ f: @escaping (ProxySettings) -> ProxySettings) -> Signal<Bool, NoError> {
|
|
return accountManager.transaction { transaction -> Bool in
|
|
return updateProxySettingsInteractively(transaction: transaction, f)
|
|
}
|
|
}
|
|
|
|
extension ProxyServerSettings {
|
|
var mtProxySettings: MTSocksProxySettings {
|
|
switch self.connection {
|
|
case let .socks5(username, password):
|
|
return MTSocksProxySettings(ip: self.host, port: UInt16(clamping: self.port), username: username, password: password, secret: nil)
|
|
case let .mtp(secret):
|
|
return MTSocksProxySettings(ip: self.host, port: UInt16(clamping: self.port), username: nil, password: nil, secret: secret)
|
|
}
|
|
}
|
|
}
|
|
|
|
public func updateProxySettingsInteractively(transaction: AccountManagerModifier<TelegramAccountManagerTypes>, _ f: @escaping (ProxySettings) -> ProxySettings) -> Bool {
|
|
var hasChanges = false
|
|
transaction.updateSharedData(SharedDataKeys.proxySettings, { current in
|
|
let previous = current?.get(ProxySettings.self) ?? ProxySettings.defaultSettings
|
|
let updated = f(previous)
|
|
hasChanges = previous != updated
|
|
return PreferencesEntry(updated)
|
|
})
|
|
return hasChanges
|
|
}
|