Add tvOS support

- Upgrade OpenSSL for tvOS Simulator on arm64
- Use own WireGuard fork on develop

Closes #337
This commit is contained in:
Davide De Rosa 2023-12-16 20:50:10 +01:00
parent c56bfd7224
commit 6101e92c3b
No known key found for this signature in database
GPG Key ID: A48836171C759F5E
9 changed files with 54 additions and 44 deletions

View File

@ -23,8 +23,8 @@ jobs:
- name: Run tests - name: Run tests
run: | run: |
swift test swift test
publish_release: publish_version:
name: Tag release name: Publish release
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: run_tests needs: run_tests
steps: steps:
@ -49,7 +49,7 @@ jobs:
git commit -m "$COMMIT_MESSAGE" git commit -m "$COMMIT_MESSAGE"
git tag "v$VERSION" -m "$TAG_MESSAGE" git tag "v$VERSION" -m "$TAG_MESSAGE"
git push && git push --tags git push && git push --tags
- name: Publish release - name: Publish
uses: softprops/action-gh-release@v1 uses: softprops/action-gh-release@v1
with: with:
tag_name: "v${{ env.VERSION }}" tag_name: "v${{ env.VERSION }}"

View File

@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- Support for Apple TV. [#337](https://github.com/passepartoutvpn/tunnelkit/issues/337)
- Attach user data to VPN configuration. [#400](https://github.com/passepartoutvpn/tunnelkit/pull/400) - Attach user data to VPN configuration. [#400](https://github.com/passepartoutvpn/tunnelkit/pull/400)
## 6.2.0 (2023-12-14) ## 6.2.0 (2023-12-14)

View File

@ -1,34 +1,32 @@
{ {
"object": { "pins" : [
"pins": [
{ {
"package": "openssl-apple", "identity" : "openssl-apple",
"repositoryURL": "https://github.com/passepartoutvpn/openssl-apple", "kind" : "remoteSourceControl",
"state": { "location" : "https://github.com/passepartoutvpn/openssl-apple",
"branch": null, "state" : {
"revision": "026702febcaebcbf9ea68f2fa66b017eba998cdf", "revision" : "026702febcaebcbf9ea68f2fa66b017eba998cdf",
"version": "3.2.105" "version" : "3.2.105"
} }
}, },
{ {
"package": "SwiftyBeaver", "identity" : "swiftybeaver",
"repositoryURL": "https://github.com/SwiftyBeaver/SwiftyBeaver", "kind" : "remoteSourceControl",
"state": { "location" : "https://github.com/SwiftyBeaver/SwiftyBeaver",
"branch": null, "state" : {
"revision": "12b5acf96d98f91d50de447369bd18df74600f1a", "revision" : "12b5acf96d98f91d50de447369bd18df74600f1a",
"version": "1.9.6" "version" : "1.9.6"
} }
}, },
{ {
"package": "WireGuardKit", "identity" : "wireguard-apple",
"repositoryURL": "https://github.com/passepartoutvpn/wireguard-apple", "kind" : "remoteSourceControl",
"state": { "location" : "https://github.com/passepartoutvpn/wireguard-apple",
"branch": null, "state" : {
"revision": "73d9152fa0cb661db0348a1ac11dbbf998422a50", "branch" : "develop",
"version": "1.0.17" "revision" : "b79f0f150356d8200a64922ecf041dd020140aa0"
} }
} }
] ],
}, "version" : 2
"version": 1
} }

View File

@ -1,4 +1,4 @@
// swift-tools-version:5.5 // swift-tools-version:5.9
// The swift-tools-version declares the minimum version of Swift required to build this package. // The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription import PackageDescription
@ -6,7 +6,9 @@ import PackageDescription
let package = Package( let package = Package(
name: "TunnelKit", name: "TunnelKit",
platforms: [ platforms: [
.iOS(.v15), .macOS(.v12) .iOS(.v15),
.macOS(.v12),
.tvOS(.v17)
], ],
products: [ products: [
// Products define the executables and libraries a package produces, and make them visible to other packages. // Products define the executables and libraries a package produces, and make them visible to other packages.
@ -39,10 +41,11 @@ 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(url: "https://github.com/SwiftyBeaver/SwiftyBeaver", from: "1.9.0"), .package(url: "https://github.com/SwiftyBeaver/SwiftyBeaver", from: "1.9.0"),
.package(url: "https://github.com/passepartoutvpn/openssl-apple", from: "3.2.0"), .package(url: "https://github.com/passepartoutvpn/openssl-apple", from: "3.2.105"),
// .package(name: "WireGuardKit", url: "https://git.zx2c4.com/wireguard-apple", .exact("1.0.15-26")), // .package(url: "https://git.zx2c4.com/wireguard-apple", .exact: Version("1.0.15-26")),
.package(name: "WireGuardKit", url: "https://github.com/passepartoutvpn/wireguard-apple", .exact("1.0.17")) // .package(url: "https://github.com/passepartoutvpn/wireguard-apple", exact: Version("1.0.17")),
// .package(name: "WireGuardKit", url: "https://github.com/passepartoutvpn/wireguard-apple", .revision("73d9152fa0cb661db0348a1ac11dbbf998422a50")) // .package(url: "https://github.com/passepartoutvpn/wireguard-apple", revision: "73d9152fa0cb661db0348a1ac11dbbf998422a50")
.package(url: "https://github.com/passepartoutvpn/wireguard-apple", branch: "develop")
// .package(name: "WireGuardKit", path: "../wireguard-apple") // .package(name: "WireGuardKit", path: "../wireguard-apple")
], ],
targets: [ targets: [
@ -118,7 +121,7 @@ let package = Package(
dependencies: [ dependencies: [
"__TunnelKitUtils", "__TunnelKitUtils",
"TunnelKitCore", "TunnelKitCore",
"WireGuardKit", .product(name: "WireGuardKit", package: "wireguard-apple"),
"SwiftyBeaver" "SwiftyBeaver"
]), ]),
.target( .target(

View File

@ -38,7 +38,7 @@ import Foundation
#if os(iOS) #if os(iOS)
import NetworkExtension import NetworkExtension
import SystemConfiguration.CaptiveNetwork import SystemConfiguration.CaptiveNetwork
#else #elseif os(macOS)
import CoreWLAN import CoreWLAN
#endif #endif
import SwiftyBeaver import SwiftyBeaver
@ -116,10 +116,12 @@ public class InterfaceObserver: NSObject {
NEHotspotNetwork.fetchCurrent { NEHotspotNetwork.fetchCurrent {
completionHandler($0?.ssid) completionHandler($0?.ssid)
} }
#else #elseif os(macOS)
let client = CWWiFiClient.shared() let client = CWWiFiClient.shared()
let ssid = client.interfaces()?.compactMap { $0.ssid() }.first let ssid = client.interfaces()?.compactMap { $0.ssid() }.first
completionHandler(ssid) completionHandler(ssid)
#else
completionHandler(nil)
#endif #endif
} }
} }

View File

@ -38,8 +38,10 @@ public struct NetworkExtensionExtra {
/// Disconnects on sleep if `true`. /// Disconnects on sleep if `true`.
public var disconnectsOnSleep = false public var disconnectsOnSleep = false
#if !os(tvOS)
/// Enables best-effort kill switch. /// Enables best-effort kill switch.
public var killSwitch = false public var killSwitch = false
#endif
/// Extra user configuration data. /// Extra user configuration data.
public var userData: [String: Any]? public var userData: [String: Any]?

View File

@ -38,7 +38,7 @@ import NetworkExtension
import SwiftyBeaver import SwiftyBeaver
#if os(iOS) #if os(iOS)
import SystemConfiguration.CaptiveNetwork import SystemConfiguration.CaptiveNetwork
#else #elseif os(macOS)
import CoreWLAN import CoreWLAN
#endif #endif
import TunnelKitCore import TunnelKitCore

View File

@ -113,7 +113,9 @@ extension OpenVPN.ProviderConfiguration: NetworkExtensionConfiguration {
} }
protocolConfiguration.disconnectOnSleep = extra?.disconnectsOnSleep ?? false protocolConfiguration.disconnectOnSleep = extra?.disconnectsOnSleep ?? false
protocolConfiguration.providerConfiguration = try asDictionary() protocolConfiguration.providerConfiguration = try asDictionary()
#if !os(tvOS)
protocolConfiguration.includeAllNetworks = extra?.killSwitch ?? false protocolConfiguration.includeAllNetworks = extra?.killSwitch ?? false
#endif
return protocolConfiguration return protocolConfiguration
} }
} }

View File

@ -86,7 +86,9 @@ extension WireGuard.ProviderConfiguration: NetworkExtensionConfiguration {
protocolConfiguration.passwordReference = extra?.passwordReference protocolConfiguration.passwordReference = extra?.passwordReference
protocolConfiguration.disconnectOnSleep = extra?.disconnectsOnSleep ?? false protocolConfiguration.disconnectOnSleep = extra?.disconnectsOnSleep ?? false
protocolConfiguration.providerConfiguration = try asDictionary() protocolConfiguration.providerConfiguration = try asDictionary()
#if !os(tvOS)
protocolConfiguration.includeAllNetworks = extra?.killSwitch ?? false protocolConfiguration.includeAllNetworks = extra?.killSwitch ?? false
#endif
return protocolConfiguration return protocolConfiguration
} }
} }