diff --git a/Tun/TunDebug.entitlements b/Tun/TunDebug.entitlements new file mode 100644 index 0000000..62cc9b8 --- /dev/null +++ b/Tun/TunDebug.entitlements @@ -0,0 +1,20 @@ + + + + + com.apple.developer.networking.networkextension + + packet-tunnel-provider + + com.apple.security.app-sandbox + + com.apple.security.application-groups + + group.com.jihe.punchnetmac + + com.apple.security.network.client + + com.apple.security.network.server + + + diff --git a/punchnet.xcodeproj/project.pbxproj b/punchnet.xcodeproj/project.pbxproj index 9507252..7bda03d 100644 --- a/punchnet.xcodeproj/project.pbxproj +++ b/punchnet.xcodeproj/project.pbxproj @@ -571,7 +571,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; - CODE_SIGN_ENTITLEMENTS = punchnet/punchnet.entitlements; + CODE_SIGN_ENTITLEMENTS = punchnet/punchnetDebug.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer"; CODE_SIGN_STYLE = Manual; @@ -591,10 +591,10 @@ ); MACOSX_DEPLOYMENT_TARGET = 15.6; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.jihe.punchnetmac.dev; + PRODUCT_BUNDLE_IDENTIFIER = com.jihe.punchnetmac; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; - "PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = MacPunchnetTestDev; + "PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = MacPunchnetTest; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; }; @@ -709,7 +709,7 @@ C8A77F352DD1E77B00195617 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CODE_SIGN_ENTITLEMENTS = Tun/Tun.entitlements; + CODE_SIGN_ENTITLEMENTS = Tun/TunDebug.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer"; CODE_SIGN_STYLE = Manual; @@ -728,10 +728,10 @@ ); MACOSX_DEPLOYMENT_TARGET = 15.6; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.jihe.punchnetmac.dev.tun; + PRODUCT_BUNDLE_IDENTIFIER = com.jihe.punchnetmac.tun; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; - "PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = MacPunchnetTunTestDev; + "PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = MacPunchnetTunTest; SKIP_INSTALL = YES; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; diff --git a/punchnet/Core/SystemConfig.swift b/punchnet/Core/SystemConfig.swift index 275cb16..8ec433f 100644 --- a/punchnet/Core/SystemConfig.swift +++ b/punchnet/Core/SystemConfig.swift @@ -37,7 +37,7 @@ struct SystemConfig { .dev: EnvConfig( serverHost: "test.punchsky.com", stunAssistHost: "test.punchsky.com", - tunBundleId: "com.jihe.punchnetmac.dev.tun", + tunBundleId: "com.jihe.punchnetmac.tun", localizedDescription: "punchnetmac-dev" ), .prod: EnvConfig( diff --git a/punchnet/Core/VPNManager.swift b/punchnet/Core/VPNManager.swift index 2e6302c..d3c6f8d 100644 --- a/punchnet/Core/VPNManager.swift +++ b/punchnet/Core/VPNManager.swift @@ -128,11 +128,13 @@ class VPNManager { let env = SystemConfig.getCurrentEnvConfig() for manager in managers { - guard let protocolConfiguration = manager.protocolConfiguration as? NETunnelProviderProtocol, - protocolConfiguration.providerBundleIdentifier == env.tunBundleId else { - try await manager.removeFromPreferences() - continue - } +// guard let protocolConfiguration = manager.protocolConfiguration as? NETunnelProviderProtocol, +// protocolConfiguration.providerBundleIdentifier == env.tunBundleId else { +// try await manager.removeFromPreferences() +// continue +// } + // TODO Debug + try await manager.removeFromPreferences() } let managersAfterCleanup = try await NETunnelProviderManager.loadAllFromPreferences() diff --git a/punchnet/punchnetDebug.entitlements b/punchnet/punchnetDebug.entitlements new file mode 100644 index 0000000..7aaf894 --- /dev/null +++ b/punchnet/punchnetDebug.entitlements @@ -0,0 +1,28 @@ + + + + + com.apple.developer.networking.networkextension + + packet-tunnel-provider + + com.apple.developer.networking.vpn.api + + allow-vpn + + com.apple.security.app-sandbox + + com.apple.security.application-groups + + group.com.jihe.punchnetmac + + com.apple.security.files.user-selected.read-only + + com.apple.security.network.client + + com.apple.security.network.server + + keychain-access-groups + + +