Implement --route-nopull via TunnelKit (#230)
Use it internally to override server-pushed settings.
This commit is contained in:
parent
5627e6c4a9
commit
f95e4f228d
|
@ -51,7 +51,7 @@
|
||||||
"repositoryURL": "https://github.com/passepartoutvpn/tunnelkit",
|
"repositoryURL": "https://github.com/passepartoutvpn/tunnelkit",
|
||||||
"state": {
|
"state": {
|
||||||
"branch": null,
|
"branch": null,
|
||||||
"revision": "3a54295ed9d2b71057fdeef752144beea66e31f2",
|
"revision": "8df7e90c95dc1af66b27990b5f00ba21120e9f9d",
|
||||||
"version": null
|
"version": null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -43,6 +43,8 @@ extension EndpointAdvancedView {
|
||||||
if isServerPushed {
|
if isServerPushed {
|
||||||
ipv4Section
|
ipv4Section
|
||||||
ipv6Section
|
ipv6Section
|
||||||
|
} else {
|
||||||
|
pullSection(configuration: cfg)
|
||||||
}
|
}
|
||||||
dnsSection(configuration: cfg)
|
dnsSection(configuration: cfg)
|
||||||
proxySection(configuration: cfg)
|
proxySection(configuration: cfg)
|
||||||
|
@ -111,6 +113,18 @@ extension EndpointAdvancedView.OpenVPNView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func pullSection(configuration: OpenVPN.Configuration) -> some View {
|
||||||
|
configuration.pullMask.map { mask in
|
||||||
|
Section {
|
||||||
|
ForEach(mask, id: \.self) {
|
||||||
|
Text($0.localizedDescription)
|
||||||
|
}
|
||||||
|
} header: {
|
||||||
|
Text(L10n.Global.Strings.pull)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func communicationSection(configuration: OpenVPN.Configuration) -> some View {
|
private func communicationSection(configuration: OpenVPN.Configuration) -> some View {
|
||||||
configuration.communicationSettings.map { settings in
|
configuration.communicationSettings.map { settings in
|
||||||
Section {
|
Section {
|
||||||
|
|
|
@ -502,6 +502,8 @@ internal enum L10n {
|
||||||
internal static let proxy = L10n.tr("Localizable", "global.strings.proxy", fallback: "Proxy")
|
internal static let proxy = L10n.tr("Localizable", "global.strings.proxy", fallback: "Proxy")
|
||||||
/// Public key
|
/// Public key
|
||||||
internal static let publicKey = L10n.tr("Localizable", "global.strings.public_key", fallback: "Public key")
|
internal static let publicKey = L10n.tr("Localizable", "global.strings.public_key", fallback: "Public key")
|
||||||
|
/// Pull
|
||||||
|
internal static let pull = L10n.tr("Localizable", "global.strings.pull", fallback: "Pull")
|
||||||
/// Reconnect
|
/// Reconnect
|
||||||
internal static let reconnect = L10n.tr("Localizable", "global.strings.reconnect", fallback: "Reconnect")
|
internal static let reconnect = L10n.tr("Localizable", "global.strings.reconnect", fallback: "Reconnect")
|
||||||
/// Rename
|
/// Rename
|
||||||
|
|
|
@ -120,3 +120,18 @@ extension Bool {
|
||||||
return self ? V.enabled : V.disabled
|
return self ? V.enabled : V.disabled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension OpenVPN.PullMask {
|
||||||
|
var localizedDescription: String {
|
||||||
|
switch self {
|
||||||
|
case .routes:
|
||||||
|
return L10n.Endpoint.Advanced.Openvpn.Items.Route.caption
|
||||||
|
|
||||||
|
case .dns:
|
||||||
|
return Unlocalized.Network.dns
|
||||||
|
|
||||||
|
case .proxy:
|
||||||
|
return L10n.Global.Strings.proxy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
"global.strings.connect" = "Connect";
|
"global.strings.connect" = "Connect";
|
||||||
"global.strings.disconnect" = "Disconnect";
|
"global.strings.disconnect" = "Disconnect";
|
||||||
"global.strings.download" = "Download";
|
"global.strings.download" = "Download";
|
||||||
|
"global.strings.pull" = "Pull";
|
||||||
|
|
||||||
"global.messages.email_not_configured" = "No e-mail account is configured.";
|
"global.messages.email_not_configured" = "No e-mail account is configured.";
|
||||||
"global.messages.share" = "Passepartout is a user-friendly, open source OpenVPN / WireGuard client for iOS and macOS";
|
"global.messages.share" = "Passepartout is a user-friendly, open source OpenVPN / WireGuard client for iOS and macOS";
|
||||||
|
|
|
@ -24,7 +24,7 @@ let package = Package(
|
||||||
// Dependencies declare other packages that this package depends on.
|
// Dependencies declare other packages that this package depends on.
|
||||||
// .package(url: /* package url */, from: "1.0.0"),
|
// .package(url: /* package url */, from: "1.0.0"),
|
||||||
// .package(name: "TunnelKit", url: "https://github.com/passepartoutvpn/tunnelkit", from: "5.0.0"),
|
// .package(name: "TunnelKit", url: "https://github.com/passepartoutvpn/tunnelkit", from: "5.0.0"),
|
||||||
.package(name: "TunnelKit", url: "https://github.com/passepartoutvpn/tunnelkit", .revision("3a54295ed9d2b71057fdeef752144beea66e31f2")),
|
.package(name: "TunnelKit", url: "https://github.com/passepartoutvpn/tunnelkit", .revision("8df7e90c95dc1af66b27990b5f00ba21120e9f9d")),
|
||||||
// .package(name: "TunnelKit", path: "../../tunnelkit"),
|
// .package(name: "TunnelKit", path: "../../tunnelkit"),
|
||||||
.package(url: "https://github.com/zoul/generic-json-swift", from: "2.0.0"),
|
.package(url: "https://github.com/zoul/generic-json-swift", from: "2.0.0"),
|
||||||
.package(url: "https://github.com/SwiftyBeaver/SwiftyBeaver", from: "1.9.0")
|
.package(url: "https://github.com/SwiftyBeaver/SwiftyBeaver", from: "1.9.0")
|
||||||
|
|
|
@ -82,6 +82,7 @@ extension OpenVPN.ConfigurationBuilder {
|
||||||
break
|
break
|
||||||
|
|
||||||
case .manual:
|
case .manual:
|
||||||
|
appendNoPullMask(.routes)
|
||||||
var policies: [OpenVPN.RoutingPolicy] = []
|
var policies: [OpenVPN.RoutingPolicy] = []
|
||||||
if settings.isDefaultIPv4 {
|
if settings.isDefaultIPv4 {
|
||||||
policies.append(.IPv4)
|
policies.append(.IPv4)
|
||||||
|
@ -99,6 +100,7 @@ extension OpenVPN.ConfigurationBuilder {
|
||||||
break
|
break
|
||||||
|
|
||||||
case .manual:
|
case .manual:
|
||||||
|
appendNoPullMask(.dns)
|
||||||
let isDNSEnabled = settings.configurationType != .disabled
|
let isDNSEnabled = settings.configurationType != .disabled
|
||||||
self.isDNSEnabled = isDNSEnabled
|
self.isDNSEnabled = isDNSEnabled
|
||||||
|
|
||||||
|
@ -131,6 +133,7 @@ extension OpenVPN.ConfigurationBuilder {
|
||||||
break
|
break
|
||||||
|
|
||||||
case .manual:
|
case .manual:
|
||||||
|
appendNoPullMask(.proxy)
|
||||||
isProxyEnabled = settings.configurationType != .disabled
|
isProxyEnabled = settings.configurationType != .disabled
|
||||||
|
|
||||||
switch settings.configurationType {
|
switch settings.configurationType {
|
||||||
|
@ -161,4 +164,11 @@ extension OpenVPN.ConfigurationBuilder {
|
||||||
mtu = settings.mtuBytes
|
mtu = settings.mtuBytes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private mutating func appendNoPullMask(_ mask: OpenVPN.PullMask) {
|
||||||
|
if noPullMask == nil {
|
||||||
|
noPullMask = []
|
||||||
|
}
|
||||||
|
noPullMask?.append(mask)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue