mirror of
https://github.com/bolucat/Archive.git
synced 2025-12-24 13:28:37 +08:00
Update On Mon Jun 24 20:32:20 CEST 2024
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21225" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21225"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22690"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -23,7 +23,7 @@
|
||||
<rect key="frame" x="0.0" y="0.0" width="700" height="360"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jcb-hK-ckn">
|
||||
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jcb-hK-ckn">
|
||||
<rect key="frame" x="18" y="323" width="109" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Domain Strategy:" id="22k-l7-G7a">
|
||||
@@ -32,7 +32,7 @@
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="oz6-O3-feh">
|
||||
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="oz6-O3-feh">
|
||||
<rect key="frame" x="42" y="293" width="85" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Routing Rule:" id="4rB-9k-291">
|
||||
@@ -121,23 +121,23 @@
|
||||
</tabViewItem>
|
||||
<tabViewItem label="Direct" identifier="" id="yc0-Po-cG1">
|
||||
<view key="view" id="mlE-HX-BcJ">
|
||||
<rect key="frame" x="10" y="33" width="414" height="190"/>
|
||||
<rect key="frame" x="10" y="33" width="650" height="190"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<scrollView fixedFrame="YES" borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" translatesAutoresizingMaskIntoConstraints="NO" id="kkR-uc-Qja">
|
||||
<rect key="frame" x="12" y="12" width="389" height="171"/>
|
||||
<rect key="frame" x="12" y="12" width="627" height="171"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<clipView key="contentView" ambiguous="YES" drawsBackground="NO" copiesOnScroll="NO" id="oot-vM-Y6a">
|
||||
<rect key="frame" x="0.0" y="0.0" width="389" height="171"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="oot-vM-Y6a">
|
||||
<rect key="frame" x="0.0" y="0.0" width="627" height="171"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textView ambiguous="YES" importsGraphics="NO" richText="NO" verticallyResizable="YES" spellingCorrection="YES" smartInsertDelete="YES" id="vYm-hy-3PV">
|
||||
<rect key="frame" x="0.0" y="0.0" width="389" height="171"/>
|
||||
<textView importsGraphics="NO" richText="NO" verticallyResizable="YES" spellingCorrection="YES" smartInsertDelete="YES" id="vYm-hy-3PV">
|
||||
<rect key="frame" x="0.0" y="0.0" width="627" height="171"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
<size key="minSize" width="389" height="171"/>
|
||||
<size key="maxSize" width="394" height="10000000"/>
|
||||
<size key="minSize" width="627" height="171"/>
|
||||
<size key="maxSize" width="628" height="10000000"/>
|
||||
<color key="insertionPointColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||
</textView>
|
||||
</subviews>
|
||||
@@ -148,7 +148,7 @@
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="9vp-fC-VPR">
|
||||
<rect key="frame" x="373" y="0.0" width="16" height="171"/>
|
||||
<rect key="frame" x="611" y="0.0" width="16" height="171"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
</scrollView>
|
||||
@@ -157,23 +157,23 @@
|
||||
</tabViewItem>
|
||||
<tabViewItem label="Block" identifier="" id="nsT-BW-R2Z">
|
||||
<view key="view" id="OgP-Jb-qTh">
|
||||
<rect key="frame" x="10" y="33" width="414" height="190"/>
|
||||
<rect key="frame" x="10" y="33" width="650" height="190"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<scrollView fixedFrame="YES" borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" translatesAutoresizingMaskIntoConstraints="NO" id="GOX-0f-UYf">
|
||||
<rect key="frame" x="12" y="12" width="389" height="171"/>
|
||||
<rect key="frame" x="12" y="12" width="627" height="171"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<clipView key="contentView" ambiguous="YES" drawsBackground="NO" copiesOnScroll="NO" id="lep-5k-Lk2">
|
||||
<rect key="frame" x="0.0" y="0.0" width="389" height="171"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="lep-5k-Lk2">
|
||||
<rect key="frame" x="0.0" y="0.0" width="627" height="171"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textView ambiguous="YES" importsGraphics="NO" richText="NO" verticallyResizable="YES" spellingCorrection="YES" smartInsertDelete="YES" id="UmH-oj-OeF">
|
||||
<rect key="frame" x="0.0" y="0.0" width="389" height="171"/>
|
||||
<textView importsGraphics="NO" richText="NO" verticallyResizable="YES" spellingCorrection="YES" smartInsertDelete="YES" id="UmH-oj-OeF">
|
||||
<rect key="frame" x="0.0" y="0.0" width="627" height="171"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
<size key="minSize" width="389" height="171"/>
|
||||
<size key="maxSize" width="394" height="10000000"/>
|
||||
<size key="minSize" width="627" height="171"/>
|
||||
<size key="maxSize" width="633" height="10000000"/>
|
||||
<color key="insertionPointColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||
</textView>
|
||||
</subviews>
|
||||
@@ -184,7 +184,7 @@
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="c7l-Gi-Vwn">
|
||||
<rect key="frame" x="373" y="0.0" width="16" height="171"/>
|
||||
<rect key="frame" x="611" y="0.0" width="16" height="171"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
</scrollView>
|
||||
@@ -193,7 +193,7 @@
|
||||
</tabViewItem>
|
||||
</tabViewItems>
|
||||
</tabView>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="abB-zF-WFz" userLabel="Set the rules line by line: domain or ip">
|
||||
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="abB-zF-WFz" userLabel="Set the rules line by line: domain or ip">
|
||||
<rect key="frame" x="18" y="20" width="241" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" title="* Set the rules line by line: domain or ip" id="ccq-gn-C6Z" userLabel="Set the rules line by line: domain or ip">
|
||||
|
||||
@@ -30,7 +30,17 @@ final class PreferencePacViewController: NSViewController, PreferencePane {
|
||||
|
||||
@IBOutlet var gfwPacListUrl: NSTextField!
|
||||
@IBOutlet var userRulesView: NSTextView!
|
||||
|
||||
@objc private func configWindowWillClose(notification: Notification) {
|
||||
print("configWindowWillClose-pac",notification)
|
||||
guard let object = notification.object as? NSWindow else {
|
||||
return
|
||||
}
|
||||
|
||||
if object.title == "V2rayU" {
|
||||
showDock(state: false)
|
||||
}
|
||||
}
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
// fix: https://github.com/sindresorhus/Preferences/issues/31
|
||||
@@ -275,6 +285,9 @@ func getPacUserRules() -> String {
|
||||
if !userRuleTxt.contains("chat.openai.com") {
|
||||
userRuleTxt.append("\n||chat.openai.com")
|
||||
}
|
||||
if !userRuleTxt.contains("chatgpt.com") {
|
||||
userRuleTxt.append("\n||chatgpt.com")
|
||||
}
|
||||
return userRuleTxt
|
||||
}
|
||||
|
||||
|
||||
@@ -297,8 +297,8 @@ class V2rayConfig: NSObject {
|
||||
var rules: [V2rayRoutingSettingRule] = []
|
||||
|
||||
// rules
|
||||
var ruleProxyDomain, ruleProxyIp, ruleDirectDomain, ruleDirectIp, ruleBlockDomain, ruleBlockIp: V2rayRoutingSettingRule?
|
||||
|
||||
var ruleProxyDomain, ruleProxyIp, ruleDirectDomain, ruleDirectIp, ruleBlockDomain, ruleBlockIp, ruleDirectIpDefault, ruleDirectDomainDefault: V2rayRoutingSettingRule?
|
||||
print("ruleBlockDomain",self.routingBlockDomains)
|
||||
// proxy
|
||||
if self.routingProxyDomains.count > 0 {
|
||||
ruleProxyDomain = getRoutingRule(outTag: "proxy", domain: self.routingProxyDomains, ip: nil, port: nil)
|
||||
@@ -317,7 +317,7 @@ class V2rayConfig: NSObject {
|
||||
|
||||
// block
|
||||
if self.routingBlockDomains.count > 0 {
|
||||
ruleBlockDomain = getRoutingRule(outTag: "block", domain: self.routingDirectDomains, ip: nil, port: nil)
|
||||
ruleBlockDomain = getRoutingRule(outTag: "block", domain: self.routingBlockDomains, ip: nil, port: nil)
|
||||
}
|
||||
if self.routingBlockIps.count > 0 {
|
||||
ruleBlockIp = getRoutingRule(outTag: "block", domain: nil, ip: self.routingBlockIps, port: nil)
|
||||
@@ -327,79 +327,60 @@ class V2rayConfig: NSObject {
|
||||
case .RoutingRuleGlobal:
|
||||
break
|
||||
case .RoutingRuleLAN:
|
||||
if ruleDirectIp == nil {
|
||||
ruleDirectIp = getRoutingRule(outTag: "direct", domain: nil, ip: ["geoip:private"], port: nil)
|
||||
} else {
|
||||
ruleDirectIp?.domain?.append("geoip:private")
|
||||
}
|
||||
if ruleDirectDomain == nil {
|
||||
ruleDirectDomain = getRoutingRule(outTag: "direct", domain: ["localhost"], ip: nil, port: nil)
|
||||
} else {
|
||||
ruleDirectDomain?.domain?.append("localhost")
|
||||
}
|
||||
ruleDirectIpDefault = getRoutingRule(outTag: "direct", domain: nil, ip: ["geoip:private"], port: nil)
|
||||
ruleDirectDomainDefault = getRoutingRule(outTag: "direct", domain: ["localhost"], ip: nil, port: nil)
|
||||
break
|
||||
case .RoutingRuleCn:
|
||||
if ruleDirectIp == nil {
|
||||
ruleDirectIp = getRoutingRule(outTag: "direct", domain: nil, ip: ["geoip:cn"], port: nil)
|
||||
} else {
|
||||
ruleDirectIp?.domain?.append("geoip:cn")
|
||||
}
|
||||
if ruleDirectDomain == nil {
|
||||
ruleDirectDomain = getRoutingRule(outTag: "direct", domain: ["geosite:cn"], ip: nil, port: nil)
|
||||
} else {
|
||||
ruleDirectDomain?.domain?.append("geosite:cn")
|
||||
}
|
||||
ruleDirectIpDefault = getRoutingRule(outTag: "direct", domain: nil, ip: ["geoip:cn"], port: nil)
|
||||
ruleDirectDomainDefault = getRoutingRule(outTag: "direct", domain: ["geosite:cn"], ip: nil, port: nil)
|
||||
break
|
||||
case .RoutingRuleLANAndCn:
|
||||
if ruleDirectIp == nil {
|
||||
ruleDirectIp = getRoutingRule(outTag: "direct", domain: nil, ip: ["geoip:cn","geoip:private"], port: nil)
|
||||
} else {
|
||||
ruleDirectIp?.ip?.append("geoip:private")
|
||||
ruleDirectIp?.ip?.append("geoip:cn")
|
||||
}
|
||||
if ruleDirectDomain == nil {
|
||||
ruleDirectDomain = getRoutingRule(outTag: "direct", domain: ["geosite:cn","localhost"], ip: nil, port: nil)
|
||||
} else {
|
||||
ruleDirectDomain?.domain?.append("geosite:cn")
|
||||
ruleDirectDomain?.domain?.append("localhost")
|
||||
}
|
||||
ruleDirectIpDefault = getRoutingRule(outTag: "direct", domain: nil, ip: ["geoip:cn","geoip:private"], port: nil)
|
||||
ruleDirectDomainDefault = getRoutingRule(outTag: "direct", domain: ["geosite:cn","localhost"], ip: nil, port: nil)
|
||||
break
|
||||
}
|
||||
// 先block
|
||||
// 域名阻断 -> 域名代理 -> 域名直连 -> IP阻断 -> IP代理 -> IP直连 的优先级进行匹配
|
||||
|
||||
// 域名阻断
|
||||
if ruleBlockDomain != nil {
|
||||
ruleBlockDomain?.ip = nil
|
||||
rules.append(ruleBlockDomain!)
|
||||
}
|
||||
if ruleBlockIp != nil {
|
||||
ruleBlockIp?.domain = nil
|
||||
rules.append(ruleBlockIp!)
|
||||
}
|
||||
// 然后直连
|
||||
if ruleDirectDomain != nil {
|
||||
ruleDirectDomain!.ip = nil
|
||||
rules.append(ruleDirectDomain!)
|
||||
}
|
||||
if ruleDirectIp != nil {
|
||||
ruleDirectIp!.domain = nil
|
||||
rules.append(ruleDirectIp!)
|
||||
}
|
||||
// 最后代理
|
||||
// 域名代理
|
||||
if ruleProxyDomain != nil {
|
||||
ruleProxyDomain?.ip = nil
|
||||
rules.append(ruleProxyDomain!)
|
||||
}
|
||||
// 域名直连
|
||||
if ruleDirectDomain != nil {
|
||||
ruleDirectDomain!.ip = nil
|
||||
rules.append(ruleDirectDomain!)
|
||||
}
|
||||
// IP阻断
|
||||
if ruleBlockIp != nil {
|
||||
ruleBlockIp!.domain = nil
|
||||
rules.append(ruleBlockIp!)
|
||||
}
|
||||
// IP代理
|
||||
if ruleProxyIp != nil {
|
||||
ruleProxyIp?.domain = nil
|
||||
ruleProxyIp!.domain = nil
|
||||
rules.append(ruleProxyIp!)
|
||||
}
|
||||
|
||||
// 默认按端口全部代理
|
||||
var ruleProxyPort = getRoutingRule(outTag: "proxy", domain: nil, ip: nil, port: "0-65535")
|
||||
ruleProxyPort.outboundTag = "proxy"
|
||||
ruleProxyPort.type = "field"
|
||||
ruleProxyPort.port = "0-65535"
|
||||
// rules.append(ruleProxyPort)
|
||||
|
||||
// IP直连
|
||||
if ruleDirectIp != nil {
|
||||
ruleDirectIp!.domain = nil
|
||||
rules.append(ruleDirectIp!)
|
||||
}
|
||||
// 如果匹配失败,则私有地址和大陆境内地址直连,否则走代理。
|
||||
if ruleDirectIpDefault != nil {
|
||||
ruleDirectIpDefault!.domain = nil
|
||||
rules.append(ruleDirectIpDefault!)
|
||||
}
|
||||
if ruleDirectDomainDefault != nil {
|
||||
ruleDirectDomainDefault!.ip = nil
|
||||
rules.append(ruleDirectDomainDefault!)
|
||||
}
|
||||
// 默认全部代理, 无需设置规则
|
||||
// 代理规则
|
||||
self.routing.settings.rules = rules
|
||||
// set v2ray routing
|
||||
|
||||
Reference in New Issue
Block a user