From f6f895550d1af251c0862142a2a002d1d07fa90a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Mon, 19 Feb 2024 00:41:20 +0800 Subject: [PATCH] Add support for `bypass_domain` and `match_domain` platform HTTP proxy options --- .../Network/ExtensionPlatformInterface.swift | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Library/Network/ExtensionPlatformInterface.swift b/Library/Network/ExtensionPlatformInterface.swift index 2623e4b..800467b 100644 --- a/Library/Network/ExtensionPlatformInterface.swift +++ b/Library/Network/ExtensionPlatformInterface.swift @@ -148,8 +148,28 @@ public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtoc proxySettings.httpEnabled = true proxySettings.httpsEnabled = true } + var bypassDomains: [String] = [] + let bypassDomainIterator = options.getHTTPProxyBypassDomain()! + while bypassDomainIterator.hasNext() { + bypassDomains.append(bypassDomainIterator.next()) + } if excludeAPNs { - proxySettings.exceptionList = ["push.apple.com"] + if !bypassDomains.contains(where: { it in + it == "push.apple.com" + }) { + bypassDomains.append("push.apple.com") + } + } + if !bypassDomains.isEmpty { + proxySettings.exceptionList = bypassDomains + } + var matchDomains: [String] = [] + let matchDomainIterator = options.getHTTPProxyMatchDomain()! + while matchDomainIterator.hasNext() { + matchDomains.append(matchDomainIterator.next()) + } + if !matchDomains.isEmpty { + proxySettings.matchDomains = matchDomains } settings.proxySettings = proxySettings }