mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-06 03:26:51 +03:00
refactor: reorganize all methods
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
export * from './types';
|
||||
export * from './createBaseApiRequest';
|
||||
@@ -1,9 +0,0 @@
|
||||
export type IBaseApiResponse<T> =
|
||||
| {
|
||||
success: true;
|
||||
data: T;
|
||||
}
|
||||
| {
|
||||
success: false;
|
||||
message: string;
|
||||
};
|
||||
@@ -1,2 +0,0 @@
|
||||
export * from './types';
|
||||
export * from './methods';
|
||||
@@ -1,14 +0,0 @@
|
||||
import { ClashAPI } from '../types';
|
||||
import { getClashApiUrl } from '../../helpers';
|
||||
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
||||
|
||||
export async function getClashConfig(): Promise<
|
||||
IBaseApiResponse<ClashAPI.Config>
|
||||
> {
|
||||
return createBaseApiRequest<ClashAPI.Config>(() =>
|
||||
fetch(`${getClashApiUrl()}/configs`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import { ClashAPI } from '../types';
|
||||
import { getClashApiUrl } from '../../helpers';
|
||||
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
||||
|
||||
export async function getClashGroupDelay(
|
||||
group: string,
|
||||
url = 'https://www.gstatic.com/generate_204',
|
||||
timeout = 2000,
|
||||
): Promise<IBaseApiResponse<ClashAPI.Delays>> {
|
||||
const endpoint = `${getClashApiUrl()}/group/${group}/delay?url=${encodeURIComponent(
|
||||
url,
|
||||
)}&timeout=${timeout}`;
|
||||
|
||||
return createBaseApiRequest<ClashAPI.Delays>(() =>
|
||||
fetch(endpoint, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import { ClashAPI } from '../types';
|
||||
import { getClashApiUrl } from '../../helpers';
|
||||
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
||||
|
||||
export async function getClashVersion(): Promise<
|
||||
IBaseApiResponse<ClashAPI.Version>
|
||||
> {
|
||||
return createBaseApiRequest<ClashAPI.Version>(() =>
|
||||
fetch(`${getClashApiUrl()}/version`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
export * from './getConfig';
|
||||
export * from './getGroupDelay';
|
||||
export * from './getProxies';
|
||||
export * from './getVersion';
|
||||
export * from './triggerProxySelector';
|
||||
export * from './triggerLatencyTest';
|
||||
@@ -1,34 +0,0 @@
|
||||
import { getClashApiUrl } from '../../helpers';
|
||||
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
||||
|
||||
export async function triggerLatencyGroupTest(
|
||||
tag: string,
|
||||
timeout: number = 5000,
|
||||
url: string = 'https://www.gstatic.com/generate_204',
|
||||
): Promise<IBaseApiResponse<void>> {
|
||||
return createBaseApiRequest<void>(() =>
|
||||
fetch(
|
||||
`${getClashApiUrl()}/group/${tag}/delay?url=${encodeURIComponent(url)}&timeout=${timeout}`,
|
||||
{
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export async function triggerLatencyProxyTest(
|
||||
tag: string,
|
||||
timeout: number = 2000,
|
||||
url: string = 'https://www.gstatic.com/generate_204',
|
||||
): Promise<IBaseApiResponse<void>> {
|
||||
return createBaseApiRequest<void>(() =>
|
||||
fetch(
|
||||
`${getClashApiUrl()}/proxies/${tag}/delay?url=${encodeURIComponent(url)}&timeout=${timeout}`,
|
||||
{
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
export namespace ClashAPI {
|
||||
export interface Version {
|
||||
meta: boolean;
|
||||
premium: boolean;
|
||||
version: string;
|
||||
}
|
||||
|
||||
export interface Config {
|
||||
port: number;
|
||||
'socks-port': number;
|
||||
'redir-port': number;
|
||||
'tproxy-port': number;
|
||||
'mixed-port': number;
|
||||
'allow-lan': boolean;
|
||||
'bind-address': string;
|
||||
mode: 'Rule' | 'Global' | 'Direct';
|
||||
'mode-list': string[];
|
||||
'log-level': 'debug' | 'info' | 'warn' | 'error';
|
||||
ipv6: boolean;
|
||||
tun: null | Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface ProxyHistoryEntry {
|
||||
time: string;
|
||||
delay: number;
|
||||
}
|
||||
|
||||
export interface ProxyBase {
|
||||
type: string;
|
||||
name: string;
|
||||
udp: boolean;
|
||||
history: ProxyHistoryEntry[];
|
||||
now?: string;
|
||||
all?: string[];
|
||||
}
|
||||
|
||||
export interface Proxies {
|
||||
proxies: Record<string, ProxyBase>;
|
||||
}
|
||||
|
||||
export type Delays = Record<string, number>;
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export * from './methods';
|
||||
@@ -1,2 +0,0 @@
|
||||
export * from './getIpCheck';
|
||||
export * from './getFakeIpCheck';
|
||||
@@ -5,6 +5,5 @@
|
||||
|
||||
export * from './validators';
|
||||
export * from './helpers';
|
||||
export * from './clash';
|
||||
export * from './podkop';
|
||||
export * from './constants';
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { IBaseApiResponse } from './types';
|
||||
import { withTimeout } from '../helpers';
|
||||
|
||||
export async function createBaseApiRequest<T>(
|
||||
@@ -42,3 +41,13 @@ export async function createBaseApiRequest<T>(
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export type IBaseApiResponse<T> =
|
||||
| {
|
||||
success: true;
|
||||
data: T;
|
||||
}
|
||||
| {
|
||||
success: false;
|
||||
message: string;
|
||||
};
|
||||
18
fe-app-podkop/src/podkop/methods/clash/getGroupLatency.ts
Normal file
18
fe-app-podkop/src/podkop/methods/clash/getGroupLatency.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { getClashApiUrl } from '../../../helpers';
|
||||
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
||||
|
||||
export async function getGroupLatency(
|
||||
tag: string,
|
||||
timeout: number = 5000,
|
||||
url: string = 'https://www.gstatic.com/generate_204',
|
||||
): Promise<IBaseApiResponse<void>> {
|
||||
return createBaseApiRequest<void>(() =>
|
||||
fetch(
|
||||
`${getClashApiUrl()}/group/${tag}/delay?url=${encodeURIComponent(url)}&timeout=${timeout}`,
|
||||
{
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import { ClashAPI } from '../types';
|
||||
import { getClashApiUrl } from '../../helpers';
|
||||
import { ClashAPI } from '../../types';
|
||||
import { getClashApiUrl } from '../../../helpers';
|
||||
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
||||
|
||||
export async function getClashProxies(): Promise<
|
||||
export async function getProxies(): Promise<
|
||||
IBaseApiResponse<ClashAPI.Proxies>
|
||||
> {
|
||||
return createBaseApiRequest<ClashAPI.Proxies>(() =>
|
||||
18
fe-app-podkop/src/podkop/methods/clash/getProxyLatency.ts
Normal file
18
fe-app-podkop/src/podkop/methods/clash/getProxyLatency.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { getClashApiUrl } from '../../../helpers';
|
||||
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
||||
|
||||
export async function getProxyLatency(
|
||||
tag: string,
|
||||
timeout: number = 2000,
|
||||
url: string = 'https://www.gstatic.com/generate_204',
|
||||
): Promise<IBaseApiResponse<void>> {
|
||||
return createBaseApiRequest<void>(() =>
|
||||
fetch(
|
||||
`${getClashApiUrl()}/proxies/${tag}/delay?url=${encodeURIComponent(url)}&timeout=${timeout}`,
|
||||
{
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
11
fe-app-podkop/src/podkop/methods/clash/index.ts
Normal file
11
fe-app-podkop/src/podkop/methods/clash/index.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { getGroupLatency } from './getGroupLatency';
|
||||
import { getProxies } from './getProxies';
|
||||
import { getProxyLatency } from './getProxyLatency';
|
||||
import { setProxy } from './setProxy';
|
||||
|
||||
export const ClashMethods = {
|
||||
getGroupLatency,
|
||||
getProxies,
|
||||
getProxyLatency,
|
||||
setProxy,
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
import { getClashApiUrl } from '../../helpers';
|
||||
import { getClashApiUrl } from '../../../helpers';
|
||||
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
||||
|
||||
export async function triggerProxySelector(
|
||||
export async function setProxy(
|
||||
selector: string,
|
||||
outbound: string,
|
||||
): Promise<IBaseApiResponse<void>> {
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Podkop } from '../types';
|
||||
import { Podkop } from '../../types';
|
||||
|
||||
export async function getConfigSections(): Promise<Podkop.ConfigSection[]> {
|
||||
return uci.load('podkop').then(() => uci.sections('podkop'));
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Podkop } from '../types';
|
||||
import { getConfigSections } from './getConfigSections';
|
||||
import { getClashProxies } from '../../clash';
|
||||
import { getProxyUrlName, splitProxyString } from '../../helpers';
|
||||
import { Podkop } from '../../types';
|
||||
import { ClashMethods } from '../clash';
|
||||
import { getProxyUrlName, splitProxyString } from '../../../helpers';
|
||||
|
||||
interface IGetDashboardSectionsResponse {
|
||||
success: boolean;
|
||||
@@ -10,7 +10,7 @@ interface IGetDashboardSectionsResponse {
|
||||
|
||||
export async function getDashboardSections(): Promise<IGetDashboardSectionsResponse> {
|
||||
const configSections = await getConfigSections();
|
||||
const clashProxies = await getClashProxies();
|
||||
const clashProxies = await ClashMethods.getProxies();
|
||||
|
||||
if (!clashProxies.success) {
|
||||
return {
|
||||
7
fe-app-podkop/src/podkop/methods/custom/index.ts
Normal file
7
fe-app-podkop/src/podkop/methods/custom/index.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { getConfigSections } from './getConfigSections';
|
||||
import { getDashboardSections } from './getDashboardSections';
|
||||
|
||||
export const CustomPodkopMethods = {
|
||||
getConfigSections,
|
||||
getDashboardSections,
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
import { FAKEIP_CHECK_DOMAIN } from '../../../constants';
|
||||
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
||||
import { FAKEIP_CHECK_DOMAIN } from '../../constants';
|
||||
|
||||
interface IGetFakeIpCheckResponse {
|
||||
fakeip: boolean;
|
||||
@@ -1,5 +1,5 @@
|
||||
import { IP_CHECK_DOMAIN } from '../../../constants';
|
||||
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
||||
import { IP_CHECK_DOMAIN } from '../../constants';
|
||||
|
||||
interface IGetIpCheckResponse {
|
||||
fakeip: boolean;
|
||||
7
fe-app-podkop/src/podkop/methods/fakeip/index.ts
Normal file
7
fe-app-podkop/src/podkop/methods/fakeip/index.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { getFakeIpCheck } from './getFakeIpCheck';
|
||||
import { getIpCheck } from './getIpCheck';
|
||||
|
||||
export const RemoteFakeIPMethods = {
|
||||
getFakeIpCheck,
|
||||
getIpCheck,
|
||||
};
|
||||
@@ -1,24 +0,0 @@
|
||||
import { executeShellCommand } from '../../helpers';
|
||||
import { Podkop } from '../types';
|
||||
|
||||
export async function getDNSCheck(): Promise<
|
||||
Podkop.MethodResponse<Podkop.DnsCheckResult>
|
||||
> {
|
||||
const response = await executeShellCommand({
|
||||
command: '/usr/bin/podkop',
|
||||
args: ['check_dns_available'],
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
if (response.stdout) {
|
||||
return {
|
||||
success: true,
|
||||
data: JSON.parse(response.stdout) as Podkop.DnsCheckResult,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
success: false,
|
||||
error: '',
|
||||
};
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import { executeShellCommand } from '../../helpers';
|
||||
import { Podkop } from '../types';
|
||||
|
||||
export async function getFakeIPCheck(): Promise<
|
||||
Podkop.MethodResponse<Podkop.FakeIPCheckResult>
|
||||
> {
|
||||
const response = await executeShellCommand({
|
||||
command: '/usr/bin/podkop',
|
||||
args: ['check_fakeip'],
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
if (response.stdout) {
|
||||
return {
|
||||
success: true,
|
||||
data: JSON.parse(response.stdout) as Podkop.FakeIPCheckResult,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
success: false,
|
||||
error: '',
|
||||
};
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import { executeShellCommand } from '../../helpers';
|
||||
import { Podkop } from '../types';
|
||||
|
||||
export async function getNftRulesCheck(): Promise<
|
||||
Podkop.MethodResponse<Podkop.NftRulesCheckResult>
|
||||
> {
|
||||
const response = await executeShellCommand({
|
||||
command: '/usr/bin/podkop',
|
||||
args: ['check_nft_rules'],
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
if (response.stdout) {
|
||||
return {
|
||||
success: true,
|
||||
data: JSON.parse(response.stdout) as Podkop.NftRulesCheckResult,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
success: false,
|
||||
error: '',
|
||||
};
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import { executeShellCommand } from '../../helpers';
|
||||
|
||||
export async function getPodkopStatus(): Promise<{
|
||||
enabled: number;
|
||||
status: string;
|
||||
}> {
|
||||
const response = await executeShellCommand({
|
||||
command: '/usr/bin/podkop',
|
||||
args: ['get_status'],
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
if (response.stdout) {
|
||||
return JSON.parse(response.stdout.replace(/\n/g, '')) as {
|
||||
enabled: number;
|
||||
status: string;
|
||||
};
|
||||
}
|
||||
|
||||
return { enabled: 0, status: 'unknown' };
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import { executeShellCommand } from '../../helpers';
|
||||
import { Podkop } from '../types';
|
||||
|
||||
export async function getSingBoxCheck(): Promise<
|
||||
Podkop.MethodResponse<Podkop.SingBoxCheckResult>
|
||||
> {
|
||||
const response = await executeShellCommand({
|
||||
command: '/usr/bin/podkop',
|
||||
args: ['check_sing_box'],
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
if (response.stdout) {
|
||||
return {
|
||||
success: true,
|
||||
data: JSON.parse(response.stdout) as Podkop.SingBoxCheckResult,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
success: false,
|
||||
error: '',
|
||||
};
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
import { executeShellCommand } from '../../helpers';
|
||||
|
||||
export async function getSingBoxStatus(): Promise<{
|
||||
running: number;
|
||||
enabled: number;
|
||||
status: string;
|
||||
}> {
|
||||
const response = await executeShellCommand({
|
||||
command: '/usr/bin/podkop',
|
||||
args: ['get_sing_box_status'],
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
if (response.stdout) {
|
||||
return JSON.parse(response.stdout.replace(/\n/g, '')) as {
|
||||
running: number;
|
||||
enabled: number;
|
||||
status: string;
|
||||
};
|
||||
}
|
||||
|
||||
return { running: 0, enabled: 0, status: 'unknown' };
|
||||
}
|
||||
@@ -1,8 +1,4 @@
|
||||
export * from './getConfigSections';
|
||||
export * from './getDashboardSections';
|
||||
export * from './getPodkopStatus';
|
||||
export * from './getSingBoxStatus';
|
||||
export * from './getDNSCheck';
|
||||
export * from './getNftRulesCheck';
|
||||
export * from './getSingBoxCheck';
|
||||
export * from './getFakeIPCheck';
|
||||
export * from './clash';
|
||||
export * from './custom';
|
||||
export * from './fakeip';
|
||||
export * from './shell';
|
||||
|
||||
24
fe-app-podkop/src/podkop/methods/shell/callBaseMethod.ts
Normal file
24
fe-app-podkop/src/podkop/methods/shell/callBaseMethod.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { executeShellCommand } from '../../../helpers';
|
||||
import { Podkop } from '../../types';
|
||||
|
||||
export async function callBaseMethod<T>(
|
||||
method: Podkop.AvailableMethods,
|
||||
): Promise<Podkop.MethodResponse<T>> {
|
||||
const response = await executeShellCommand({
|
||||
command: '/usr/bin/podkop',
|
||||
args: [method],
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
if (response.stdout) {
|
||||
return {
|
||||
success: true,
|
||||
data: JSON.parse(response.stdout) as T,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
success: false,
|
||||
error: '',
|
||||
};
|
||||
}
|
||||
27
fe-app-podkop/src/podkop/methods/shell/index.ts
Normal file
27
fe-app-podkop/src/podkop/methods/shell/index.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { callBaseMethod } from './callBaseMethod';
|
||||
import { Podkop } from '../../types';
|
||||
|
||||
export const PodkopShellMethods = {
|
||||
checkDNSAvailable: async () =>
|
||||
callBaseMethod<Podkop.DnsCheckResult>(
|
||||
Podkop.AvailableMethods.CHECK_DNS_AVAILABLE,
|
||||
),
|
||||
checkFakeIP: async () =>
|
||||
callBaseMethod<Podkop.FakeIPCheckResult>(
|
||||
Podkop.AvailableMethods.CHECK_FAKEIP,
|
||||
),
|
||||
checkNftRules: async () =>
|
||||
callBaseMethod<Podkop.NftRulesCheckResult>(
|
||||
Podkop.AvailableMethods.CHECK_NFT_RULES,
|
||||
),
|
||||
getStatus: async () =>
|
||||
callBaseMethod<Podkop.GetStatus>(Podkop.AvailableMethods.GET_STATUS),
|
||||
checkSingBox: async () =>
|
||||
callBaseMethod<Podkop.SingBoxCheckResult>(
|
||||
Podkop.AvailableMethods.CHECK_SING_BOX,
|
||||
),
|
||||
getSingBoxStatus: async () =>
|
||||
callBaseMethod<Podkop.GetSingBoxStatus>(
|
||||
Podkop.AvailableMethods.GET_SING_BOX_STATUS,
|
||||
),
|
||||
};
|
||||
@@ -1,24 +1,19 @@
|
||||
import {
|
||||
getDashboardSections,
|
||||
getPodkopStatus,
|
||||
getSingBoxStatus,
|
||||
} from '../../methods';
|
||||
import {
|
||||
getClashApiUrl,
|
||||
getClashWsUrl,
|
||||
onMount,
|
||||
preserveScrollForPage,
|
||||
} from '../../../helpers';
|
||||
import {
|
||||
triggerLatencyGroupTest,
|
||||
triggerLatencyProxyTest,
|
||||
triggerProxySelector,
|
||||
} from '../../../clash';
|
||||
import { store, StoreType } from '../../../store';
|
||||
import { socket } from '../../../socket';
|
||||
import { prettyBytes } from '../../../helpers/prettyBytes';
|
||||
import { renderSections } from './renderSections';
|
||||
import { renderWidget } from './renderWidget';
|
||||
import {
|
||||
ClashMethods,
|
||||
CustomPodkopMethods,
|
||||
PodkopShellMethods,
|
||||
} from '../../methods';
|
||||
|
||||
// Fetchers
|
||||
|
||||
@@ -32,7 +27,7 @@ async function fetchDashboardSections() {
|
||||
},
|
||||
});
|
||||
|
||||
const { data, success } = await getDashboardSections();
|
||||
const { data, success } = await CustomPodkopMethods.getDashboardSections();
|
||||
|
||||
if (!success) {
|
||||
console.log('[fetchDashboardSections]: failed to fetch', getClashApiUrl());
|
||||
@@ -49,22 +44,12 @@ async function fetchDashboardSections() {
|
||||
}
|
||||
|
||||
async function fetchServicesInfo() {
|
||||
try {
|
||||
const [podkop, singbox] = await Promise.all([
|
||||
getPodkopStatus(),
|
||||
getSingBoxStatus(),
|
||||
]);
|
||||
|
||||
store.set({
|
||||
servicesInfoWidget: {
|
||||
loading: false,
|
||||
failed: false,
|
||||
data: { singbox: singbox.running, podkop: podkop.enabled },
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
console.log('[fetchServicesInfo]: failed to fetchServices', err);
|
||||
const [podkop, singbox] = await Promise.all([
|
||||
PodkopShellMethods.getStatus(),
|
||||
PodkopShellMethods.getSingBoxStatus(),
|
||||
]);
|
||||
|
||||
if (!podkop.success || !singbox.success) {
|
||||
store.set({
|
||||
servicesInfoWidget: {
|
||||
loading: false,
|
||||
@@ -73,6 +58,16 @@ async function fetchServicesInfo() {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (podkop.success && singbox.success) {
|
||||
store.set({
|
||||
servicesInfoWidget: {
|
||||
loading: false,
|
||||
failed: false,
|
||||
data: { singbox: singbox.data.running, podkop: podkop.data.enabled },
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function connectToClashSockets() {
|
||||
@@ -155,7 +150,7 @@ async function connectToClashSockets() {
|
||||
// Handlers
|
||||
|
||||
async function handleChooseOutbound(selector: string, tag: string) {
|
||||
await triggerProxySelector(selector, tag);
|
||||
await ClashMethods.setProxy(selector, tag);
|
||||
await fetchDashboardSections();
|
||||
}
|
||||
|
||||
@@ -167,7 +162,7 @@ async function handleTestGroupLatency(tag: string) {
|
||||
},
|
||||
});
|
||||
|
||||
await triggerLatencyGroupTest(tag);
|
||||
await ClashMethods.getGroupLatency(tag);
|
||||
await fetchDashboardSections();
|
||||
|
||||
store.set({
|
||||
@@ -186,7 +181,7 @@ async function handleTestProxyLatency(tag: string) {
|
||||
},
|
||||
});
|
||||
|
||||
await triggerLatencyProxyTest(tag);
|
||||
await ClashMethods.getProxyLatency(tag);
|
||||
await fetchDashboardSections();
|
||||
|
||||
store.set({
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { getDNSCheck } from '../../../methods';
|
||||
import { updateDiagnosticsCheck } from '../updateDiagnosticsCheck';
|
||||
import { insertIf } from '../../../../helpers';
|
||||
import { IDiagnosticsChecksItem } from '../../../../store';
|
||||
import { DIAGNOSTICS_CHECKS_MAP } from './contstants';
|
||||
import { PodkopShellMethods } from '../../../methods';
|
||||
|
||||
export async function runDnsCheck() {
|
||||
const { order, title, code } = DIAGNOSTICS_CHECKS_MAP.DNS;
|
||||
@@ -16,7 +16,7 @@ export async function runDnsCheck() {
|
||||
items: [],
|
||||
});
|
||||
|
||||
const dnsChecks = await getDNSCheck();
|
||||
const dnsChecks = await PodkopShellMethods.checkDNSAvailable();
|
||||
|
||||
if (!dnsChecks.success) {
|
||||
updateDiagnosticsCheck({
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import * as podkopMethods from '../../../methods';
|
||||
import * as fakeIPMethods from '../../../../fakeip/methods';
|
||||
import { updateDiagnosticsCheck } from '../updateDiagnosticsCheck';
|
||||
import { insertIf } from '../../../../helpers';
|
||||
import { IDiagnosticsChecksItem } from '../../../../store';
|
||||
import { DIAGNOSTICS_CHECKS_MAP } from './contstants';
|
||||
import { PodkopShellMethods, RemoteFakeIPMethods } from '../../../methods';
|
||||
|
||||
export async function runFakeIPCheck() {
|
||||
const { order, title, code } = DIAGNOSTICS_CHECKS_MAP.FAKEIP;
|
||||
@@ -17,9 +16,9 @@ export async function runFakeIPCheck() {
|
||||
items: [],
|
||||
});
|
||||
|
||||
const routerFakeIPResponse = await podkopMethods.getFakeIPCheck();
|
||||
const checkFakeIPResponse = await fakeIPMethods.getFakeIpCheck();
|
||||
const checkIPResponse = await fakeIPMethods.getIpCheck();
|
||||
const routerFakeIPResponse = await PodkopShellMethods.checkFakeIP();
|
||||
const checkFakeIPResponse = await RemoteFakeIPMethods.getFakeIpCheck();
|
||||
const checkIPResponse = await RemoteFakeIPMethods.getIpCheck();
|
||||
|
||||
console.log('runFakeIPCheck', {
|
||||
routerFakeIPResponse,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { getNftRulesCheck } from '../../../methods';
|
||||
import { updateDiagnosticsCheck } from '../updateDiagnosticsCheck';
|
||||
import { getFakeIpCheck, getIpCheck } from '../../../../fakeip';
|
||||
import { DIAGNOSTICS_CHECKS_MAP } from './contstants';
|
||||
import { RemoteFakeIPMethods } from '../../../methods/fakeip';
|
||||
import { PodkopShellMethods } from '../../../methods';
|
||||
|
||||
export async function runNftCheck() {
|
||||
const { order, title, code } = DIAGNOSTICS_CHECKS_MAP.NFT;
|
||||
@@ -15,10 +15,10 @@ export async function runNftCheck() {
|
||||
items: [],
|
||||
});
|
||||
|
||||
await getFakeIpCheck();
|
||||
await getIpCheck();
|
||||
await RemoteFakeIPMethods.getFakeIpCheck();
|
||||
await RemoteFakeIPMethods.getIpCheck();
|
||||
|
||||
const nftablesChecks = await getNftRulesCheck();
|
||||
const nftablesChecks = await PodkopShellMethods.checkNftRules();
|
||||
|
||||
if (!nftablesChecks.success) {
|
||||
updateDiagnosticsCheck({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { getSingBoxCheck } from '../../../methods';
|
||||
import { updateDiagnosticsCheck } from '../updateDiagnosticsCheck';
|
||||
import { DIAGNOSTICS_CHECKS_MAP } from './contstants';
|
||||
import { PodkopShellMethods } from '../../../methods';
|
||||
|
||||
export async function runSingBoxCheck() {
|
||||
const { order, title, code } = DIAGNOSTICS_CHECKS_MAP.SINGBOX;
|
||||
@@ -14,7 +14,7 @@ export async function runSingBoxCheck() {
|
||||
items: [],
|
||||
});
|
||||
|
||||
const singBoxChecks = await getSingBoxCheck();
|
||||
const singBoxChecks = await PodkopShellMethods.checkSingBox();
|
||||
|
||||
if (!singBoxChecks.success) {
|
||||
updateDiagnosticsCheck({
|
||||
|
||||
@@ -1,5 +1,35 @@
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
export namespace ClashAPI {
|
||||
export interface ProxyHistoryEntry {
|
||||
time: string;
|
||||
delay: number;
|
||||
}
|
||||
|
||||
export interface ProxyBase {
|
||||
type: string;
|
||||
name: string;
|
||||
udp: boolean;
|
||||
history: ProxyHistoryEntry[];
|
||||
now?: string;
|
||||
all?: string[];
|
||||
}
|
||||
|
||||
export interface Proxies {
|
||||
proxies: Record<string, ProxyBase>;
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
export namespace Podkop {
|
||||
export enum AvailableMethods {
|
||||
CHECK_DNS_AVAILABLE = 'check_dns_available',
|
||||
CHECK_FAKEIP = 'check_fakeip',
|
||||
CHECK_NFT_RULES = 'check_nft_rules',
|
||||
GET_STATUS = 'get_status',
|
||||
CHECK_SING_BOX = 'check_sing_box',
|
||||
GET_SING_BOX_STATUS = 'get_sing_box_status',
|
||||
}
|
||||
|
||||
export interface Outbound {
|
||||
code: string;
|
||||
displayName: string;
|
||||
@@ -102,4 +132,15 @@ export namespace Podkop {
|
||||
fakeip: boolean;
|
||||
IP: string;
|
||||
}
|
||||
|
||||
export interface GetStatus {
|
||||
enabled: number;
|
||||
status: string;
|
||||
}
|
||||
|
||||
export interface GetSingBoxStatus {
|
||||
running: number;
|
||||
enabled: number;
|
||||
status: string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1003,7 +1003,7 @@ function validateProxyUrl(url) {
|
||||
};
|
||||
}
|
||||
|
||||
// src/api/createBaseApiRequest.ts
|
||||
// src/podkop/api.ts
|
||||
async function createBaseApiRequest(fetchFn, options) {
|
||||
const wrappedFn = () => options?.timeoutMs && options?.operationName ? withTimeout(
|
||||
fetchFn(),
|
||||
@@ -1032,62 +1032,8 @@ async function createBaseApiRequest(fetchFn, options) {
|
||||
}
|
||||
}
|
||||
|
||||
// src/clash/methods/getConfig.ts
|
||||
async function getClashConfig() {
|
||||
return createBaseApiRequest(
|
||||
() => fetch(`${getClashApiUrl()}/configs`, {
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json" }
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// src/clash/methods/getGroupDelay.ts
|
||||
async function getClashGroupDelay(group, url = "https://www.gstatic.com/generate_204", timeout = 2e3) {
|
||||
const endpoint = `${getClashApiUrl()}/group/${group}/delay?url=${encodeURIComponent(
|
||||
url
|
||||
)}&timeout=${timeout}`;
|
||||
return createBaseApiRequest(
|
||||
() => fetch(endpoint, {
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json" }
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// src/clash/methods/getProxies.ts
|
||||
async function getClashProxies() {
|
||||
return createBaseApiRequest(
|
||||
() => fetch(`${getClashApiUrl()}/proxies`, {
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json" }
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// src/clash/methods/getVersion.ts
|
||||
async function getClashVersion() {
|
||||
return createBaseApiRequest(
|
||||
() => fetch(`${getClashApiUrl()}/version`, {
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json" }
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// src/clash/methods/triggerProxySelector.ts
|
||||
async function triggerProxySelector(selector, outbound) {
|
||||
return createBaseApiRequest(
|
||||
() => fetch(`${getClashApiUrl()}/proxies/${selector}`, {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ name: outbound })
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// src/clash/methods/triggerLatencyTest.ts
|
||||
async function triggerLatencyGroupTest(tag, timeout = 5e3, url = "https://www.gstatic.com/generate_204") {
|
||||
// src/podkop/methods/clash/getGroupLatency.ts
|
||||
async function getGroupLatency(tag, timeout = 5e3, url = "https://www.gstatic.com/generate_204") {
|
||||
return createBaseApiRequest(
|
||||
() => fetch(
|
||||
`${getClashApiUrl()}/group/${tag}/delay?url=${encodeURIComponent(url)}&timeout=${timeout}`,
|
||||
@@ -1098,7 +1044,19 @@ async function triggerLatencyGroupTest(tag, timeout = 5e3, url = "https://www.gs
|
||||
)
|
||||
);
|
||||
}
|
||||
async function triggerLatencyProxyTest(tag, timeout = 2e3, url = "https://www.gstatic.com/generate_204") {
|
||||
|
||||
// src/podkop/methods/clash/getProxies.ts
|
||||
async function getProxies() {
|
||||
return createBaseApiRequest(
|
||||
() => fetch(`${getClashApiUrl()}/proxies`, {
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json" }
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// src/podkop/methods/clash/getProxyLatency.ts
|
||||
async function getProxyLatency(tag, timeout = 2e3, url = "https://www.gstatic.com/generate_204") {
|
||||
return createBaseApiRequest(
|
||||
() => fetch(
|
||||
`${getClashApiUrl()}/proxies/${tag}/delay?url=${encodeURIComponent(url)}&timeout=${timeout}`,
|
||||
@@ -1110,15 +1068,34 @@ async function triggerLatencyProxyTest(tag, timeout = 2e3, url = "https://www.gs
|
||||
);
|
||||
}
|
||||
|
||||
// src/podkop/methods/getConfigSections.ts
|
||||
// src/podkop/methods/clash/setProxy.ts
|
||||
async function setProxy(selector, outbound) {
|
||||
return createBaseApiRequest(
|
||||
() => fetch(`${getClashApiUrl()}/proxies/${selector}`, {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ name: outbound })
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// src/podkop/methods/clash/index.ts
|
||||
var ClashMethods = {
|
||||
getGroupLatency,
|
||||
getProxies,
|
||||
getProxyLatency,
|
||||
setProxy
|
||||
};
|
||||
|
||||
// src/podkop/methods/custom/getConfigSections.ts
|
||||
async function getConfigSections() {
|
||||
return uci.load("podkop").then(() => uci.sections("podkop"));
|
||||
}
|
||||
|
||||
// src/podkop/methods/getDashboardSections.ts
|
||||
// src/podkop/methods/custom/getDashboardSections.ts
|
||||
async function getDashboardSections() {
|
||||
const configSections = await getConfigSections();
|
||||
const clashProxies = await getClashProxies();
|
||||
const clashProxies = await ClashMethods.getProxies();
|
||||
if (!clashProxies.success) {
|
||||
return {
|
||||
success: false,
|
||||
@@ -1241,37 +1218,51 @@ async function getDashboardSections() {
|
||||
};
|
||||
}
|
||||
|
||||
// src/podkop/methods/getPodkopStatus.ts
|
||||
async function getPodkopStatus() {
|
||||
const response = await executeShellCommand({
|
||||
command: "/usr/bin/podkop",
|
||||
args: ["get_status"],
|
||||
timeout: 1e4
|
||||
});
|
||||
if (response.stdout) {
|
||||
return JSON.parse(response.stdout.replace(/\n/g, ""));
|
||||
}
|
||||
return { enabled: 0, status: "unknown" };
|
||||
// src/podkop/methods/custom/index.ts
|
||||
var CustomPodkopMethods = {
|
||||
getConfigSections,
|
||||
getDashboardSections
|
||||
};
|
||||
|
||||
// src/podkop/methods/fakeip/getFakeIpCheck.ts
|
||||
async function getFakeIpCheck() {
|
||||
return createBaseApiRequest(
|
||||
() => fetch(`https://${FAKEIP_CHECK_DOMAIN}/check`, {
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json" }
|
||||
}),
|
||||
{
|
||||
operationName: "getFakeIpCheck",
|
||||
timeoutMs: 5e3
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// src/podkop/methods/getSingBoxStatus.ts
|
||||
async function getSingBoxStatus() {
|
||||
const response = await executeShellCommand({
|
||||
command: "/usr/bin/podkop",
|
||||
args: ["get_sing_box_status"],
|
||||
timeout: 1e4
|
||||
});
|
||||
if (response.stdout) {
|
||||
return JSON.parse(response.stdout.replace(/\n/g, ""));
|
||||
}
|
||||
return { running: 0, enabled: 0, status: "unknown" };
|
||||
// src/podkop/methods/fakeip/getIpCheck.ts
|
||||
async function getIpCheck() {
|
||||
return createBaseApiRequest(
|
||||
() => fetch(`https://${IP_CHECK_DOMAIN}/check`, {
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json" }
|
||||
}),
|
||||
{
|
||||
operationName: "getIpCheck",
|
||||
timeoutMs: 5e3
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// src/podkop/methods/getDNSCheck.ts
|
||||
async function getDNSCheck() {
|
||||
// src/podkop/methods/fakeip/index.ts
|
||||
var RemoteFakeIPMethods = {
|
||||
getFakeIpCheck,
|
||||
getIpCheck
|
||||
};
|
||||
|
||||
// src/podkop/methods/shell/callBaseMethod.ts
|
||||
async function callBaseMethod(method) {
|
||||
const response = await executeShellCommand({
|
||||
command: "/usr/bin/podkop",
|
||||
args: ["check_dns_available"],
|
||||
args: [method],
|
||||
timeout: 1e4
|
||||
});
|
||||
if (response.stdout) {
|
||||
@@ -1286,62 +1277,39 @@ async function getDNSCheck() {
|
||||
};
|
||||
}
|
||||
|
||||
// src/podkop/methods/getNftRulesCheck.ts
|
||||
async function getNftRulesCheck() {
|
||||
const response = await executeShellCommand({
|
||||
command: "/usr/bin/podkop",
|
||||
args: ["check_nft_rules"],
|
||||
timeout: 1e4
|
||||
});
|
||||
if (response.stdout) {
|
||||
return {
|
||||
success: true,
|
||||
data: JSON.parse(response.stdout)
|
||||
};
|
||||
}
|
||||
return {
|
||||
success: false,
|
||||
error: ""
|
||||
};
|
||||
}
|
||||
// src/podkop/types.ts
|
||||
var Podkop;
|
||||
((Podkop2) => {
|
||||
let AvailableMethods;
|
||||
((AvailableMethods2) => {
|
||||
AvailableMethods2["CHECK_DNS_AVAILABLE"] = "check_dns_available";
|
||||
AvailableMethods2["CHECK_FAKEIP"] = "check_fakeip";
|
||||
AvailableMethods2["CHECK_NFT_RULES"] = "check_nft_rules";
|
||||
AvailableMethods2["GET_STATUS"] = "get_status";
|
||||
AvailableMethods2["CHECK_SING_BOX"] = "check_sing_box";
|
||||
AvailableMethods2["GET_SING_BOX_STATUS"] = "get_sing_box_status";
|
||||
})(AvailableMethods = Podkop2.AvailableMethods || (Podkop2.AvailableMethods = {}));
|
||||
})(Podkop || (Podkop = {}));
|
||||
|
||||
// src/podkop/methods/getSingBoxCheck.ts
|
||||
async function getSingBoxCheck() {
|
||||
const response = await executeShellCommand({
|
||||
command: "/usr/bin/podkop",
|
||||
args: ["check_sing_box"],
|
||||
timeout: 1e4
|
||||
});
|
||||
if (response.stdout) {
|
||||
return {
|
||||
success: true,
|
||||
data: JSON.parse(response.stdout)
|
||||
};
|
||||
}
|
||||
return {
|
||||
success: false,
|
||||
error: ""
|
||||
};
|
||||
}
|
||||
|
||||
// src/podkop/methods/getFakeIPCheck.ts
|
||||
async function getFakeIPCheck() {
|
||||
const response = await executeShellCommand({
|
||||
command: "/usr/bin/podkop",
|
||||
args: ["check_fakeip"],
|
||||
timeout: 1e4
|
||||
});
|
||||
if (response.stdout) {
|
||||
return {
|
||||
success: true,
|
||||
data: JSON.parse(response.stdout)
|
||||
};
|
||||
}
|
||||
return {
|
||||
success: false,
|
||||
error: ""
|
||||
};
|
||||
}
|
||||
// src/podkop/methods/shell/index.ts
|
||||
var PodkopShellMethods = {
|
||||
checkDNSAvailable: async () => callBaseMethod(
|
||||
Podkop.AvailableMethods.CHECK_DNS_AVAILABLE
|
||||
),
|
||||
checkFakeIP: async () => callBaseMethod(
|
||||
Podkop.AvailableMethods.CHECK_FAKEIP
|
||||
),
|
||||
checkNftRules: async () => callBaseMethod(
|
||||
Podkop.AvailableMethods.CHECK_NFT_RULES
|
||||
),
|
||||
getStatus: async () => callBaseMethod(Podkop.AvailableMethods.GET_STATUS),
|
||||
checkSingBox: async () => callBaseMethod(
|
||||
Podkop.AvailableMethods.CHECK_SING_BOX
|
||||
),
|
||||
getSingBoxStatus: async () => callBaseMethod(
|
||||
Podkop.AvailableMethods.GET_SING_BOX_STATUS
|
||||
)
|
||||
};
|
||||
|
||||
// src/podkop/services/tab.service.ts
|
||||
var TabService = class _TabService {
|
||||
@@ -1994,7 +1962,7 @@ async function fetchDashboardSections() {
|
||||
failed: false
|
||||
}
|
||||
});
|
||||
const { data, success } = await getDashboardSections();
|
||||
const { data, success } = await CustomPodkopMethods.getDashboardSections();
|
||||
if (!success) {
|
||||
console.log("[fetchDashboardSections]: failed to fetch", getClashApiUrl());
|
||||
}
|
||||
@@ -2008,20 +1976,11 @@ async function fetchDashboardSections() {
|
||||
});
|
||||
}
|
||||
async function fetchServicesInfo() {
|
||||
try {
|
||||
const [podkop, singbox] = await Promise.all([
|
||||
getPodkopStatus(),
|
||||
getSingBoxStatus()
|
||||
]);
|
||||
store.set({
|
||||
servicesInfoWidget: {
|
||||
loading: false,
|
||||
failed: false,
|
||||
data: { singbox: singbox.running, podkop: podkop.enabled }
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
console.log("[fetchServicesInfo]: failed to fetchServices", err);
|
||||
const [podkop, singbox] = await Promise.all([
|
||||
PodkopShellMethods.getStatus(),
|
||||
PodkopShellMethods.getSingBoxStatus()
|
||||
]);
|
||||
if (!podkop.success || !singbox.success) {
|
||||
store.set({
|
||||
servicesInfoWidget: {
|
||||
loading: false,
|
||||
@@ -2030,6 +1989,15 @@ async function fetchServicesInfo() {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (podkop.success && singbox.success) {
|
||||
store.set({
|
||||
servicesInfoWidget: {
|
||||
loading: false,
|
||||
failed: false,
|
||||
data: { singbox: singbox.data.running, podkop: podkop.data.enabled }
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
async function connectToClashSockets() {
|
||||
socket.subscribe(
|
||||
@@ -2105,7 +2073,7 @@ async function connectToClashSockets() {
|
||||
);
|
||||
}
|
||||
async function handleChooseOutbound(selector, tag) {
|
||||
await triggerProxySelector(selector, tag);
|
||||
await ClashMethods.setProxy(selector, tag);
|
||||
await fetchDashboardSections();
|
||||
}
|
||||
async function handleTestGroupLatency(tag) {
|
||||
@@ -2115,7 +2083,7 @@ async function handleTestGroupLatency(tag) {
|
||||
latencyFetching: true
|
||||
}
|
||||
});
|
||||
await triggerLatencyGroupTest(tag);
|
||||
await ClashMethods.getGroupLatency(tag);
|
||||
await fetchDashboardSections();
|
||||
store.set({
|
||||
sectionsWidget: {
|
||||
@@ -2131,7 +2099,7 @@ async function handleTestProxyLatency(tag) {
|
||||
latencyFetching: true
|
||||
}
|
||||
});
|
||||
await triggerLatencyProxyTest(tag);
|
||||
await ClashMethods.getProxyLatency(tag);
|
||||
await fetchDashboardSections();
|
||||
store.set({
|
||||
sectionsWidget: {
|
||||
@@ -2772,7 +2740,7 @@ async function runDnsCheck() {
|
||||
state: "loading",
|
||||
items: []
|
||||
});
|
||||
const dnsChecks = await getDNSCheck();
|
||||
const dnsChecks = await PodkopShellMethods.checkDNSAvailable();
|
||||
if (!dnsChecks.success) {
|
||||
updateDiagnosticsCheck({
|
||||
order,
|
||||
@@ -2842,7 +2810,7 @@ async function runSingBoxCheck() {
|
||||
state: "loading",
|
||||
items: []
|
||||
});
|
||||
const singBoxChecks = await getSingBoxCheck();
|
||||
const singBoxChecks = await PodkopShellMethods.checkSingBox();
|
||||
if (!singBoxChecks.success) {
|
||||
updateDiagnosticsCheck({
|
||||
order,
|
||||
@@ -2911,34 +2879,6 @@ async function runSingBoxCheck() {
|
||||
}
|
||||
}
|
||||
|
||||
// src/fakeip/methods/getIpCheck.ts
|
||||
async function getIpCheck() {
|
||||
return createBaseApiRequest(
|
||||
() => fetch(`https://${IP_CHECK_DOMAIN}/check`, {
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json" }
|
||||
}),
|
||||
{
|
||||
operationName: "getIpCheck",
|
||||
timeoutMs: 5e3
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// src/fakeip/methods/getFakeIpCheck.ts
|
||||
async function getFakeIpCheck() {
|
||||
return createBaseApiRequest(
|
||||
() => fetch(`https://${FAKEIP_CHECK_DOMAIN}/check`, {
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json" }
|
||||
}),
|
||||
{
|
||||
operationName: "getFakeIpCheck",
|
||||
timeoutMs: 5e3
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// src/podkop/tabs/diagnostic/checks/runNftCheck.ts
|
||||
async function runNftCheck() {
|
||||
const { order, title, code } = DIAGNOSTICS_CHECKS_MAP.NFT;
|
||||
@@ -2950,9 +2890,9 @@ async function runNftCheck() {
|
||||
state: "loading",
|
||||
items: []
|
||||
});
|
||||
await getFakeIpCheck();
|
||||
await getIpCheck();
|
||||
const nftablesChecks = await getNftRulesCheck();
|
||||
await RemoteFakeIPMethods.getFakeIpCheck();
|
||||
await RemoteFakeIPMethods.getIpCheck();
|
||||
const nftablesChecks = await PodkopShellMethods.checkNftRules();
|
||||
if (!nftablesChecks.success) {
|
||||
updateDiagnosticsCheck({
|
||||
order,
|
||||
@@ -3042,9 +2982,9 @@ async function runFakeIPCheck() {
|
||||
state: "loading",
|
||||
items: []
|
||||
});
|
||||
const routerFakeIPResponse = await getFakeIPCheck();
|
||||
const checkFakeIPResponse = await getFakeIpCheck();
|
||||
const checkIPResponse = await getIpCheck();
|
||||
const routerFakeIPResponse = await PodkopShellMethods.checkFakeIP();
|
||||
const checkFakeIPResponse = await RemoteFakeIPMethods.getFakeIpCheck();
|
||||
const checkIPResponse = await RemoteFakeIPMethods.getIpCheck();
|
||||
console.log("runFakeIPCheck", {
|
||||
routerFakeIPResponse,
|
||||
checkFakeIPResponse,
|
||||
@@ -3254,6 +3194,8 @@ return baseclass.extend({
|
||||
CACHE_TIMEOUT,
|
||||
COMMAND_SCHEDULING,
|
||||
COMMAND_TIMEOUT,
|
||||
ClashMethods,
|
||||
CustomPodkopMethods,
|
||||
DIAGNOSTICS_INITIAL_DELAY,
|
||||
DIAGNOSTICS_UPDATE_INTERVAL,
|
||||
DNS_SERVER_OPTIONS,
|
||||
@@ -3263,7 +3205,9 @@ return baseclass.extend({
|
||||
FETCH_TIMEOUT,
|
||||
IP_CHECK_DOMAIN,
|
||||
PODKOP_LUCI_APP_VERSION,
|
||||
PodkopShellMethods,
|
||||
REGIONAL_OPTIONS,
|
||||
RemoteFakeIPMethods,
|
||||
STATUS_COLORS,
|
||||
TabService,
|
||||
TabServiceInstance,
|
||||
@@ -3273,21 +3217,9 @@ return baseclass.extend({
|
||||
executeShellCommand,
|
||||
getBaseUrl,
|
||||
getClashApiUrl,
|
||||
getClashConfig,
|
||||
getClashGroupDelay,
|
||||
getClashProxies,
|
||||
getClashUIUrl,
|
||||
getClashVersion,
|
||||
getClashWsUrl,
|
||||
getConfigSections,
|
||||
getDNSCheck,
|
||||
getDashboardSections,
|
||||
getFakeIPCheck,
|
||||
getNftRulesCheck,
|
||||
getPodkopStatus,
|
||||
getProxyUrlName,
|
||||
getSingBoxCheck,
|
||||
getSingBoxStatus,
|
||||
initDashboardController,
|
||||
initDiagnosticController,
|
||||
injectGlobalStyles,
|
||||
@@ -3302,9 +3234,6 @@ return baseclass.extend({
|
||||
renderDiagnostic,
|
||||
splitProxyString,
|
||||
svgEl,
|
||||
triggerLatencyGroupTest,
|
||||
triggerLatencyProxyTest,
|
||||
triggerProxySelector,
|
||||
validateDNS,
|
||||
validateDomain,
|
||||
validateIPV4,
|
||||
|
||||
Reference in New Issue
Block a user