mirror of
https://github.com/passepartoutvpn/passepartout-apple.git
synced 2025-02-21 15:22:06 +00:00
Make proxy configuration a 3-state
- Manual: server, port - PAC: set PAC URL - Disabled BEWARE: breaking change in Profile.
This commit is contained in:
parent
9055fec394
commit
addbc181fd
@ -104,3 +104,18 @@ extension Network.Choice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension Network.ProxySettings.ConfigurationType {
|
||||||
|
var localizedDescription: String {
|
||||||
|
switch self {
|
||||||
|
case .manual:
|
||||||
|
return L10n.Global.Strings.manual
|
||||||
|
|
||||||
|
case .pac:
|
||||||
|
return Unlocalized.Network.proxyAutoConfiguration
|
||||||
|
|
||||||
|
case .disabled:
|
||||||
|
return L10n.Global.Strings.disabled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -215,9 +215,16 @@ extension NetworkSettingsView {
|
|||||||
Toggle(L10n.Global.Strings.automatic, isOn: $settings.isAutomaticProxy.animation())
|
Toggle(L10n.Global.Strings.automatic, isOn: $settings.isAutomaticProxy.animation())
|
||||||
|
|
||||||
if !settings.isAutomaticProxy {
|
if !settings.isAutomaticProxy {
|
||||||
Toggle(L10n.Global.Strings.enabled, isOn: $settings.proxy.isProxyEnabled.animation())
|
themeTextPicker(
|
||||||
|
// FIXME: l10n, refactor string id to "global.strings.configuration"
|
||||||
if settings.proxy.isProxyEnabled {
|
L10n.Profile.Sections.Configuration.header,
|
||||||
|
selection: $settings.proxy.configurationType,
|
||||||
|
values: Network.ProxySettings.availableConfigurationTypes,
|
||||||
|
description: \.localizedDescription
|
||||||
|
)
|
||||||
|
|
||||||
|
switch settings.proxy.configurationType {
|
||||||
|
case .manual:
|
||||||
TextField(Unlocalized.Placeholders.address, text: $settings.proxy.proxyAddress ?? "")
|
TextField(Unlocalized.Placeholders.address, text: $settings.proxy.proxyAddress ?? "")
|
||||||
.themeIPAddress(settings.proxy.proxyAddress)
|
.themeIPAddress(settings.proxy.proxyAddress)
|
||||||
.withLeadingText(L10n.Global.Strings.address)
|
.withLeadingText(L10n.Global.Strings.address)
|
||||||
@ -226,13 +233,16 @@ extension NetworkSettingsView {
|
|||||||
.themeSocketPort()
|
.themeSocketPort()
|
||||||
.withLeadingText(L10n.Global.Strings.port)
|
.withLeadingText(L10n.Global.Strings.port)
|
||||||
|
|
||||||
|
case .pac:
|
||||||
TextField(Unlocalized.Placeholders.pacURL, text: $settings.proxy.proxyAutoConfigurationURL.toString())
|
TextField(Unlocalized.Placeholders.pacURL, text: $settings.proxy.proxyAutoConfigurationURL.toString())
|
||||||
.themeURL(settings.proxy.proxyAutoConfigurationURL?.absoluteString)
|
.themeURL(settings.proxy.proxyAutoConfigurationURL?.absoluteString)
|
||||||
.withLeadingText(Unlocalized.Network.proxyAutoConfiguration)
|
|
||||||
|
case .disabled:
|
||||||
|
EmptyView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !settings.isAutomaticProxy && settings.proxy.isProxyEnabled {
|
if !settings.isAutomaticProxy && settings.proxy.configurationType != .disabled {
|
||||||
proxyManualBypassDomains
|
proxyManualBypassDomains
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,17 +113,27 @@ extension OpenVPN.ConfigurationBuilder {
|
|||||||
break
|
break
|
||||||
|
|
||||||
case .manual:
|
case .manual:
|
||||||
isProxyEnabled = settings.isProxyEnabled
|
isProxyEnabled = settings.configurationType != .disabled
|
||||||
|
|
||||||
if settings.isProxyEnabled {
|
switch settings.configurationType {
|
||||||
|
case .manual:
|
||||||
if let proxyServer = settings.proxyServer {
|
if let proxyServer = settings.proxyServer {
|
||||||
httpProxy = proxyServer
|
httpProxy = proxyServer
|
||||||
httpsProxy = proxyServer
|
httpsProxy = proxyServer
|
||||||
} else if let pac = settings.proxyAutoConfigurationURL {
|
proxyAutoConfigurationURL = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
case .pac:
|
||||||
|
if let pac = settings.proxyAutoConfigurationURL {
|
||||||
|
httpProxy = nil
|
||||||
|
httpsProxy = nil
|
||||||
proxyAutoConfigurationURL = pac
|
proxyAutoConfigurationURL = pac
|
||||||
}
|
}
|
||||||
proxyBypassDomains = settings.proxyBypassDomains.filter { !$0.isEmpty }
|
|
||||||
|
case .disabled:
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
proxyBypassDomains = settings.proxyBypassDomains.filter { !$0.isEmpty }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,9 +106,17 @@ extension Network {
|
|||||||
|
|
||||||
extension Network {
|
extension Network {
|
||||||
public struct ProxySettings: Codable, Equatable, NetworkChoiceRepresentable, ProxySettingsProviding {
|
public struct ProxySettings: Codable, Equatable, NetworkChoiceRepresentable, ProxySettingsProviding {
|
||||||
|
public enum ConfigurationType: String, Codable {
|
||||||
|
case manual
|
||||||
|
|
||||||
|
case pac
|
||||||
|
|
||||||
|
case disabled
|
||||||
|
}
|
||||||
|
|
||||||
public var choice: Network.Choice
|
public var choice: Network.Choice
|
||||||
|
|
||||||
public var isProxyEnabled = true
|
public var configurationType: ConfigurationType = .manual
|
||||||
|
|
||||||
public var proxyAddress: String?
|
public var proxyAddress: String?
|
||||||
|
|
||||||
|
@ -39,6 +39,14 @@ extension Network.DNSSettings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension Network.ProxySettings {
|
||||||
|
public static let availableConfigurationTypes: [ConfigurationType] = [
|
||||||
|
.manual,
|
||||||
|
.pac,
|
||||||
|
.disabled
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
extension Network.MTUSettings {
|
extension Network.MTUSettings {
|
||||||
public static let availableBytes: [Int] = [0, 1500, 1400, 1300, 1200]
|
public static let availableBytes: [Int] = [0, 1500, 1400, 1300, 1200]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user