Merge branch 'macos-15' into meta-dev

This commit is contained in:
mrFq1 2024-09-21 17:30:32 +08:00
commit fc64af600d
12 changed files with 226 additions and 136 deletions

View File

@ -21,7 +21,7 @@ enum TerminalConfirmAction {
ConfigManager.shared.restoreTunProxy = ConfigManager.shared.isTunModeVariable.value
PrivilegedHelperManager.shared.helper()?.stopMeta()
PrivilegedHelperManager.shared.helper()?.updateTun(state: false)
PrivilegedHelperManager.shared.helper()?.updateTun(state: false, dns: ConfigManager.metaTunDNS)
let path = Paths.tempPath() + "/cacheConfigs"
try? FileManager.default.removeItem(atPath: path)

View File

@ -442,7 +442,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
return
}
PrivilegedHelperManager.shared.helper()?.updateTun(state: enable)
PrivilegedHelperManager.shared.helper()?.updateTun(state: enable, dns: ConfigManager.metaTunDNS)
Logger.log("tun state updated, new: \(enable)")
}
}
@ -578,7 +578,7 @@ extension AppDelegate: ClashProcessDelegate {
if ConfigManager.shared.restoreTunProxy {
ApiRequest.updateTun(enable: true) {
PrivilegedHelperManager.shared.helper()?.updateTun(state: true)
PrivilegedHelperManager.shared.helper()?.updateTun(state: true, dns: ConfigManager.metaTunDNS)
}
} else {
syncConfigWithTun(true)
@ -755,7 +755,7 @@ extension AppDelegate: ApiRequestStreamDelegate {
}
func didGetLog(log: String, level: String) {
Logger.log(log, level: ClashLogLevel(rawValue: level) ?? .unknow)
// Logger.log(log, level: ClashLogLevel(rawValue: level) ?? .unknow)
}
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="23094" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="23094"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
@ -296,15 +296,15 @@
<scrollView borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" translatesAutoresizingMaskIntoConstraints="NO" id="plI-7S-yCW">
<rect key="frame" x="20" y="10" width="392" height="20"/>
<clipView key="contentView" drawsBackground="NO" id="HHy-NP-pH6">
<rect key="frame" x="0.0" y="0.0" width="392" height="20"/>
<rect key="frame" x="0.0" y="0.0" width="377" height="20"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView importsGraphics="NO" richText="NO" verticallyResizable="YES" spellingCorrection="YES" smartInsertDelete="YES" id="sjz-uN-XpL">
<rect key="frame" x="0.0" y="0.0" width="392" height="20"/>
<rect key="frame" x="0.0" y="0.0" width="377" height="20"/>
<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="392" height="20"/>
<size key="minSize" width="377" height="20"/>
<size key="maxSize" width="450" height="10000000"/>
<color key="insertionPointColor" name="textColor" catalog="System" colorSpace="catalog"/>
</textView>
@ -318,7 +318,7 @@
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="OaY-Eu-ksx">
<rect key="frame" x="376" y="0.0" width="16" height="20"/>
<rect key="frame" x="377" y="0.0" width="15" height="20"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
@ -425,15 +425,15 @@
<scrollView borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vfh-gi-qYe">
<rect key="frame" x="20" y="40" width="392" height="100"/>
<clipView key="contentView" drawsBackground="NO" id="bzV-Hc-3eJ">
<rect key="frame" x="0.0" y="0.0" width="392" height="100"/>
<rect key="frame" x="0.0" y="0.0" width="377" height="100"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView importsGraphics="NO" richText="NO" verticallyResizable="YES" spellingCorrection="YES" smartInsertDelete="YES" id="JDw-FW-A2o">
<rect key="frame" x="0.0" y="0.0" width="392" height="100"/>
<rect key="frame" x="0.0" y="0.0" width="377" height="100"/>
<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="392" height="100"/>
<size key="minSize" width="377" height="100"/>
<size key="maxSize" width="450" height="10000000"/>
<color key="insertionPointColor" name="textColor" catalog="System" colorSpace="catalog"/>
</textView>
@ -447,7 +447,7 @@
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="dbQ-aI-3eA">
<rect key="frame" x="376" y="0.0" width="16" height="100"/>
<rect key="frame" x="377" y="0.0" width="15" height="100"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
@ -1951,7 +1951,7 @@
<rect key="frame" x="103" y="-4" width="39" height="25"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" enabled="NO" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="qZF-t6-s4q">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<font key="font" metaFont="message"/>
<menu key="menu" id="XPC-Mb-vvl"/>
</popUpButtonCell>
</popUpButton>

View File

@ -99,6 +99,14 @@ class ConfigManager {
var proxyShouldPaused = BehaviorRelay<Bool>(value: false)
var isTunModeVariable = BehaviorRelay<Bool>(value: false)
static let defaultTunDNS = "8.8.8.8"
static var metaTunDNS: String = UserDefaults.standard.object(forKey: "metaTunDNS") as? String ?? defaultTunDNS {
didSet {
UserDefaults.standard.set(metaTunDNS, forKey: "metaTunDNS")
}
}
var showNetSpeedIndicator: Bool {
get {

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="bU7-R8-ocO">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="23094" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="bU7-R8-ocO">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="23094"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
@ -9,46 +9,103 @@
<scene sceneID="PEd-7d-5j0">
<objects>
<viewController id="bU7-R8-ocO" customClass="MetaPrefsViewController" customModule="ClashX_Meta" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" id="tOy-S4-hL0">
<rect key="frame" x="0.0" y="0.0" width="472" height="332"/>
<view key="view" misplaced="YES" id="tOy-S4-hL0">
<rect key="frame" x="0.0" y="0.0" width="472" height="432"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<stackView distribution="fill" orientation="vertical" alignment="leading" spacing="20" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="0gk-BB-Gdf">
<rect key="frame" x="20" y="20" width="432" height="292"/>
<rect key="frame" x="20" y="20" width="432" height="393"/>
<subviews>
<box borderType="line" title="Meta Setting" translatesAutoresizingMaskIntoConstraints="NO" id="Lcd-RJ-vG1">
<rect key="frame" x="-3" y="238" width="438" height="54"/>
<rect key="frame" x="-3" y="278" width="438" height="115"/>
<view key="contentView" id="U05-m1-3dj">
<rect key="frame" x="3" y="3" width="432" height="36"/>
<rect key="frame" x="4" y="5" width="430" height="95"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Wig-IX-1hV">
<rect key="frame" x="18" y="9" width="135" height="18"/>
<buttonCell key="cell" type="check" title="Hide unselectable" bezelStyle="regularSquare" imagePosition="left" allowsMixedState="YES" inset="2" id="Koj-ew-y0I">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="hideUnselectable:" target="bU7-R8-ocO" id="UQS-Tg-9Uv"/>
</connections>
</button>
<gridView xPlacement="fill" yPlacement="top" rowAlignment="none" rowSpacing="12" columnSpacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="d0F-qy-EB6">
<rect key="frame" x="20" y="10" width="390" height="75"/>
<constraints>
<constraint firstAttribute="height" priority="750" constant="75" id="fyq-n5-2Ix"/>
</constraints>
<rows>
<gridRow id="26k-bz-8yg"/>
<gridRow yPlacement="center" id="xtF-Ze-hcM"/>
<gridRow id="PIc-Wv-hxH"/>
</rows>
<columns>
<gridColumn id="MDQ-YN-zJd"/>
<gridColumn xPlacement="leading" id="UPL-cT-NLz"/>
</columns>
<gridCells>
<gridCell row="26k-bz-8yg" column="MDQ-YN-zJd" headOfMergedCell="2mv-OU-fSM" id="2mv-OU-fSM">
<button key="contentView" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Wig-IX-1hV">
<rect key="frame" x="-2" y="58" width="392" height="18"/>
<buttonCell key="cell" type="check" title="Hide unselectable" bezelStyle="regularSquare" imagePosition="left" allowsMixedState="YES" inset="2" id="Koj-ew-y0I">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="hideUnselectable:" target="bU7-R8-ocO" id="UQS-Tg-9Uv"/>
</connections>
</button>
</gridCell>
<gridCell row="26k-bz-8yg" column="UPL-cT-NLz" headOfMergedCell="2mv-OU-fSM" id="vNI-Dq-n1X"/>
<gridCell row="xtF-Ze-hcM" column="MDQ-YN-zJd" id="1fK-KG-TIa">
<textField key="contentView" focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Syy-v6-wb3">
<rect key="frame" x="-2" y="29" width="61" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Tun DNS:" id="N2a-mI-oqd">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</gridCell>
<gridCell row="xtF-Ze-hcM" column="UPL-cT-NLz" id="vDS-hM-vrm">
<textField key="contentView" focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="YuJ-wO-puO">
<rect key="frame" x="77" y="26" width="180" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="180" id="ijg-Ja-v3G"/>
</constraints>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" placeholderString="0.0.0.0" drawsBackground="YES" id="LKc-Yk-wGS">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<action selector="tunDNSChanged:" target="bU7-R8-ocO" id="Zrz-j3-5bz"/>
</connections>
</textField>
</gridCell>
<gridCell row="PIc-Wv-hxH" column="MDQ-YN-zJd" id="H9O-ll-Z6U"/>
<gridCell row="PIc-Wv-hxH" column="UPL-cT-NLz" id="D61-lb-gFK">
<textField key="contentView" focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="uyA-iw-5fY">
<rect key="frame" x="75" y="0.0" width="106" height="14"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Local DNS is better" id="4Zp-vS-Add">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</gridCell>
</gridCells>
</gridView>
</subviews>
<constraints>
<constraint firstItem="Wig-IX-1hV" firstAttribute="leading" secondItem="U05-m1-3dj" secondAttribute="leading" constant="20" symbolic="YES" id="0g8-Ft-49X"/>
<constraint firstItem="Wig-IX-1hV" firstAttribute="top" secondItem="U05-m1-3dj" secondAttribute="top" constant="10" id="AVb-dh-ckc"/>
<constraint firstAttribute="bottom" secondItem="Wig-IX-1hV" secondAttribute="bottom" constant="10" id="VDC-ux-IGa"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="Wig-IX-1hV" secondAttribute="trailing" constant="20" symbolic="YES" id="qZp-1P-0L4"/>
<constraint firstItem="d0F-qy-EB6" firstAttribute="top" secondItem="U05-m1-3dj" secondAttribute="top" constant="10" id="Qg5-qf-Z0j"/>
<constraint firstItem="d0F-qy-EB6" firstAttribute="leading" secondItem="U05-m1-3dj" secondAttribute="leading" constant="20" symbolic="YES" id="VSd-el-9rZ"/>
<constraint firstAttribute="trailing" secondItem="d0F-qy-EB6" secondAttribute="trailing" constant="20" symbolic="YES" id="bwS-xa-YsK"/>
<constraint firstAttribute="bottom" secondItem="d0F-qy-EB6" secondAttribute="bottom" constant="10" id="e4K-Jx-b7q"/>
</constraints>
</view>
</box>
<box borderType="line" title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="KHD-s8-L0n">
<rect key="frame" x="-3" y="126" width="438" height="98"/>
<rect key="frame" x="-3" y="164" width="438" height="100"/>
<view key="contentView" id="ZgJ-Un-cAG">
<rect key="frame" x="3" y="3" width="432" height="92"/>
<rect key="frame" x="4" y="5" width="430" height="92"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<gridView xPlacement="leading" yPlacement="top" rowAlignment="none" rowSpacing="12" columnSpacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="r7N-5F-w74">
<rect key="frame" x="20" y="10" width="392" height="72"/>
<rect key="frame" x="20" y="10" width="390" height="72"/>
<rows>
<gridRow yPlacement="fill" height="16" id="5H2-9j-Ogj"/>
<gridRow height="16" id="e2a-DC-a5c"/>
@ -60,7 +117,7 @@
</columns>
<gridCells>
<gridCell row="5H2-9j-Ogj" column="MnO-yN-hLw" id="VQj-HB-t6C">
<textField key="contentView" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Vgo-Xk-1pb">
<textField key="contentView" focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Vgo-Xk-1pb">
<rect key="frame" x="-2" y="56" width="74" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Dashboard:" id="GfV-WO-d0g">
<font key="font" usesAppearanceFont="YES"/>
@ -119,13 +176,13 @@
</view>
</box>
<box borderType="line" title="Alpha Core" translatesAutoresizingMaskIntoConstraints="NO" id="jTG-JZ-aJa">
<rect key="frame" x="-3" y="-4" width="438" height="114"/>
<rect key="frame" x="-3" y="32" width="438" height="116"/>
<view key="contentView" id="Xn6-sq-HY0">
<rect key="frame" x="3" y="3" width="432" height="96"/>
<rect key="frame" x="4" y="5" width="430" height="96"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<gridView xPlacement="leading" yPlacement="top" rowAlignment="none" rowSpacing="12" columnSpacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="WT1-lz-2cY">
<rect key="frame" x="20" y="10" width="392" height="76"/>
<rect key="frame" x="20" y="10" width="390" height="76"/>
<rows>
<gridRow height="16" id="IsL-fW-4UR"/>
<gridRow height="16" id="pTu-Kx-Kht"/>
@ -150,7 +207,7 @@
</gridCell>
<gridCell row="IsL-fW-4UR" column="1Gr-S3-ZBU" id="c1k-yH-sOx"/>
<gridCell row="pTu-Kx-Kht" column="u8z-TL-hvE" id="qXc-Dd-A2g">
<textField key="contentView" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="0zZ-n3-FuW">
<textField key="contentView" focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="0zZ-n3-FuW">
<rect key="frame" x="-2" y="32" width="57" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Version: " id="Puz-ig-bL1">
<font key="font" metaFont="system"/>
@ -160,7 +217,7 @@
</textField>
</gridCell>
<gridCell row="pTu-Kx-Kht" column="1Gr-S3-ZBU" id="FUF-Rt-7ec">
<textField key="contentView" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="yKt-RT-uZL">
<textField key="contentView" focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="yKt-RT-uZL">
<rect key="frame" x="136" y="32" width="37" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="HK1-lo-81Z">
<font key="font" usesAppearanceFont="YES"/>
@ -220,16 +277,27 @@
</constraints>
</view>
</box>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="TTD-4f-gyL">
<rect key="frame" x="18" y="0.0" width="396" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Requires restart ClashX Meta to take effect." id="wIw-Pj-t2i">
<font key="font" metaFont="system"/>
<color key="textColor" name="systemOrangeColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<constraints>
<constraint firstItem="KHD-s8-L0n" firstAttribute="leading" secondItem="0gk-BB-Gdf" secondAttribute="leading" id="6Ox-4d-pKO"/>
<constraint firstAttribute="trailing" secondItem="Lcd-RJ-vG1" secondAttribute="trailing" id="9kN-Nw-mb0"/>
<constraint firstAttribute="trailing" secondItem="KHD-s8-L0n" secondAttribute="trailing" id="FHY-Iu-vcs"/>
<constraint firstItem="Lcd-RJ-vG1" firstAttribute="leading" secondItem="0gk-BB-Gdf" secondAttribute="leading" id="OE1-Ap-pHa"/>
<constraint firstItem="Lcd-RJ-vG1" firstAttribute="leading" secondItem="0gk-BB-Gdf" secondAttribute="leading" id="IT4-8w-3dS"/>
<constraint firstAttribute="trailing" secondItem="jTG-JZ-aJa" secondAttribute="trailing" id="Sws-G0-fci"/>
<constraint firstItem="jTG-JZ-aJa" firstAttribute="leading" secondItem="0gk-BB-Gdf" secondAttribute="leading" id="Vka-wv-da2"/>
<constraint firstAttribute="trailing" secondItem="Lcd-RJ-vG1" secondAttribute="trailing" id="ZbI-rR-t7b"/>
<constraint firstAttribute="trailing" secondItem="TTD-4f-gyL" secondAttribute="trailing" constant="20" id="h6f-oT-QRr"/>
<constraint firstItem="TTD-4f-gyL" firstAttribute="leading" secondItem="0gk-BB-Gdf" secondAttribute="leading" constant="20" id="hwO-If-HLk"/>
</constraints>
<visibilityPriorities>
<real value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
@ -238,69 +306,23 @@
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
<box horizontalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="9fd-zM-y8F">
<rect key="frame" x="424" y="40" width="5" height="155"/>
</box>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="xKe-Qu-hcc">
<rect key="frame" x="415" y="193" width="12" height="5"/>
<constraints>
<constraint firstAttribute="width" constant="12" id="GuQ-Wu-4Wd"/>
</constraints>
</box>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="gFx-Lb-iFL">
<rect key="frame" x="415" y="165" width="12" height="5"/>
<constraints>
<constraint firstAttribute="width" constant="12" id="Y0d-Xy-ztL"/>
</constraints>
</box>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="FrB-J6-MgI">
<rect key="frame" x="415" y="95" width="12" height="5"/>
<constraints>
<constraint firstAttribute="width" constant="12" id="DFM-5Q-cRE"/>
</constraints>
</box>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="bHj-ai-2Dz">
<rect key="frame" x="415" y="37" width="12" height="5"/>
<constraints>
<constraint firstAttribute="width" constant="12" id="c8e-Ar-gqj"/>
</constraints>
</box>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="V9S-ix-ppO">
<rect key="frame" x="274" y="127" width="135" height="14"/>
<textFieldCell key="cell" controlSize="small" lineBreakMode="clipping" alignment="right" title="restart app to take effect" id="oLx-08-DXe">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<constraints>
<constraint firstItem="9fd-zM-y8F" firstAttribute="top" secondItem="xKe-Qu-hcc" secondAttribute="bottom" id="2VP-FN-ddK"/>
<constraint firstAttribute="bottom" secondItem="0gk-BB-Gdf" secondAttribute="bottom" priority="999" constant="20" symbolic="YES" id="41D-Qn-QFB"/>
<constraint firstItem="gFx-Lb-iFL" firstAttribute="trailing" secondItem="9fd-zM-y8F" secondAttribute="trailing" id="9z4-Fn-nJO"/>
<constraint firstItem="bHj-ai-2Dz" firstAttribute="centerY" secondItem="SRr-f9-XRY" secondAttribute="centerY" id="B4j-kO-o2T"/>
<constraint firstItem="V9S-ix-ppO" firstAttribute="top" secondItem="KHD-s8-L0n" secondAttribute="bottom" constant="9" id="DJP-lb-FuN"/>
<constraint firstItem="V9S-ix-ppO" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="tOy-S4-hL0" secondAttribute="leading" constant="20" id="Dz5-P4-oOk"/>
<constraint firstItem="0gk-BB-Gdf" firstAttribute="top" secondItem="tOy-S4-hL0" secondAttribute="top" constant="20" id="HMj-bI-0qk"/>
<constraint firstItem="0gk-BB-Gdf" firstAttribute="leading" secondItem="tOy-S4-hL0" secondAttribute="leading" constant="20" symbolic="YES" id="IiH-bU-bk9"/>
<constraint firstItem="FrB-J6-MgI" firstAttribute="trailing" secondItem="9fd-zM-y8F" secondAttribute="trailing" id="L7H-ES-XI6"/>
<constraint firstItem="V9S-ix-ppO" firstAttribute="trailing" secondItem="9fd-zM-y8F" secondAttribute="trailing" constant="-20" id="atW-G9-M0a"/>
<constraint firstAttribute="trailing" secondItem="9fd-zM-y8F" secondAttribute="trailing" constant="45" id="f2U-NH-55J"/>
<constraint firstAttribute="trailing" secondItem="0gk-BB-Gdf" secondAttribute="trailing" constant="20" symbolic="YES" id="hOC-5w-szi"/>
<constraint firstItem="xKe-Qu-hcc" firstAttribute="centerY" secondItem="Fty-b5-ZE7" secondAttribute="centerY" id="jNu-jR-KyJ"/>
<constraint firstItem="gFx-Lb-iFL" firstAttribute="centerY" secondItem="uY1-el-AeU" secondAttribute="centerY" id="lr1-In-RzS"/>
<constraint firstItem="xKe-Qu-hcc" firstAttribute="trailing" secondItem="9fd-zM-y8F" secondAttribute="trailing" id="mno-6k-HO6"/>
<constraint firstItem="bHj-ai-2Dz" firstAttribute="top" secondItem="9fd-zM-y8F" secondAttribute="bottom" id="ptj-PV-RkG"/>
<constraint firstItem="bHj-ai-2Dz" firstAttribute="trailing" secondItem="9fd-zM-y8F" secondAttribute="trailing" id="scw-5M-2fP"/>
<constraint firstItem="FrB-J6-MgI" firstAttribute="centerY" secondItem="dqT-AG-7Ec" secondAttribute="centerY" id="z60-DQ-YoZ"/>
</constraints>
</view>
<connections>
<outlet property="alphaVersionTextField" destination="yKt-RT-uZL" id="A2m-kO-WMQ"/>
<outlet property="hideUnselectableButton" destination="Wig-IX-1hV" id="9dI-B3-Tbe"/>
<outlet property="restartTextField" destination="TTD-4f-gyL" id="gDw-gY-aSm"/>
<outlet property="showAlphaButton" destination="UWj-Su-skJ" id="v29-ZT-4mA"/>
<outlet property="tunDNSTextField" destination="YuJ-wO-puO" id="4xw-eF-vnz"/>
<outlet property="updateButton" destination="SRr-f9-XRY" id="suh-eD-eh8"/>
<outlet property="updateProgressIndicator" destination="ZLW-Hh-cDO" id="Ojv-7K-OyZ"/>
<outlet property="useAlphaButton" destination="dqT-AG-7Ec" id="vYv-Uc-vuI"/>

View File

@ -6,6 +6,7 @@
//
import Cocoa
import Network
class MetaPrefsViewController: NSViewController {
// Meta Setting
@ -28,6 +29,14 @@ class MetaPrefsViewController: NSViewController {
MenuItemFactory.hideUnselectable = newState.rawValue
}
@IBOutlet var tunDNSTextField: NSTextField!
@IBAction func tunDNSChanged(_ sender: NSTextField) {
let ds = sender.stringValue
guard let _ = IPv4Address(ds) else { return }
ConfigManager.metaTunDNS = ds
updateNeedsRestart()
}
// Dashboard
@IBOutlet var useSwiftuiButton: NSButton!
@IBOutlet var useYacdButton: NSButton!
@ -47,6 +56,7 @@ class MetaPrefsViewController: NSViewController {
break
}
initDashboardButtons()
updateNeedsRestart()
}
// Alpha Core
@ -71,6 +81,7 @@ class MetaPrefsViewController: NSViewController {
let use = sender.state == .on
ConfigManager.useAlphaCore = use
updateNeedsRestart()
}
@IBAction func updateAlpha(_ sender: NSButton) {
@ -104,11 +115,21 @@ class MetaPrefsViewController: NSViewController {
}
@IBOutlet var restartTextField: NSTextField!
var prefsSnapshot = [String]()
var versionSnapshot = "none"
var alphaCoreUpdated = false
override func viewDidLoad() {
super.viewDidLoad()
// Meta Setting
hideUnselectableButton.state = .init(rawValue: MenuItemFactory.hideUnselectable)
tunDNSTextField.placeholderString = ConfigManager.defaultTunDNS
tunDNSTextField.stringValue = ConfigManager.metaTunDNS
tunDNSTextField.delegate = self
// Dashboard
initDashboardButtons()
@ -116,6 +137,11 @@ class MetaPrefsViewController: NSViewController {
useAlphaButton.state = ConfigManager.useAlphaCore ? .on : .off
updateProgressIndicator.isHidden = true
setAlphaVersion()
// Snapshot
prefsSnapshot = takePrefsSnapshot()
versionSnapshot = alphaVersionTextField.stringValue
restartTextField.isHidden = true
}
func initDashboardButtons() {
@ -156,6 +182,31 @@ class MetaPrefsViewController: NSViewController {
alphaVersionTextField.stringValue = "none"
updateButton.title = NSLocalizedString("Download Meta core", comment: "")
}
if let v = version,
versionSnapshot != "none",
v != versionSnapshot {
alphaCoreUpdated = true
updateNeedsRestart()
}
}
func takePrefsSnapshot() -> [String] {
[
ConfigManager.metaTunDNS,
"\(ConfigManager.useYacdDashboard)",
"\(ConfigManager.useAlphaCore)"
]
}
func updateNeedsRestart() {
let needsRestart = prefsSnapshot != takePrefsSnapshot() || alphaCoreUpdated
restartTextField.isHidden = !needsRestart
}
}
extension MetaPrefsViewController: NSTextFieldDelegate {
func control(_ control: NSControl, textShouldEndEditing fieldEditor: NSText) -> Bool {
IPv4Address(fieldEditor.string) != nil
}
}

View File

@ -1,15 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="19162" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="23094" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19162"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="23094"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner"/>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView misplaced="YES" id="c22-O7-iKe" customClass="RemoteConfigAddView" customModule="ClashX_Pro" customModuleProvider="target">
<customView misplaced="YES" id="c22-O7-iKe" customClass="RemoteConfigAddView" customModule="ClashX_Meta" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="338" height="54"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>

View File

@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="23094" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21701"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="23094"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@ -24,7 +23,7 @@
<customView translatesAutoresizingMaskIntoConstraints="NO" id="x4I-nn-92U">
<rect key="frame" x="38" y="0.0" width="24" height="22"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Hlw-Vg-wLD">
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Hlw-Vg-wLD">
<rect key="frame" x="-2" y="1" width="28" height="10"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="0KB/s" id="Cy5-d1-ldi">
<font key="font" metaFont="system" size="8"/>
@ -32,7 +31,7 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="srp-1R-o7n">
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="srp-1R-o7n">
<rect key="frame" x="-2" y="11" width="28" height="10"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="0KB/s" id="oCt-YG-3AI">
<font key="font" metaFont="system" size="8"/>
@ -69,6 +68,6 @@
</customView>
</objects>
<resources>
<image name="menu_icon" width="1024" height="1024"/>
<image name="menu_icon" width="16" height="16"/>
</resources>
</document>

View File

@ -9,9 +9,9 @@
<key>CFBundleName</key>
<string>com.metacubex.ClashX.ProxyConfigHelper</string>
<key>CFBundleShortVersionString</key>
<string>1.12</string>
<string>1.13</string>
<key>CFBundleVersion</key>
<string>22</string>
<string>23</string>
<key>SMAuthorizedClients</key>
<array>
<string>anchor apple generic and identifier &quot;com.metacubex.ClashX.ProxyConfigHelper&quot; and (certificate leaf[field.1.2.840.113635.100.6.1.9] /* exists */ or certificate 1[field.1.2.840.113635.100.6.2.6] /* exists */ and certificate leaf[field.1.2.840.113635.100.6.1.13] /* exists */ and certificate leaf[subject.OU] = MEWHFZ92DY)</string>

View File

@ -10,10 +10,10 @@ import SystemConfiguration
// https://github.com/zhuhaow/Specht2/blob/main/app/me.zhuhaow.Specht2.proxy-helper/ProxyHelper.swift
class MetaDNS: NSObject {
var savedDns = [String: [String]]()
let defaultDNS = "198.18.0.2"
private var customDNS = "8.8.8.8"
static let savedDNSKey = "ProxyConfigHelper.SavedSystemDNSs"
var savedDNS = [String: [String]]()
let authRef: AuthorizationRef
override init() {
@ -29,7 +29,13 @@ class MetaDNS: NSObject {
if auth == nil {
NSLog("Error: No authorization has been granted to modify network configuration.")
}
if let data = UserDefaults.standard.data(forKey: MetaDNS.savedDNSKey),
let saved = try? JSONDecoder().decode([String: [String]].self, from: data) {
self.savedDNS = saved
}
authRef = auth!
super.init()
@ -39,31 +45,35 @@ class MetaDNS: NSObject {
AuthorizationFree(authRef, AuthorizationFlags())
}
@objc func updateDns() {
let dns = getAllDns()
dns.forEach {
if $0.value.count == 1,
$0.value[0] == defaultDNS {
if savedDns[$0.key] == nil {
savedDns[$0.key] = []
} else {
// ignore save
}
} else {
savedDns[$0.key] = $0.value
}
}
@objc func setCustomDNS(_ dns: String) {
customDNS = dns
}
@objc func hijackDNS() {
let dns = getAllDns()
let hijacked = dns.allSatisfy {
$0.value.count == 1 && $0.value[0] == customDNS
}
guard !hijacked else { return }
savedDNS = dns
if let data = try? JSONEncoder().encode(savedDNS) {
UserDefaults.standard.set(data, forKey: MetaDNS.savedDNSKey)
}
let dnsDic = dns.reduce(into: [:]) {
$0[$1.key] = [defaultDNS]
$0[$1.key] = [customDNS]
}
updateDNSConfigure(dnsDic)
}
@objc func revertDns() {
updateDNSConfigure(savedDns)
savedDns.removeAll()
@objc func revertDNS() {
guard savedDNS.count > 0 else { return }
updateDNSConfigure(savedDNS)
savedDNS.removeAll()
UserDefaults.standard.removeObject(forKey: MetaDNS.savedDNSKey)
}
func getAllDns() -> [String: [String]] {

View File

@ -132,12 +132,13 @@ extension ProxyConfigHelper: ProxyConfigRemoteProcessProtocol {
}
}
func updateTun(state: Bool) {
func updateTun(state: Bool, dns: String) {
DispatchQueue.main.async {
self.metaDNS.setCustomDNS(dns)
if state {
self.metaDNS.updateDns()
self.metaDNS.hijackDNS()
} else {
self.metaDNS.revertDns()
self.metaDNS.revertDNS()
}
self.metaDNS.flushDnsCache()
}

View File

@ -13,7 +13,7 @@ protocol ProxyConfigRemoteProcessProtocol {
func startMeta(path: String, confPath: String, confFilePath: String, confJSON: String, reply: @escaping (String?) -> Void)
func stopMeta()
func updateTun(state: Bool)
func updateTun(state: Bool, dns: String)
func getUsedPorts(reply: @escaping (String?) -> Void)