mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-07 20:45:48 +08:00
fix: macOS-specific TUN device name on macOS
This commit is contained in:
parent
9d9dd73790
commit
f6023dc618
@ -14,6 +14,9 @@ import { useClash } from "@/hooks/use-clash";
|
|||||||
import { BaseDialog, DialogRef, Notice, Switch } from "@/components/base";
|
import { BaseDialog, DialogRef, Notice, Switch } from "@/components/base";
|
||||||
import { StackModeSwitch } from "./stack-mode-switch";
|
import { StackModeSwitch } from "./stack-mode-switch";
|
||||||
import { enhanceProfiles } from "@/services/cmds";
|
import { enhanceProfiles } from "@/services/cmds";
|
||||||
|
import getSystem from "@/utils/get-system";
|
||||||
|
|
||||||
|
const OS = getSystem();
|
||||||
|
|
||||||
export const TunViewer = forwardRef<DialogRef>((props, ref) => {
|
export const TunViewer = forwardRef<DialogRef>((props, ref) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@ -23,7 +26,7 @@ export const TunViewer = forwardRef<DialogRef>((props, ref) => {
|
|||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [values, setValues] = useState({
|
const [values, setValues] = useState({
|
||||||
stack: "mixed",
|
stack: "mixed",
|
||||||
device: "Mihomo",
|
device: OS === "macos" ? "utun1024" : "Mihomo",
|
||||||
autoRoute: true,
|
autoRoute: true,
|
||||||
autoDetectInterface: true,
|
autoDetectInterface: true,
|
||||||
dnsHijack: ["any:53"],
|
dnsHijack: ["any:53"],
|
||||||
@ -36,7 +39,7 @@ export const TunViewer = forwardRef<DialogRef>((props, ref) => {
|
|||||||
setOpen(true);
|
setOpen(true);
|
||||||
setValues({
|
setValues({
|
||||||
stack: clash?.tun.stack ?? "gvisor",
|
stack: clash?.tun.stack ?? "gvisor",
|
||||||
device: clash?.tun.device ?? "Mihomo",
|
device: clash?.tun.device ?? (OS === "macos" ? "utun1024" : "Mihomo"),
|
||||||
autoRoute: clash?.tun["auto-route"] ?? true,
|
autoRoute: clash?.tun["auto-route"] ?? true,
|
||||||
autoDetectInterface: clash?.tun["auto-detect-interface"] ?? true,
|
autoDetectInterface: clash?.tun["auto-detect-interface"] ?? true,
|
||||||
dnsHijack: clash?.tun["dns-hijack"] ?? ["any:53"],
|
dnsHijack: clash?.tun["dns-hijack"] ?? ["any:53"],
|
||||||
@ -51,7 +54,12 @@ export const TunViewer = forwardRef<DialogRef>((props, ref) => {
|
|||||||
try {
|
try {
|
||||||
let tun = {
|
let tun = {
|
||||||
stack: values.stack,
|
stack: values.stack,
|
||||||
device: values.device === "" ? "Mihomo" : values.device,
|
device:
|
||||||
|
values.device === ""
|
||||||
|
? OS === "macos"
|
||||||
|
? "utun1024"
|
||||||
|
: "Mihomo"
|
||||||
|
: values.device,
|
||||||
"auto-route": values.autoRoute,
|
"auto-route": values.autoRoute,
|
||||||
"auto-detect-interface": values.autoDetectInterface,
|
"auto-detect-interface": values.autoDetectInterface,
|
||||||
"dns-hijack": values.dnsHijack[0] === "" ? [] : values.dnsHijack,
|
"dns-hijack": values.dnsHijack[0] === "" ? [] : values.dnsHijack,
|
||||||
@ -90,7 +98,7 @@ export const TunViewer = forwardRef<DialogRef>((props, ref) => {
|
|||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
let tun = {
|
let tun = {
|
||||||
stack: "gvisor",
|
stack: "gvisor",
|
||||||
device: "Mihomo",
|
device: OS === "macos" ? "utun1024" : "Mihomo",
|
||||||
"auto-route": true,
|
"auto-route": true,
|
||||||
"auto-detect-interface": true,
|
"auto-detect-interface": true,
|
||||||
"dns-hijack": ["any:53"],
|
"dns-hijack": ["any:53"],
|
||||||
@ -99,7 +107,7 @@ export const TunViewer = forwardRef<DialogRef>((props, ref) => {
|
|||||||
};
|
};
|
||||||
setValues({
|
setValues({
|
||||||
stack: "gvisor",
|
stack: "gvisor",
|
||||||
device: "Mihomo",
|
device: OS === "macos" ? "utun1024" : "Mihomo",
|
||||||
autoRoute: true,
|
autoRoute: true,
|
||||||
autoDetectInterface: true,
|
autoDetectInterface: true,
|
||||||
dnsHijack: ["any:53"],
|
dnsHijack: ["any:53"],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user