mirror of
https://github.com/pompurin404/mihomo-party.git
synced 2024-11-16 11:42:19 +08:00
set external controller at core launch
Some checks are pending
Build / windows (arm64) (push) Waiting to run
Build / windows (ia32) (push) Waiting to run
Build / windows (x64) (push) Waiting to run
Build / windows7 (ia32) (push) Waiting to run
Build / windows7 (x64) (push) Waiting to run
Build / linux (arm64) (push) Waiting to run
Build / linux (x64) (push) Waiting to run
Build / macos (arm64) (push) Waiting to run
Build / macos (x64) (push) Waiting to run
Build / updater (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-bin) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-electron) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-electron-bin) (push) Blocked by required conditions
Build / aur-git-updater (push) Waiting to run
Build / Update WinGet Package (push) Blocked by required conditions
Build / Update Homebrew cask (push) Blocked by required conditions
Some checks are pending
Build / windows (arm64) (push) Waiting to run
Build / windows (ia32) (push) Waiting to run
Build / windows (x64) (push) Waiting to run
Build / windows7 (ia32) (push) Waiting to run
Build / windows7 (x64) (push) Waiting to run
Build / linux (arm64) (push) Waiting to run
Build / linux (x64) (push) Waiting to run
Build / macos (arm64) (push) Waiting to run
Build / macos (x64) (push) Waiting to run
Build / updater (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-bin) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-electron) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-electron-bin) (push) Blocked by required conditions
Build / aur-git-updater (push) Waiting to run
Build / Update WinGet Package (push) Blocked by required conditions
Build / Update Homebrew cask (push) Blocked by required conditions
This commit is contained in:
parent
6eb41dfcf0
commit
349e4221a6
|
@ -45,6 +45,10 @@ chokidar.watch(path.join(mihomoCoreDir(), 'meta-update'), {}).on('unlinkDir', as
|
|||
}
|
||||
})
|
||||
|
||||
export const mihomoIpcPath =
|
||||
process.platform === 'win32' ? '\\\\.\\pipe\\MihomoParty\\mihomo' : '/tmp/mihomo-party.sock'
|
||||
const ctlParam = process.platform === 'win32' ? '-ext-ctl-pipe' : '-ext-ctl-unix'
|
||||
|
||||
let setPublicDNSTimer: NodeJS.Timeout | null = null
|
||||
let recoverDNSTimer: NodeJS.Timeout | null = null
|
||||
let child: ChildProcess
|
||||
|
@ -87,7 +91,8 @@ export async function startCore(detached = false): Promise<Promise<void>[]> {
|
|||
})
|
||||
}
|
||||
}
|
||||
child = spawn(corePath, ['-d', mihomoWorkDir()], {
|
||||
|
||||
child = spawn(corePath, ['-d', mihomoWorkDir(), ctlParam, mihomoIpcPath], {
|
||||
detached: detached,
|
||||
stdio: detached ? 'ignore' : undefined
|
||||
})
|
||||
|
|
|
@ -6,6 +6,7 @@ import { tray } from '../resolve/tray'
|
|||
import { calcTraffic } from '../utils/calc'
|
||||
import { getRuntimeConfig } from './factory'
|
||||
import { floatingWindow } from '../resolve/floatingWindow'
|
||||
import { mihomoIpcPath } from './manager'
|
||||
|
||||
let axiosIns: AxiosInstance = null!
|
||||
let mihomoTrafficWs: WebSocket | null = null
|
||||
|
@ -18,15 +19,11 @@ let mihomoConnectionsWs: WebSocket | null = null
|
|||
let connectionsRetry = 10
|
||||
|
||||
export const getAxios = async (force: boolean = false): Promise<AxiosInstance> => {
|
||||
const {
|
||||
'external-controller-pipe': mihomoPipe = '\\\\.\\pipe\\MihomoParty\\mihomo',
|
||||
'external-controller-unix': mihomoUnix = '/tmp/mihomo-party.sock'
|
||||
} = await getControledMihomoConfig()
|
||||
if (axiosIns && !force) return axiosIns
|
||||
|
||||
axiosIns = axios.create({
|
||||
baseURL: `http://localhost`,
|
||||
socketPath: process.platform === 'win32' ? mihomoPipe : mihomoUnix,
|
||||
socketPath: mihomoIpcPath,
|
||||
timeout: 15000
|
||||
})
|
||||
|
||||
|
@ -180,14 +177,7 @@ export const stopMihomoTraffic = (): void => {
|
|||
}
|
||||
|
||||
const mihomoTraffic = async (): Promise<void> => {
|
||||
const {
|
||||
'external-controller-pipe': mihomoPipe = '\\\\.\\pipe\\MihomoParty\\mihomo',
|
||||
'external-controller-unix': mihomoUnix = '/tmp/mihomo-party.sock'
|
||||
} = await getControledMihomoConfig()
|
||||
|
||||
mihomoTrafficWs = new WebSocket(
|
||||
`ws+unix:${process.platform === 'win32' ? mihomoPipe : mihomoUnix}:/traffic`
|
||||
)
|
||||
mihomoTrafficWs = new WebSocket(`ws+unix:${mihomoIpcPath}:/traffic`)
|
||||
|
||||
mihomoTrafficWs.onmessage = async (e): Promise<void> => {
|
||||
const data = e.data as string
|
||||
|
@ -239,14 +229,7 @@ export const stopMihomoMemory = (): void => {
|
|||
}
|
||||
|
||||
const mihomoMemory = async (): Promise<void> => {
|
||||
const {
|
||||
'external-controller-pipe': mihomoPipe = '\\\\.\\pipe\\MihomoParty\\mihomo',
|
||||
'external-controller-unix': mihomoUnix = '/tmp/mihomo-party.sock'
|
||||
} = await getControledMihomoConfig()
|
||||
|
||||
mihomoMemoryWs = new WebSocket(
|
||||
`ws+unix:${process.platform === 'win32' ? mihomoPipe : mihomoUnix}:/memory`
|
||||
)
|
||||
mihomoMemoryWs = new WebSocket(`ws+unix:${mihomoIpcPath}:/memory`)
|
||||
|
||||
mihomoMemoryWs.onmessage = (e): void => {
|
||||
const data = e.data as string
|
||||
|
@ -288,15 +271,9 @@ export const stopMihomoLogs = (): void => {
|
|||
}
|
||||
|
||||
const mihomoLogs = async (): Promise<void> => {
|
||||
const {
|
||||
'external-controller-pipe': mihomoPipe = '\\\\.\\pipe\\MihomoParty\\mihomo',
|
||||
'external-controller-unix': mihomoUnix = '/tmp/mihomo-party.sock',
|
||||
'log-level': logLevel = 'info'
|
||||
} = await getControledMihomoConfig()
|
||||
const { 'log-level': logLevel = 'info' } = await getControledMihomoConfig()
|
||||
|
||||
mihomoLogsWs = new WebSocket(
|
||||
`ws+unix:${process.platform === 'win32' ? mihomoPipe : mihomoUnix}:/logs?level=${logLevel}`
|
||||
)
|
||||
mihomoLogsWs = new WebSocket(`ws+unix:${mihomoIpcPath}:/logs?level=${logLevel}`)
|
||||
|
||||
mihomoLogsWs.onmessage = (e): void => {
|
||||
const data = e.data as string
|
||||
|
@ -338,14 +315,7 @@ export const stopMihomoConnections = (): void => {
|
|||
}
|
||||
|
||||
const mihomoConnections = async (): Promise<void> => {
|
||||
const {
|
||||
'external-controller-pipe': mihomoPipe = '\\\\.\\pipe\\MihomoParty\\mihomo',
|
||||
'external-controller-unix': mihomoUnix = '/tmp/mihomo-party.sock'
|
||||
} = await getControledMihomoConfig()
|
||||
|
||||
mihomoConnectionsWs = new WebSocket(
|
||||
`ws+unix:${process.platform === 'win32' ? mihomoPipe : mihomoUnix}:/connections`
|
||||
)
|
||||
mihomoConnectionsWs = new WebSocket(`ws+unix:${mihomoIpcPath}:/connections`)
|
||||
|
||||
mihomoConnectionsWs.onmessage = (e): void => {
|
||||
const data = e.data as string
|
||||
|
|
|
@ -195,16 +195,13 @@ async function migration(): Promise<void> {
|
|||
await patchAppConfig({ envType: [envType] })
|
||||
}
|
||||
// use unix socket
|
||||
if (process.platform !== 'win32' && externalControllerUnix !== '/tmp/mihomo-party.sock') {
|
||||
await patchControledMihomoConfig({ 'external-controller-unix': '/tmp/mihomo-party.sock' })
|
||||
if (externalControllerUnix) {
|
||||
await patchControledMihomoConfig({ 'external-controller-unix': undefined })
|
||||
}
|
||||
// use named pipe
|
||||
if (
|
||||
process.platform === 'win32' &&
|
||||
externalControllerPipe !== '\\\\.\\pipe\\MihomoParty\\mihomo'
|
||||
) {
|
||||
if (externalControllerPipe) {
|
||||
await patchControledMihomoConfig({
|
||||
'external-controller-pipe': '\\\\.\\pipe\\MihomoParty\\mihomo'
|
||||
'external-controller-pipe': undefined
|
||||
})
|
||||
}
|
||||
if (externalController === undefined) {
|
||||
|
|
|
@ -36,8 +36,6 @@ export const defaultConfig: IAppConfig = {
|
|||
}
|
||||
|
||||
export const defaultControledMihomoConfig: Partial<IMihomoConfig> = {
|
||||
'external-controller-pipe': '\\\\.pipe\\MihomoParty\\mihomo',
|
||||
'external-controller-unix': '/tmp/mihomo-party.sock',
|
||||
'external-controller': '',
|
||||
ipv6: true,
|
||||
mode: 'rule',
|
||||
|
|
Loading…
Reference in New Issue
Block a user