Update TunnelKit

Split IP settings and routes. Now properly handling local routes.
This commit is contained in:
Davide De Rosa 2022-10-29 11:22:06 +02:00
parent 0f04bdcce3
commit cdc05f0c10
6 changed files with 51 additions and 52 deletions

View File

@ -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)

View File

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

View File

@ -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 ?? "*")"
}
}

View File

@ -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)

View File

@ -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 ?? "*")"
}
}

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("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")