Skip to content

Commit fffd6bd

Browse files
authored
update common options (#2)
1 parent 1cc68b5 commit fffd6bd

File tree

5 files changed

+48
-2
lines changed

5 files changed

+48
-2
lines changed

src/main/core/manager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export function grantCorePermition(corePath: string): void {
7575
try {
7676
if (process.platform === 'linux') {
7777
execSync(
78-
`echo "${password}" | sudo -S setcap cap_net_bind_service,cap_net_admin,cap_dac_override,cap_net_raw=+ep ${corePath}`
78+
`echo "${password}" | sudo -S setcap cap_net_bind_service,cap_net_admin,cap_sys_ptrace,cap_dac_read_search,cap_dac_override,cap_net_raw=+ep ${corePath}`
7979
)
8080
}
8181
if (process.platform === 'darwin') {

src/main/utils/template.ts

+3
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ export const defaultControledMihomoConfig: Partial<IMihomoConfig> = {
1212
mode: 'rule',
1313
'mixed-port': 7890,
1414
'allow-lan': false,
15+
'unified-delay': false,
1516
'log-level': 'info',
17+
'find-process-mode': 'strict',
1618
tun: {
1719
enable: false,
1820
device: 'Mihomo',
1921
stack: 'mixed',
2022
'auto-route': true,
23+
'auto-redirect': false,
2124
'auto-detect-interface': true,
2225
'dns-hijack': ['any:53'],
2326
mtu: 1500

src/renderer/src/pages/mihomo.tsx

+26-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ const Mihomo: React.FC = () => {
2121
'external-controller': externalController,
2222
secret,
2323
'log-level': level = 'info',
24+
'find-process-mode': mode = 'strict',
2425
'allow-lan': lan,
26+
'unified-delay': delay,
2527
'mixed-port': mixedPort = 7890
2628
} = controledMihomoConfig || {}
2729

@@ -150,7 +152,16 @@ const Mihomo: React.FC = () => {
150152
}}
151153
/>
152154
</SettingItem>
153-
<SettingItem title="日志等级">
155+
<SettingItem title="使用RTT延迟测试" divider>
156+
<Switch
157+
size="sm"
158+
isSelected={delay}
159+
onValueChange={(v) => {
160+
onChange({ 'unified-delay': v })
161+
}}
162+
/>
163+
</SettingItem>
164+
<SettingItem title="日志等级" divider>
154165
<Select
155166
className="w-[100px]"
156167
size="sm"
@@ -166,6 +177,20 @@ const Mihomo: React.FC = () => {
166177
<SelectItem key="debug">调试</SelectItem>
167178
</Select>
168179
</SettingItem>
180+
<SettingItem title="查找进程">
181+
<Select
182+
className="w-[100px]"
183+
size="sm"
184+
selectedKeys={new Set([mode])}
185+
onSelectionChange={(v) => {
186+
onChange({ 'find-process-mode': v.currentKey as FindProcessMode })
187+
}}
188+
>
189+
<SelectItem key="strict">自动</SelectItem>
190+
<SelectItem key="off">关闭</SelectItem>
191+
<SelectItem key="always">开启</SelectItem>
192+
</Select>
193+
</SettingItem>
169194
</SettingCard>
170195
</BasePage>
171196
)

src/renderer/src/pages/tun.tsx

+15
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import SettingCard from '@renderer/components/base/base-setting-card'
44
import SettingItem from '@renderer/components/base/base-setting-item'
55
import { useControledMihomoConfig } from '@renderer/hooks/use-controled-mihomo-config'
66
import { restartCore } from '@renderer/utils/ipc'
7+
import { platform } from '@renderer/utils/init'
78
import React, { Key, useState } from 'react'
89

910
const Tun: React.FC = () => {
@@ -13,6 +14,7 @@ const Tun: React.FC = () => {
1314
device = 'Mihomo',
1415
stack = 'mixed',
1516
'auto-route': autoRoute = true,
17+
'auto-redirect': autoRedirect = false,
1618
'auto-detect-interface': autoDetectInterface = true,
1719
'dns-hijack': dnsHijack = ['any:53'],
1820
'strict-route': strictRoute = false,
@@ -23,6 +25,7 @@ const Tun: React.FC = () => {
2325
device,
2426
stack,
2527
autoRoute,
28+
autoRedirect,
2629
autoDetectInterface,
2730
dnsHijack,
2831
strictRoute,
@@ -47,6 +50,7 @@ const Tun: React.FC = () => {
4750
device: values.device,
4851
stack: values.stack,
4952
'auto-route': values.autoRoute,
53+
'auto-redirect': values.autoRedirect,
5054
'auto-detect-interface': values.autoDetectInterface,
5155
'dns-hijack': values.dnsHijack,
5256
'strict-route': values.strictRoute,
@@ -100,6 +104,17 @@ const Tun: React.FC = () => {
100104
}}
101105
/>
102106
</SettingItem>
107+
{platform === 'linux' && (
108+
<SettingItem title="自动设置TCP重定向" divider>
109+
<Switch
110+
size="sm"
111+
isSelected={values.autoRedirect}
112+
onValueChange={(v) => {
113+
setValues({ ...values, autoRedirect: v })
114+
}}
115+
/>
116+
</SettingItem>
117+
)}
103118
<SettingItem title="自动选择流量出口接口" divider>
104119
<Switch
105120
size="sm"

src/shared/types.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ type SysProxyMode = 'auto' | 'manual'
44
type MihomoGroupType = 'Selector'
55
type MihomoProxyType = 'Shadowsocks'
66
type TunStack = 'gvisor' | 'mixed' | 'system'
7+
type FindProcessMode = 'off' | 'strict' | 'always'
78

89
interface IMihomoVersion {
910
version: string
@@ -177,7 +178,9 @@ interface IMihomoConfig {
177178
mode: OutboundMode
178179
'mixed-port': number
179180
'allow-lan': boolean
181+
'unified-delay': boolean
180182
'log-level': LogLevel
183+
'find-process-mode': FindProcessMode
181184
'socks-port'?: number
182185
port?: number
183186
proxies?: []

0 commit comments

Comments
 (0)