Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve NEVPNErrorDomain error and profile duplication on first import #1026

Merged
merged 4 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions Library/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,23 @@
"kind" : "remoteSourceControl",
"location" : "git@github.com:passepartoutvpn/passepartoutkit-source",
"state" : {
"revision" : "a08e04fccde51d92d5bed3fbe1880c4225f18618",
"version" : "1.0.0"
"revision" : "612168933da04498bfe60abd09d466183388196f"
}
},
{
"identity" : "passepartoutkit-source-openvpn-openssl",
"kind" : "remoteSourceControl",
"location" : "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl",
"state" : {
"revision" : "3c3d7a4b477976fed638858bca9bb06e224bea3c",
"version" : "1.0.0"
"revision" : "dc14907a90eb9ece4f2a2d993a99ebde674fe409"
}
},
{
"identity" : "passepartoutkit-source-wireguard-go",
"kind" : "remoteSourceControl",
"location" : "git@github.com:passepartoutvpn/passepartoutkit-source-wireguard-go",
"state" : {
"revision" : "7c1e0279eadf319a8744b34c09cb481a32d17623",
"version" : "1.0.0"
"revision" : "6b24ea9ad16b37ecfe5d18ddccc8be8fc2f612f8"
}
},
{
Expand Down
12 changes: 6 additions & 6 deletions Library/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ let package = Package(
)
],
dependencies: [
.package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", from: "1.0.0"),
// .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", revision: "a08e04fccde51d92d5bed3fbe1880c4225f18618"),
// .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", from: "1.0.0"),
.package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", revision: "612168933da04498bfe60abd09d466183388196f"),
// .package(path: "../../passepartoutkit-source"),
.package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", from: "1.0.0"),
// .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", revision: "031863a1cd683962a7dfe68e20b91fa820a1ecce"),
// .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", from: "1.0.0"),
.package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", revision: "dc14907a90eb9ece4f2a2d993a99ebde674fe409"),
// .package(path: "../../passepartoutkit-source-openvpn-openssl"),
.package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-wireguard-go", from: "1.0.0"),
// .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-wireguard-go", revision: "68fceaa664913988b2d9053405738682a30b87b8"),
// .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-wireguard-go", from: "1.0.0"),
.package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-wireguard-go", revision: "6b24ea9ad16b37ecfe5d18ddccc8be8fc2f612f8"),
// .package(path: "../../passepartoutkit-source-wireguard-go"),
.package(url: "https://github.com/Cocoanetics/Kvitto", from: "1.0.0")
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
</CommandLineArgument>
<CommandLineArgument
argument = "-pp_fake_migration"
isEnabled = "YES">
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "-com.apple.CoreData.SQLDebug 1"
Expand Down
84 changes: 25 additions & 59 deletions Passepartout/App/Context/AppContext+Shared.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,23 @@ extension AppContext {
let processor = dependencies.appProcessor(with: iapManager)
let tunnelEnvironment = dependencies.tunnelEnvironment()

#if targetEnvironment(simulator)
let tunnelStrategy = FakeTunnelStrategy(environment: tunnelEnvironment, dataCountInterval: 1000)
let mainProfileRepository = dependencies.coreDataProfileRepository(
model: cdRemoteModel,
observingResults: true
)
#else
let tunnelStrategy = NETunnelStrategy(
bundleIdentifier: BundleConfiguration.mainString(for: .tunnelId),
coder: dependencies.neProtocolCoder(),
environment: tunnelEnvironment
)
let mainProfileRepository = NEProfileRepository(repository: tunnelStrategy) {
dependencies.profileTitle($0)
}
#endif

let profileManager: ProfileManager = {
let remoteRepositoryBlock: (Bool) -> ProfileRepository = {
let remoteStore = CoreDataPersistentStore(
Expand All @@ -84,10 +101,7 @@ extension AppContext {
)
}
return ProfileManager(
repository: dependencies.mainProfileRepository(
model: cdRemoteModel,
environment: tunnelEnvironment
),
repository: mainProfileRepository,
backupRepository: dependencies.backupProfileRepository(
model: cdRemoteModel
),
Expand All @@ -98,7 +112,7 @@ extension AppContext {
}()

let tunnel = ExtendedTunnel(
tunnel: Tunnel(strategy: dependencies.tunnelStrategy(environment: tunnelEnvironment)),
tunnel: Tunnel(strategy: tunnelStrategy),
environment: tunnelEnvironment,
processor: processor,
interval: Constants.shared.tunnel.refreshInterval
Expand Down Expand Up @@ -214,49 +228,7 @@ private extension Dependencies {
var betaReceiptURL: URL? {
Bundle.main.appStoreProductionReceiptURL
}
}

// MARK: Simulator

#if targetEnvironment(simulator)

private extension Dependencies {
func tunnelStrategy(environment: TunnelEnvironment) -> TunnelObservableStrategy {
FakeTunnelStrategy(environment: environment, dataCountInterval: 1000)
}

func mainProfileRepository(model: NSManagedObjectModel, environment: TunnelEnvironment) -> ProfileRepository {
coreDataProfileRepository(model: model, observingResults: true)
}

func backupProfileRepository(model: NSManagedObjectModel) -> ProfileRepository? {
nil
}
}

#else

// MARK: Device

private extension Dependencies {
func tunnelStrategy(environment: TunnelEnvironment) -> TunnelObservableStrategy {
neStrategy(environment: environment)
}

func mainProfileRepository(model: NSManagedObjectModel, environment: TunnelEnvironment) -> ProfileRepository {
neProfileRepository(environment: environment)
}

func backupProfileRepository(model: NSManagedObjectModel) -> ProfileRepository? {
coreDataProfileRepository(model: model, observingResults: false)
}
}

#endif

// MARK: Common

private extension Dependencies {
var mirrorsRemoteRepository: Bool {
#if os(tvOS)
true
Expand All @@ -265,18 +237,12 @@ private extension Dependencies {
#endif
}

func neProfileRepository(environment: TunnelEnvironment) -> ProfileRepository {
NEProfileRepository(repository: neStrategy(environment: environment)) {
profileTitle($0)
}
}

func neStrategy(environment: TunnelEnvironment) -> NETunnelStrategy {
NETunnelStrategy(
bundleIdentifier: BundleConfiguration.mainString(for: .tunnelId),
coder: neProtocolCoder(),
environment: environment
)
func backupProfileRepository(model: NSManagedObjectModel) -> ProfileRepository? {
#if targetEnvironment(simulator)
nil
#else
coreDataProfileRepository(model: model, observingResults: false)
#endif
}

func coreDataProfileRepository(model: NSManagedObjectModel, observingResults: Bool) -> ProfileRepository {
Expand Down