Implement --route-nopull via TunnelKit (#230)

Use it internally to override server-pushed settings.
This commit is contained in:
Davide De Rosa 2022-10-13 19:09:51 +02:00 committed by GitHub
parent 5627e6c4a9
commit f95e4f228d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 44 additions and 2 deletions

View File

@ -51,7 +51,7 @@
"repositoryURL": "https://github.com/passepartoutvpn/tunnelkit",
"state": {
"branch": null,
"revision": "3a54295ed9d2b71057fdeef752144beea66e31f2",
"revision": "8df7e90c95dc1af66b27990b5f00ba21120e9f9d",
"version": null
}
},

View File

@ -43,6 +43,8 @@ extension EndpointAdvancedView {
if isServerPushed {
ipv4Section
ipv6Section
} else {
pullSection(configuration: cfg)
}
dnsSection(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 {
configuration.communicationSettings.map { settings in
Section {

View File

@ -502,6 +502,8 @@ internal enum L10n {
internal static let proxy = L10n.tr("Localizable", "global.strings.proxy", fallback: "Proxy")
/// 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
internal static let reconnect = L10n.tr("Localizable", "global.strings.reconnect", fallback: "Reconnect")
/// Rename

View File

@ -120,3 +120,18 @@ extension Bool {
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
}
}
}

View File

@ -50,6 +50,7 @@
"global.strings.connect" = "Connect";
"global.strings.disconnect" = "Disconnect";
"global.strings.download" = "Download";
"global.strings.pull" = "Pull";
"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";

View File

@ -24,7 +24,7 @@ let package = Package(
// Dependencies declare other packages that this package depends on.
// .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", .revision("3a54295ed9d2b71057fdeef752144beea66e31f2")),
.package(name: "TunnelKit", url: "https://github.com/passepartoutvpn/tunnelkit", .revision("8df7e90c95dc1af66b27990b5f00ba21120e9f9d")),
// .package(name: "TunnelKit", path: "../../tunnelkit"),
.package(url: "https://github.com/zoul/generic-json-swift", from: "2.0.0"),
.package(url: "https://github.com/SwiftyBeaver/SwiftyBeaver", from: "1.9.0")

View File

@ -82,6 +82,7 @@ extension OpenVPN.ConfigurationBuilder {
break
case .manual:
appendNoPullMask(.routes)
var policies: [OpenVPN.RoutingPolicy] = []
if settings.isDefaultIPv4 {
policies.append(.IPv4)
@ -99,6 +100,7 @@ extension OpenVPN.ConfigurationBuilder {
break
case .manual:
appendNoPullMask(.dns)
let isDNSEnabled = settings.configurationType != .disabled
self.isDNSEnabled = isDNSEnabled
@ -131,6 +133,7 @@ extension OpenVPN.ConfigurationBuilder {
break
case .manual:
appendNoPullMask(.proxy)
isProxyEnabled = settings.configurationType != .disabled
switch settings.configurationType {
@ -161,4 +164,11 @@ extension OpenVPN.ConfigurationBuilder {
mtu = settings.mtuBytes
}
}
private mutating func appendNoPullMask(_ mask: OpenVPN.PullMask) {
if noPullMask == nil {
noPullMask = []
}
noPullMask?.append(mask)
}
}