Skip to content

Force Proxy to any Windows/MacOS/Linux Application TCP and UDP traffic

removed GUI domain, added IP range for mac

AnoF-Cyber0cb1aaa1bcfc
diff --git a/MacOS/ProxyBridge/ProxyBridge/ProxyRulesView.swift b/MacOS/ProxyBridge/ProxyBridge/ProxyRulesView.swift
index c6609b9..617237a 100644
--- a/MacOS/ProxyBridge/ProxyBridge/ProxyRulesView.swift
+++ b/MacOS/ProxyBridge/ProxyBridge/ProxyRulesView.swift
@@ -410,7 +410,7 @@ struct RuleEditorView: View {
label: "Target hosts",
placeholder: "*",
text: $targetHosts,
- hint: "Example: 127.0.0.1; *.example.com; 192.168.1.*; 10.1.0.0-10.5.255.255"
+ hint: "Example: 127.0.0.1; 192.168.1.*; 10.0.0.1-10.0.0.254"
)
formField(
diff --git a/MacOS/ProxyBridge/extension/AppProxyProvider.swift b/MacOS/ProxyBridge/extension/AppProxyProvider.swift
index c12ff2a..bca221c 100644
--- a/MacOS/ProxyBridge/extension/AppProxyProvider.swift
+++ b/MacOS/ProxyBridge/extension/AppProxyProvider.swift
@@ -135,11 +135,40 @@ struct ProxyRule: Codable {
return false
}
+ private static func ipToInteger(_ ipString: String) -> UInt32? {
+ let octets = ipString.components(separatedBy: ".")
+ guard octets.count == 4 else { return nil }
+
+ var result: UInt32 = 0
+ for octet in octets {
+ guard let value = UInt8(octet) else { return nil }
+ result = (result << 8) | UInt32(value)
+ }
+ return result
+ }
+
private static func matchIPPattern(_ pattern: String, ipString: String) -> Bool {
if pattern.isEmpty || pattern == "*" {
return true
}
+ // Check for IP range (e.g., 192.168.1.1-192.168.1.254)
+ if pattern.contains("-") {
+ let parts = pattern.components(separatedBy: "-")
+ if parts.count == 2 {
+ let startIP = parts[0].trimmingCharacters(in: .whitespaces)
+ let endIP = parts[1].trimmingCharacters(in: .whitespaces)
+
+ if let startInt = ipToInteger(startIP),
+ let endInt = ipToInteger(endIP),
+ let targetInt = ipToInteger(ipString) {
+ return targetInt >= startInt && targetInt <= endInt
+ }
+ }
+ return false
+ }
+
+ // Wildcard matching (e.g., 192.168.1.*)
let patternOctets = pattern.components(separatedBy: ".")
let ipOctets = ipString.components(separatedBy: ".")