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

Move WireGuard dependency to packet tunnel provider #3273

Merged
merged 7 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
21 changes: 19 additions & 2 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
4BBBBA872B02E85400D965DA /* DesignResourcesKit in Frameworks */ = {isa = PBXBuildFile; productRef = 4BBBBA862B02E85400D965DA /* DesignResourcesKit */; };
4BBBBA922B03291700D965DA /* VPNWaitlistUserText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BBBBA912B03291700D965DA /* VPNWaitlistUserText.swift */; };
4BC21A2F27238B7500229F0E /* RunLoopExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BC21A2C272388BD00229F0E /* RunLoopExtensionTests.swift */; };
4BC8948C2C7902E6009AA141 /* WireGuard in Frameworks */ = {isa = PBXBuildFile; productRef = 4BC8948B2C7902E6009AA141 /* WireGuard */; };
4BCBE45E2BA7E81F00FC75A1 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 4BCBE45D2BA7E81F00FC75A1 /* PrivacyInfo.xcprivacy */; };
4BCBE4602BA7E87100FC75A1 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 4BCBE45F2BA7E87100FC75A1 /* PrivacyInfo.xcprivacy */; };
4BCD14672B05B682000B1E4C /* NetworkProtectionTermsAndConditionsStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BCD14662B05B682000B1E4C /* NetworkProtectionTermsAndConditionsStore.swift */; };
Expand Down Expand Up @@ -2898,6 +2899,7 @@
02025664298818B200E694E7 /* NetworkExtension.framework in Frameworks */,
4B45D85C2BE0B115006061B5 /* Subscription in Frameworks */,
4B470EE4299C6DFB0086EBDC /* Core.framework in Frameworks */,
4BC8948C2C7902E6009AA141 /* WireGuard in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -6152,6 +6154,7 @@
name = PacketTunnelProvider;
packageProductDependencies = (
4B45D85B2BE0B115006061B5 /* Subscription */,
4BC8948B2C7902E6009AA141 /* WireGuard */,
);
productName = PacketTunnelProvider;
productReference = 02025662298818B100E694E7 /* PacketTunnelProvider.appex */;
Expand Down Expand Up @@ -6565,6 +6568,7 @@
B6F997C22B8F374300476735 /* XCRemoteSwiftPackageReference "apple-toolbox" */,
F1D43AF82B99C1D300BAB743 /* XCRemoteSwiftPackageReference "BareBonesBrowser" */,
9F8FE9472BAE50E50071E372 /* XCRemoteSwiftPackageReference "lottie-spm" */,
4BC8948A2C7902E6009AA141 /* XCRemoteSwiftPackageReference "wireguard-apple" */,
);
productRefGroup = 84E341931E2F7EFB00BDBA6F /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -10566,6 +10570,14 @@
version = 2.0.0;
};
};
4BC8948A2C7902E6009AA141 /* XCRemoteSwiftPackageReference "wireguard-apple" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/duckduckgo/wireguard-apple";
requirement = {
kind = exactVersion;
version = 1.1.3;
};
};
854007E52B57FB020001BD98 /* XCRemoteSwiftPackageReference "ZIPFoundation" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/weichsel/ZIPFoundation.git";
Expand All @@ -10578,8 +10590,8 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 185.1.0;
branch = "sam/remove-wireguard-dependency";
kind = branch;
};
};
9F8FE9472BAE50E50071E372 /* XCRemoteSwiftPackageReference "lottie-spm" */ = {
Expand Down Expand Up @@ -10715,6 +10727,11 @@
package = F42D541B29DCA40B004C4FF1 /* XCRemoteSwiftPackageReference "DesignResourcesKit" */;
productName = DesignResourcesKit;
};
4BC8948B2C7902E6009AA141 /* WireGuard */ = {
isa = XCSwiftPackageProductDependency;
package = 4BC8948A2C7902E6009AA141 /* XCRemoteSwiftPackageReference "wireguard-apple" */;
productName = WireGuard;
};
4BE67B002B96B741007335F7 /* Common */ = {
isa = XCSwiftPackageProductDependency;
package = 98A16C2928A11BDE00A6C003 /* XCRemoteSwiftPackageReference "BrowserServicesKit" */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/DuckDuckGo/BrowserServicesKit",
"state" : {
"revision" : "8b62a829899f1e635aa91deded017ed72be0d4a1",
"version" : "185.1.0"
"branch" : "sam/remove-wireguard-dependency",
"revision" : "df1597b7e51a08c7d6a5e445980159395742acec"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import NetworkExtension
import NetworkProtection
import Subscription
import WidgetKit
import WireGuard

// Initial implementation for initial Network Protection tests. Will be fleshed out with https://app.asana.com/0/1203137811378537/1204630829332227/f
final class NetworkProtectionPacketTunnelProvider: PacketTunnelProvider {
Expand Down Expand Up @@ -374,6 +375,7 @@ final class NetworkProtectionPacketTunnelProvider: PacketTunnelProvider {
tunnelHealthStore: NetworkProtectionTunnelHealthStore(),
controllerErrorStore: errorStore,
snoozeTimingStore: NetworkProtectionSnoozeTimingStore(userDefaults: .networkProtectionGroupDefaults),
wireGuardInterface: DefaultWireGuardInterface(),
keychainType: .dataProtection(.unspecified),
tokenStore: tokenStore,
debugEvents: Self.networkProtectionDebugEvents(controllerErrorStore: errorStore),
Expand Down Expand Up @@ -444,3 +446,33 @@ final class NetworkProtectionPacketTunnelProvider: PacketTunnelProvider {
}
}
}

final class DefaultWireGuardInterface: WireGuardInterface {
func turnOn(settings: UnsafePointer<CChar>, handle: Int32) -> Int32 {
wgTurnOn(settings, handle)
}

func turnOff(handle: Int32) {
wgTurnOff(handle)
}

func getConfig(handle: Int32) -> UnsafeMutablePointer<CChar>? {
return wgGetConfig(handle)
}

func setConfig(handle: Int32, config: String) -> Int64 {
return wgSetConfig(handle, config)
}

func bumpSockets(handle: Int32) {
wgBumpSockets(handle)
}

func disableSomeRoamingForBrokenMobileSemantics(handle: Int32) {
wgDisableSomeRoamingForBrokenMobileSemantics(handle)
}

func setLogger(context: UnsafeMutableRawPointer?, logFunction: (@convention(c) (UnsafeMutableRawPointer?, Int32, UnsafePointer<CChar>?) -> Void)?) {
wgSetLogger(context, logFunction)
}
}
Loading