Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
path: |
.build
~/Library/Caches/org.swift.swiftpm
key: spm-${{ runner.os }}-${{ hashFiles('Package.resolved') }}
key: spm-${{ runner.os }}-${{ hashFiles('Package.swift', 'Package.resolved') }}
restore-keys: spm-${{ runner.os }}-
- run: swift test --enable-code-coverage
- name: Convert coverage
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ build-helper:
@swiftc -O \
-target arm64-apple-macos13.0 \
-o $(HELPER_BUILD_DIR)/$(HELPER_ID)-arm64 \
Sources/HelperProtocol.swift \
Sources/VPNBypassCore/HelperProtocol.swift \
Helper/HelperTool.swift \
Helper/main.swift
@swiftc -O \
-target x86_64-apple-macos13.0 \
-o $(HELPER_BUILD_DIR)/$(HELPER_ID)-x86_64 \
Sources/HelperProtocol.swift \
Sources/VPNBypassCore/HelperProtocol.swift \
Helper/HelperTool.swift \
Helper/main.swift
@lipo -create \
Expand Down Expand Up @@ -61,7 +61,7 @@ bundle: build build-helper
@cp assets/menubar-icon-error.png "$(APP_BUNDLE)/Contents/Resources/"
@cp assets/menubar-icon-error@2x.png "$(APP_BUNDLE)/Contents/Resources/"
@# Copy localizations
@cp -R Resources/*.lproj "$(APP_BUNDLE)/Contents/Resources/"
@cp -R Sources/VPNBypassCore/Resources/*.lproj "$(APP_BUNDLE)/Contents/Resources/"
@echo "App bundle created: $(APP_BUNDLE)"

clean:
Expand Down
23 changes: 10 additions & 13 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,23 @@ let package = Package(
],
dependencies: [],
targets: [
.executableTarget(
name: "VPNBypass",
.target(
name: "VPNBypassCore",
dependencies: [],
path: ".",
exclude: [
"AGENTS.md", "Casks", "Helper", "Info.plist", "LICENSE",
"Makefile", "README.md", "ROADMAP.md", "SECURITY.md",
"VPN Bypass.app", "VPNBypass.entitlements", "assets",
"dist", "docs", "scripts", "Tests"
],
sources: ["Sources"],
path: "Sources/VPNBypassCore",
resources: [
.process("Resources")
]
),
.executableTarget(
name: "VPNBypass",
dependencies: ["VPNBypassCore"],
path: "Sources/VPNBypass"
),
.testTarget(
name: "VPNBypassTests",
dependencies: [],
path: "Tests/VPNBypassTests",
sources: ["VPNBypassTests.swift"]
dependencies: ["VPNBypassCore"],
path: "Tests/VPNBypassTests"
)
]
)
3 changes: 3 additions & 0 deletions Sources/VPNBypass/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import VPNBypassCore

VPNBypassApp.main()
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3656,12 +3656,7 @@ final class RouteManager: ObservableObject {
}
}

/// Public domain normalization for custom service editor
func cleanDomainForService(_ input: String) -> String {
return cleanDomain(input)
}

private func cleanDomain(_ input: String) -> String {
nonisolated func cleanDomain(_ input: String) -> String {
var domain = input.trimmingCharacters(in: .whitespacesAndNewlines)

// Remove any protocol scheme (http, https, ssh, ftp, etc.) using regex
Expand Down Expand Up @@ -3694,7 +3689,7 @@ final class RouteManager: ObservableObject {
return domain.lowercased()
}

private func isValidIP(_ string: String) -> Bool {
nonisolated func isValidIP(_ string: String) -> Bool {
let parts = string.components(separatedBy: ".")
guard parts.count == 4 else { return false }
return parts.allSatisfy {
Expand All @@ -3706,7 +3701,7 @@ final class RouteManager: ObservableObject {

/// Validate CIDR notation (e.g., "192.168.1.0/24")
/// Rejects /0 which would conflict with VPN Only catch-all routes.
private func isValidCIDR(_ string: String) -> Bool {
nonisolated func isValidCIDR(_ string: String) -> Bool {
let parts = string.components(separatedBy: "/")
guard parts.count == 2,
isValidIP(parts[0]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ struct CustomServiceEditor: View {
private func save() {
// Normalize domains the same way the main domain input does (strips protocols, ports, paths, invalid chars)
let cleanDomains = domains
.map { routeManager.cleanDomainForService($0) }
.map { routeManager.cleanDomain($0) }
.filter { !$0.isEmpty }
let cleanIPs = ipRanges.map { $0.trimmingCharacters(in: .whitespaces) }.filter { !$0.isEmpty }
let name = serviceName.trimmingCharacters(in: .whitespaces)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import SwiftUI
import Network
import UserNotifications

@main
struct VPNBypassApp: App {
public struct VPNBypassApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
@StateObject private var routeManager = RouteManager.shared
@StateObject private var notificationManager = NotificationManager.shared
@StateObject private var launchAtLoginManager = LaunchAtLoginManager.shared

var body: some Scene {

public init() {}

public var body: some Scene {
MenuBarExtra {
MenuContent()
.environmentObject(routeManager)
Expand Down
Loading
Loading