diff --git a/CHANGELOG.md b/CHANGELOG.md index 186dbc25..700f49c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - OpenVPN: Tunnel dying prematurely. [tunnelkit#289](https://github.com/passepartoutvpn/tunnelkit/issues/289), [#237](https://github.com/passepartoutvpn/passepartout-apple/issues/237) - OpenVPN: Local network settings being ignored. [tunnelkit#290](https://github.com/passepartoutvpn/tunnelkit/issues/290) +- OpenVPN: Routes from configuration file are ignored. [tunnelkit#278](https://github.com/passepartoutvpn/tunnelkit/issues/278) - OpenVPN: Parse IPv6 endpoints properly. [tunnelkit#294](https://github.com/passepartoutvpn/tunnelkit/issues/294) - Restore "Reconnect" action in profiles. [#232](https://github.com/passepartoutvpn/passepartout-apple/pull/232) - Systematic uninstallation of VPN profile if any IAP was refunded. [#238](https://github.com/passepartoutvpn/passepartout-apple/issues/238) diff --git a/Passepartout.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Passepartout.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index a0a071d2..ca6bdda0 100644 --- a/Passepartout.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Passepartout.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -51,7 +51,7 @@ "repositoryURL": "https://github.com/passepartoutvpn/tunnelkit", "state": { "branch": null, - "revision": "8ac21771e347f700ecd05e974df1a4ebf954a6df", + "revision": "cae371bb400ad3de9bc59f96c18a091fb577ac44", "version": null } }, diff --git a/Passepartout/App/Extensions/TunnelKit+Identifiable.swift b/Passepartout/App/Extensions/TunnelKit+Identifiable.swift index 2e73dc4d..cea93703 100644 --- a/Passepartout/App/Extensions/TunnelKit+Identifiable.swift +++ b/Passepartout/App/Extensions/TunnelKit+Identifiable.swift @@ -34,12 +34,12 @@ extension Endpoint: Identifiable { extension IPv4Settings.Route: Identifiable { public var id: String { - "\(destination):\(mask):\(gateway)" + "\(destination):\(mask):\(gateway ?? "*")" } } extension IPv6Settings.Route: Identifiable { public var id: String { - "\(destination):\(prefixLength):\(gateway)" + "\(destination):\(prefixLength):\(gateway ?? "*")" } } diff --git a/Passepartout/App/Views/EndpointAdvancedView+OpenVPN.swift b/Passepartout/App/Views/EndpointAdvancedView+OpenVPN.swift index e391555c..ac5320b8 100644 --- a/Passepartout/App/Views/EndpointAdvancedView+OpenVPN.swift +++ b/Passepartout/App/Views/EndpointAdvancedView+OpenVPN.swift @@ -40,12 +40,9 @@ extension EndpointAdvancedView { var body: some View { List { let cfg = builder.build() - if isServerPushed { - ipv4Section - ipv6Section - } else { - pullSection(configuration: cfg) - } + ipv4Section + ipv6Section + pullSection(configuration: cfg) dnsSection(configuration: cfg) proxySection(configuration: cfg) if !isReadonly { @@ -65,23 +62,28 @@ extension EndpointAdvancedView { } extension EndpointAdvancedView.OpenVPNView { + + @ViewBuilder private var ipv4Section: some View { - builder.ipv4.map { cfg in + if builder.ipv4 != nil || builder.routes4 != nil { Section { - themeLongContentLinkDefault( - L10n.Global.Strings.address, - content: .constant(builder.ipv4.localizedAddress) - ) - themeLongContentLinkDefault( - L10n.NetworkSettings.Gateway.title, - content: .constant(builder.ipv4.localizedDefaultGateway) - ) - - ForEach(cfg.routes, id: \.self) { route in + if let settings = builder.ipv4 { themeLongContentLinkDefault( - L10n.Endpoint.Advanced.Openvpn.Items.Route.caption, - content: .constant(route.localizedDescription) + L10n.Global.Strings.address, + content: .constant(settings.localizedAddress) ) + themeLongContentLinkDefault( + L10n.NetworkSettings.Gateway.title, + content: .constant(settings.localizedDefaultGateway) + ) + } + builder.routes4.map { routes in + ForEach(routes, id: \.self) { route in + themeLongContentLinkDefault( + L10n.Endpoint.Advanced.Openvpn.Items.Route.caption, + content: .constant(route.localizedDescription) + ) + } } } header: { Text(Unlocalized.Network.ipv4) @@ -89,23 +91,27 @@ extension EndpointAdvancedView.OpenVPNView { } } + @ViewBuilder private var ipv6Section: some View { - builder.ipv6.map { cfg in + if builder.ipv6 != nil || builder.routes6 != nil { Section { - themeLongContentLinkDefault( - L10n.Global.Strings.address, - content: .constant(builder.ipv6.localizedAddress) - ) - themeLongContentLinkDefault( - L10n.NetworkSettings.Gateway.title, - content: .constant(builder.ipv6.localizedDefaultGateway) - ) - - ForEach(cfg.routes, id: \.self) { route in + if let settings = builder.ipv6 { themeLongContentLinkDefault( - L10n.Endpoint.Advanced.Openvpn.Items.Route.caption, - content: .constant(route.localizedDescription) + L10n.Global.Strings.address, + content: .constant(settings.localizedAddress) ) + themeLongContentLinkDefault( + L10n.NetworkSettings.Gateway.title, + content: .constant(settings.localizedDefaultGateway) + ) + } + builder.routes6.map { routes in + ForEach(routes, id: \.self) { route in + themeLongContentLinkDefault( + L10n.Endpoint.Advanced.Openvpn.Items.Route.caption, + content: .constant(route.localizedDescription) + ) + } } } header: { Text(Unlocalized.Network.ipv6) diff --git a/Passepartout/AppShared/L10n/TunnelKit+L10n.swift b/Passepartout/AppShared/L10n/TunnelKit+L10n.swift index 36de5d14..9acd077e 100644 --- a/Passepartout/AppShared/L10n/TunnelKit+L10n.swift +++ b/Passepartout/AppShared/L10n/TunnelKit+L10n.swift @@ -76,43 +76,35 @@ extension TimeInterval { } } -extension Optional where Wrapped == IPv4Settings { +extension IPv4Settings { var localizedAddress: String { - if let ipv4 = self { - return "\(ipv4.address)/\(ipv4.addressMask)" - } else { - return L10n.Global.Strings.none - } + "\(address)/\(addressMask)" } var localizedDefaultGateway: String { - self?.defaultGateway ?? L10n.Global.Strings.none + defaultGateway } } -extension Optional where Wrapped == IPv6Settings { +extension IPv6Settings { var localizedAddress: String { - if let ipv6 = self { - return "\(ipv6.address)/\(ipv6.addressPrefixLength)" - } else { - return L10n.Global.Strings.none - } + "\(address)/\(addressPrefixLength)" } var localizedDefaultGateway: String { - self?.defaultGateway ?? L10n.Global.Strings.none + defaultGateway } } extension IPv4Settings.Route { var localizedDescription: String { - "\(destination)/\(mask) -> \(gateway)" + "\(destination)/\(mask) -> \(gateway ?? "*")" } } extension IPv6Settings.Route { var localizedDescription: String { - "\(destination)/\(prefixLength) -> \(gateway)" + "\(destination)/\(prefixLength) -> \(gateway ?? "*")" } } diff --git a/PassepartoutLibrary/Package.swift b/PassepartoutLibrary/Package.swift index 40aa2a6b..06d049b2 100644 --- a/PassepartoutLibrary/Package.swift +++ b/PassepartoutLibrary/Package.swift @@ -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("8ac21771e347f700ecd05e974df1a4ebf954a6df")), + .package(name: "TunnelKit", url: "https://github.com/passepartoutvpn/tunnelkit", .revision("cae371bb400ad3de9bc59f96c18a091fb577ac44")), // .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")