mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-08 20:46:50 +03:00
feat: update diagnostics checks
This commit is contained in:
@@ -1,10 +1,26 @@
|
|||||||
import { IBaseApiResponse } from '../types';
|
import { IBaseApiResponse } from './types';
|
||||||
|
import { withTimeout } from '../helpers';
|
||||||
|
|
||||||
export async function createBaseApiRequest<T>(
|
export async function createBaseApiRequest<T>(
|
||||||
fetchFn: () => Promise<Response>,
|
fetchFn: () => Promise<Response>,
|
||||||
|
options?: {
|
||||||
|
timeoutMs?: number;
|
||||||
|
operationName?: string;
|
||||||
|
timeoutMessage?: string;
|
||||||
|
},
|
||||||
): Promise<IBaseApiResponse<T>> {
|
): Promise<IBaseApiResponse<T>> {
|
||||||
|
const wrappedFn = () =>
|
||||||
|
options?.timeoutMs && options?.operationName
|
||||||
|
? withTimeout(
|
||||||
|
fetchFn(),
|
||||||
|
options.timeoutMs,
|
||||||
|
options.operationName,
|
||||||
|
options.timeoutMessage,
|
||||||
|
)
|
||||||
|
: fetchFn();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetchFn();
|
const response = await wrappedFn();
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
return {
|
return {
|
||||||
2
fe-app-podkop/src/api/index.ts
Normal file
2
fe-app-podkop/src/api/index.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './types';
|
||||||
|
export * from './createBaseApiRequest';
|
||||||
9
fe-app-podkop/src/api/types.ts
Normal file
9
fe-app-podkop/src/api/types.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
export type IBaseApiResponse<T> =
|
||||||
|
| {
|
||||||
|
success: true;
|
||||||
|
data: T;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
success: false;
|
||||||
|
message: string;
|
||||||
|
};
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ClashAPI, IBaseApiResponse } from '../types';
|
import { ClashAPI } from '../types';
|
||||||
import { createBaseApiRequest } from './createBaseApiRequest';
|
|
||||||
import { getClashApiUrl } from '../../helpers';
|
import { getClashApiUrl } from '../../helpers';
|
||||||
|
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
||||||
|
|
||||||
export async function getClashConfig(): Promise<
|
export async function getClashConfig(): Promise<
|
||||||
IBaseApiResponse<ClashAPI.Config>
|
IBaseApiResponse<ClashAPI.Config>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ClashAPI, IBaseApiResponse } from '../types';
|
import { ClashAPI } from '../types';
|
||||||
import { createBaseApiRequest } from './createBaseApiRequest';
|
|
||||||
import { getClashApiUrl } from '../../helpers';
|
import { getClashApiUrl } from '../../helpers';
|
||||||
|
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
||||||
|
|
||||||
export async function getClashGroupDelay(
|
export async function getClashGroupDelay(
|
||||||
group: string,
|
group: string,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ClashAPI, IBaseApiResponse } from '../types';
|
import { ClashAPI } from '../types';
|
||||||
import { createBaseApiRequest } from './createBaseApiRequest';
|
|
||||||
import { getClashApiUrl } from '../../helpers';
|
import { getClashApiUrl } from '../../helpers';
|
||||||
|
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
||||||
|
|
||||||
export async function getClashProxies(): Promise<
|
export async function getClashProxies(): Promise<
|
||||||
IBaseApiResponse<ClashAPI.Proxies>
|
IBaseApiResponse<ClashAPI.Proxies>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ClashAPI, IBaseApiResponse } from '../types';
|
import { ClashAPI } from '../types';
|
||||||
import { createBaseApiRequest } from './createBaseApiRequest';
|
|
||||||
import { getClashApiUrl } from '../../helpers';
|
import { getClashApiUrl } from '../../helpers';
|
||||||
|
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
||||||
|
|
||||||
export async function getClashVersion(): Promise<
|
export async function getClashVersion(): Promise<
|
||||||
IBaseApiResponse<ClashAPI.Version>
|
IBaseApiResponse<ClashAPI.Version>
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
export * from './createBaseApiRequest';
|
|
||||||
export * from './getConfig';
|
export * from './getConfig';
|
||||||
export * from './getGroupDelay';
|
export * from './getGroupDelay';
|
||||||
export * from './getProxies';
|
export * from './getProxies';
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { IBaseApiResponse } from '../types';
|
|
||||||
import { createBaseApiRequest } from './createBaseApiRequest';
|
|
||||||
import { getClashApiUrl } from '../../helpers';
|
import { getClashApiUrl } from '../../helpers';
|
||||||
|
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
||||||
|
|
||||||
export async function triggerLatencyGroupTest(
|
export async function triggerLatencyGroupTest(
|
||||||
tag: string,
|
tag: string,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { IBaseApiResponse } from '../types';
|
|
||||||
import { createBaseApiRequest } from './createBaseApiRequest';
|
|
||||||
import { getClashApiUrl } from '../../helpers';
|
import { getClashApiUrl } from '../../helpers';
|
||||||
|
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
||||||
|
|
||||||
export async function triggerProxySelector(
|
export async function triggerProxySelector(
|
||||||
selector: string,
|
selector: string,
|
||||||
|
|||||||
@@ -1,13 +1,3 @@
|
|||||||
export type IBaseApiResponse<T> =
|
|
||||||
| {
|
|
||||||
success: true;
|
|
||||||
data: T;
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
success: false;
|
|
||||||
message: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||||
export namespace ClashAPI {
|
export namespace ClashAPI {
|
||||||
export interface Version {
|
export interface Version {
|
||||||
|
|||||||
1
fe-app-podkop/src/fakeip/index.ts
Normal file
1
fe-app-podkop/src/fakeip/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './methods';
|
||||||
23
fe-app-podkop/src/fakeip/methods/getFakeIpCheck.ts
Normal file
23
fe-app-podkop/src/fakeip/methods/getFakeIpCheck.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
||||||
|
import { FAKEIP_CHECK_DOMAIN } from '../../constants';
|
||||||
|
|
||||||
|
interface IGetFakeIpCheckResponse {
|
||||||
|
fakeip: boolean;
|
||||||
|
IP: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getFakeIpCheck(): Promise<
|
||||||
|
IBaseApiResponse<IGetFakeIpCheckResponse>
|
||||||
|
> {
|
||||||
|
return createBaseApiRequest<IGetFakeIpCheckResponse>(
|
||||||
|
() =>
|
||||||
|
fetch(`https://${FAKEIP_CHECK_DOMAIN}/check`, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
operationName: 'getFakeIpCheck',
|
||||||
|
timeoutMs: 5000,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
23
fe-app-podkop/src/fakeip/methods/getIpCheck.ts
Normal file
23
fe-app-podkop/src/fakeip/methods/getIpCheck.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
||||||
|
import { IP_CHECK_DOMAIN } from '../../constants';
|
||||||
|
|
||||||
|
interface IGetIpCheckResponse {
|
||||||
|
fakeip: boolean;
|
||||||
|
IP: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getIpCheck(): Promise<
|
||||||
|
IBaseApiResponse<IGetIpCheckResponse>
|
||||||
|
> {
|
||||||
|
return createBaseApiRequest<IGetIpCheckResponse>(
|
||||||
|
() =>
|
||||||
|
fetch(`https://${IP_CHECK_DOMAIN}/check`, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
operationName: 'getIpCheck',
|
||||||
|
timeoutMs: 5000,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
2
fe-app-podkop/src/fakeip/methods/index.ts
Normal file
2
fe-app-podkop/src/fakeip/methods/index.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './getIpCheck';
|
||||||
|
export * from './getFakeIpCheck';
|
||||||
@@ -3,3 +3,6 @@ export * from './renderCircleAlertIcon24';
|
|||||||
export * from './renderCircleCheckIcon24';
|
export * from './renderCircleCheckIcon24';
|
||||||
export * from './renderCircleSlashIcon24';
|
export * from './renderCircleSlashIcon24';
|
||||||
export * from './renderCircleXIcon24';
|
export * from './renderCircleXIcon24';
|
||||||
|
export * from './renderCheckIcon24';
|
||||||
|
export * from './renderXIcon24';
|
||||||
|
export * from './renderTriangleAlertIcon24';
|
||||||
|
|||||||
23
fe-app-podkop/src/icons/renderCheckIcon24.ts
Normal file
23
fe-app-podkop/src/icons/renderCheckIcon24.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { svgEl } from '../helpers';
|
||||||
|
|
||||||
|
export function renderCheckIcon24() {
|
||||||
|
const NS = 'http://www.w3.org/2000/svg';
|
||||||
|
return svgEl(
|
||||||
|
'svg',
|
||||||
|
{
|
||||||
|
xmlns: NS,
|
||||||
|
viewBox: '0 0 24 24',
|
||||||
|
fill: 'none',
|
||||||
|
stroke: 'currentColor',
|
||||||
|
'stroke-width': '2',
|
||||||
|
'stroke-linecap': 'round',
|
||||||
|
'stroke-linejoin': 'round',
|
||||||
|
class: 'lucide lucide-check-icon lucide-check',
|
||||||
|
},
|
||||||
|
[
|
||||||
|
svgEl('path', {
|
||||||
|
d: 'M20 6 9 17l-5-5',
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
25
fe-app-podkop/src/icons/renderTriangleAlertIcon24.ts
Normal file
25
fe-app-podkop/src/icons/renderTriangleAlertIcon24.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { svgEl } from '../helpers';
|
||||||
|
|
||||||
|
export function renderTriangleAlertIcon24() {
|
||||||
|
const NS = 'http://www.w3.org/2000/svg';
|
||||||
|
return svgEl(
|
||||||
|
'svg',
|
||||||
|
{
|
||||||
|
xmlns: NS,
|
||||||
|
viewBox: '0 0 24 24',
|
||||||
|
fill: 'none',
|
||||||
|
stroke: 'currentColor',
|
||||||
|
'stroke-width': '2',
|
||||||
|
'stroke-linecap': 'round',
|
||||||
|
'stroke-linejoin': 'round',
|
||||||
|
class: 'lucide lucide-triangle-alert-icon lucide-triangle-alert',
|
||||||
|
},
|
||||||
|
[
|
||||||
|
svgEl('path', {
|
||||||
|
d: 'm21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3',
|
||||||
|
}),
|
||||||
|
svgEl('path', { d: 'M12 9v4' }),
|
||||||
|
svgEl('path', { d: 'M12 17h.01' }),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
19
fe-app-podkop/src/icons/renderXIcon24.ts
Normal file
19
fe-app-podkop/src/icons/renderXIcon24.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import { svgEl } from '../helpers';
|
||||||
|
|
||||||
|
export function renderXIcon24() {
|
||||||
|
const NS = 'http://www.w3.org/2000/svg';
|
||||||
|
return svgEl(
|
||||||
|
'svg',
|
||||||
|
{
|
||||||
|
xmlns: NS,
|
||||||
|
viewBox: '0 0 24 24',
|
||||||
|
fill: 'none',
|
||||||
|
stroke: 'currentColor',
|
||||||
|
'stroke-width': '2',
|
||||||
|
'stroke-linecap': 'round',
|
||||||
|
'stroke-linejoin': 'round',
|
||||||
|
class: 'lucide lucide-x-icon lucide-x',
|
||||||
|
},
|
||||||
|
[svgEl('path', { d: 'M18 6 6 18' }), svgEl('path', { d: 'm6 6 12 12' })],
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -66,19 +66,19 @@ export async function runDnsCheck() {
|
|||||||
{
|
{
|
||||||
state: data.bootstrap_dns_status ? 'success' : 'error',
|
state: data.bootstrap_dns_status ? 'success' : 'error',
|
||||||
key: _('Bootsrap DNS'),
|
key: _('Bootsrap DNS'),
|
||||||
value: `${data.bootstrap_dns_server} ${data.bootstrap_dns_status ? '✅' : '❌'}`,
|
value: data.bootstrap_dns_server,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
{
|
{
|
||||||
state: data.dns_status ? 'success' : 'error',
|
state: data.dns_status ? 'success' : 'error',
|
||||||
key: _('Main DNS'),
|
key: _('Main DNS'),
|
||||||
value: `${data.dns_server} [${data.dns_type}] ${data.dns_status ? '✅' : '❌'}`,
|
value: `${data.dns_server} [${data.dns_type}]`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.local_dns_status ? 'success' : 'error',
|
state: data.local_dns_status ? 'success' : 'error',
|
||||||
key: _('Local DNS'),
|
key: _('Local DNS'),
|
||||||
value: data.local_dns_status ? '✅' : '❌',
|
value: '',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,6 +8,22 @@ export async function runFakeIPCheck() {
|
|||||||
title: _('Fake IP checks'),
|
title: _('Fake IP checks'),
|
||||||
description: _('Not implemented yet'),
|
description: _('Not implemented yet'),
|
||||||
state: 'skipped',
|
state: 'skipped',
|
||||||
items: [],
|
items: [
|
||||||
|
{
|
||||||
|
state: 'success',
|
||||||
|
key: 'success',
|
||||||
|
value: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
state: 'warning',
|
||||||
|
key: 'warning',
|
||||||
|
value: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
state: 'error',
|
||||||
|
key: 'error',
|
||||||
|
value: '',
|
||||||
|
},
|
||||||
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
import { getNftRulesCheck } from '../../../methods';
|
import { getNftRulesCheck } from '../../../methods';
|
||||||
import { updateDiagnosticsCheck } from '../updateDiagnosticsCheck';
|
import { updateDiagnosticsCheck } from '../updateDiagnosticsCheck';
|
||||||
|
import { getFakeIpCheck, getIpCheck } from '../../../../fakeip';
|
||||||
|
|
||||||
export async function runNftCheck() {
|
export async function runNftCheck() {
|
||||||
const code = 'nft_check';
|
const code = 'nft_check';
|
||||||
|
|
||||||
|
await getFakeIpCheck();
|
||||||
|
await getIpCheck();
|
||||||
|
|
||||||
updateDiagnosticsCheck({
|
updateDiagnosticsCheck({
|
||||||
code,
|
code,
|
||||||
title: _('Nftables checks'),
|
title: _('Nftables checks'),
|
||||||
@@ -73,42 +77,42 @@ export async function runNftCheck() {
|
|||||||
{
|
{
|
||||||
state: data.table_exist ? 'success' : 'error',
|
state: data.table_exist ? 'success' : 'error',
|
||||||
key: _('Table exist'),
|
key: _('Table exist'),
|
||||||
value: data.table_exist ? _('Yes') : _('No'),
|
value: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.rules_mangle_exist ? 'success' : 'error',
|
state: data.rules_mangle_exist ? 'success' : 'error',
|
||||||
key: _('Rules mangle exist'),
|
key: _('Rules mangle exist'),
|
||||||
value: data.rules_mangle_exist ? _('Yes') : _('No'),
|
value: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.rules_mangle_counters ? 'success' : 'error',
|
state: data.rules_mangle_counters ? 'success' : 'error',
|
||||||
key: _('Rules mangle counters'),
|
key: _('Rules mangle counters'),
|
||||||
value: data.rules_mangle_counters ? _('Yes') : _('No'),
|
value: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.rules_mangle_output_exist ? 'success' : 'error',
|
state: data.rules_mangle_output_exist ? 'success' : 'error',
|
||||||
key: _('Rules mangle output exist'),
|
key: _('Rules mangle output exist'),
|
||||||
value: data.rules_mangle_output_exist ? _('Yes') : _('No'),
|
value: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.rules_mangle_output_counters ? 'success' : 'error',
|
state: data.rules_mangle_output_counters ? 'success' : 'error',
|
||||||
key: _('Rules mangle output counters'),
|
key: _('Rules mangle output counters'),
|
||||||
value: data.rules_mangle_output_counters ? _('Yes') : _('No'),
|
value: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.rules_proxy_exist ? 'success' : 'error',
|
state: data.rules_proxy_exist ? 'success' : 'error',
|
||||||
key: _('Rules proxy exist'),
|
key: _('Rules proxy exist'),
|
||||||
value: data.rules_proxy_exist ? _('Yes') : _('No'),
|
value: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.rules_proxy_counters ? 'success' : 'error',
|
state: data.rules_proxy_counters ? 'success' : 'error',
|
||||||
key: _('Rules proxy counters'),
|
key: _('Rules proxy counters'),
|
||||||
value: data.rules_proxy_counters ? _('Yes') : _('No'),
|
value: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.rules_other_mark_exist ? 'warning' : 'success',
|
state: !data.rules_other_mark_exist ? 'success' : 'warning',
|
||||||
key: _('Rules other mark exist'),
|
key: _('None other Mark rules'),
|
||||||
value: data.rules_other_mark_exist ? _('Yes') : _('No'),
|
value: '',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -67,32 +67,32 @@ export async function runSingBoxCheck() {
|
|||||||
{
|
{
|
||||||
state: data.sing_box_installed ? 'success' : 'error',
|
state: data.sing_box_installed ? 'success' : 'error',
|
||||||
key: _('Sing-box installed'),
|
key: _('Sing-box installed'),
|
||||||
value: data.sing_box_installed ? _('Yes') : _('No'),
|
value: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.sing_box_version_ok ? 'success' : 'error',
|
state: data.sing_box_version_ok ? 'success' : 'error',
|
||||||
key: _('Sing-box version >= 1.12.4'),
|
key: _('Sing-box version >= 1.12.4'),
|
||||||
value: data.sing_box_version_ok ? _('Yes') : _('No'),
|
value: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.sing_box_service_exist ? 'success' : 'error',
|
state: data.sing_box_service_exist ? 'success' : 'error',
|
||||||
key: _('Sing-box service exist'),
|
key: _('Sing-box service exist'),
|
||||||
value: data.sing_box_service_exist ? _('Yes') : _('No'),
|
value: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.sing_box_autostart_disabled ? 'success' : 'error',
|
state: data.sing_box_autostart_disabled ? 'success' : 'error',
|
||||||
key: _('Sing-box autostart disabled'),
|
key: _('Sing-box autostart disabled'),
|
||||||
value: data.sing_box_autostart_disabled ? _('Yes') : _('No'),
|
value: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.sing_box_process_running ? 'success' : 'error',
|
state: data.sing_box_process_running ? 'success' : 'error',
|
||||||
key: _('Sing-box process running'),
|
key: _('Sing-box process running'),
|
||||||
value: data.sing_box_process_running ? _('Yes') : _('No'),
|
value: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.sing_box_ports_listening ? 'success' : 'error',
|
state: data.sing_box_ports_listening ? 'success' : 'error',
|
||||||
key: _('Sing-box listening ports'),
|
key: _('Sing-box listening ports'),
|
||||||
value: data.sing_box_ports_listening ? _('Yes') : _('No'),
|
value: '',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import {
|
import {
|
||||||
|
renderCheckIcon24,
|
||||||
renderCircleAlertIcon24,
|
renderCircleAlertIcon24,
|
||||||
renderCircleCheckIcon24,
|
renderCircleCheckIcon24,
|
||||||
renderCircleSlashIcon24,
|
renderCircleSlashIcon24,
|
||||||
renderCircleXIcon24,
|
renderCircleXIcon24,
|
||||||
renderLoaderCircleIcon24,
|
renderLoaderCircleIcon24,
|
||||||
|
renderTriangleAlertIcon24,
|
||||||
|
renderXIcon24,
|
||||||
} from '../../../icons';
|
} from '../../../icons';
|
||||||
import { IDiagnosticsChecksStoreItem } from '../../../store';
|
import { IDiagnosticsChecksStoreItem } from '../../../store';
|
||||||
|
|
||||||
@@ -14,15 +17,35 @@ function renderCheckSummary(items: IRenderCheckSectionProps['items']) {
|
|||||||
return E('div', {}, '');
|
return E('div', {}, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderedItems = items.map((item) =>
|
const renderedItems = items.map((item) => {
|
||||||
E(
|
function getIcon() {
|
||||||
|
const iconWrap = E('span', {
|
||||||
|
class: 'pdk_diagnostic_alert__summary__item__icon',
|
||||||
|
});
|
||||||
|
|
||||||
|
if (item.state === 'success') {
|
||||||
|
iconWrap.appendChild(renderCheckIcon24());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.state === 'warning') {
|
||||||
|
iconWrap.appendChild(renderTriangleAlertIcon24());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.state === 'error') {
|
||||||
|
iconWrap.appendChild(renderXIcon24());
|
||||||
|
}
|
||||||
|
|
||||||
|
return iconWrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
return E(
|
||||||
'div',
|
'div',
|
||||||
{
|
{
|
||||||
class: `pdk_diagnostic_alert__summary__item pdk_diagnostic_alert__summary__item--${item.state}`,
|
class: `pdk_diagnostic_alert__summary__item pdk_diagnostic_alert__summary__item--${item.state}`,
|
||||||
},
|
},
|
||||||
[E('b', {}, item.key), E('div', {}, item.value)],
|
[getIcon(), E('b', {}, item.key), E('div', {}, item.value)],
|
||||||
),
|
);
|
||||||
);
|
});
|
||||||
|
|
||||||
return E('div', { class: 'pdk_diagnostic_alert__summary' }, renderedItems);
|
return E('div', { class: 'pdk_diagnostic_alert__summary' }, renderedItems);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ export const GlobalStyles = `
|
|||||||
|
|
||||||
.pdk_diagnostic_alert__summary__item {
|
.pdk_diagnostic_alert__summary__item {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: auto 1fr;
|
grid-template-columns: 16px auto 1fr;
|
||||||
grid-column-gap: 10px;
|
grid-column-gap: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,4 +283,9 @@ export const GlobalStyles = `
|
|||||||
color: var(--success-color-medium, green);
|
color: var(--success-color-medium, green);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pdk_diagnostic_alert__summary__item__icon {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -490,7 +490,7 @@ var GlobalStyles = `
|
|||||||
|
|
||||||
.pdk_diagnostic_alert__summary__item {
|
.pdk_diagnostic_alert__summary__item {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: auto 1fr;
|
grid-template-columns: 16px auto 1fr;
|
||||||
grid-column-gap: 10px;
|
grid-column-gap: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -506,6 +506,11 @@ var GlobalStyles = `
|
|||||||
color: var(--success-color-medium, green);
|
color: var(--success-color-medium, green);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pdk_diagnostic_alert__summary__item__icon {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// src/helpers/injectGlobalStyles.ts
|
// src/helpers/injectGlobalStyles.ts
|
||||||
@@ -942,10 +947,16 @@ function validateProxyUrl(url) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// src/clash/methods/createBaseApiRequest.ts
|
// src/api/createBaseApiRequest.ts
|
||||||
async function createBaseApiRequest(fetchFn) {
|
async function createBaseApiRequest(fetchFn, options) {
|
||||||
|
const wrappedFn = () => options?.timeoutMs && options?.operationName ? withTimeout(
|
||||||
|
fetchFn(),
|
||||||
|
options.timeoutMs,
|
||||||
|
options.operationName,
|
||||||
|
options.timeoutMessage
|
||||||
|
) : fetchFn();
|
||||||
try {
|
try {
|
||||||
const response = await fetchFn();
|
const response = await wrappedFn();
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
@@ -2357,20 +2368,102 @@ function renderCircleXIcon24() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// src/icons/renderCheckIcon24.ts
|
||||||
|
function renderCheckIcon24() {
|
||||||
|
const NS = "http://www.w3.org/2000/svg";
|
||||||
|
return svgEl(
|
||||||
|
"svg",
|
||||||
|
{
|
||||||
|
xmlns: NS,
|
||||||
|
viewBox: "0 0 24 24",
|
||||||
|
fill: "none",
|
||||||
|
stroke: "currentColor",
|
||||||
|
"stroke-width": "2",
|
||||||
|
"stroke-linecap": "round",
|
||||||
|
"stroke-linejoin": "round",
|
||||||
|
class: "lucide lucide-check-icon lucide-check"
|
||||||
|
},
|
||||||
|
[
|
||||||
|
svgEl("path", {
|
||||||
|
d: "M20 6 9 17l-5-5"
|
||||||
|
})
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// src/icons/renderXIcon24.ts
|
||||||
|
function renderXIcon24() {
|
||||||
|
const NS = "http://www.w3.org/2000/svg";
|
||||||
|
return svgEl(
|
||||||
|
"svg",
|
||||||
|
{
|
||||||
|
xmlns: NS,
|
||||||
|
viewBox: "0 0 24 24",
|
||||||
|
fill: "none",
|
||||||
|
stroke: "currentColor",
|
||||||
|
"stroke-width": "2",
|
||||||
|
"stroke-linecap": "round",
|
||||||
|
"stroke-linejoin": "round",
|
||||||
|
class: "lucide lucide-x-icon lucide-x"
|
||||||
|
},
|
||||||
|
[svgEl("path", { d: "M18 6 6 18" }), svgEl("path", { d: "m6 6 12 12" })]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// src/icons/renderTriangleAlertIcon24.ts
|
||||||
|
function renderTriangleAlertIcon24() {
|
||||||
|
const NS = "http://www.w3.org/2000/svg";
|
||||||
|
return svgEl(
|
||||||
|
"svg",
|
||||||
|
{
|
||||||
|
xmlns: NS,
|
||||||
|
viewBox: "0 0 24 24",
|
||||||
|
fill: "none",
|
||||||
|
stroke: "currentColor",
|
||||||
|
"stroke-width": "2",
|
||||||
|
"stroke-linecap": "round",
|
||||||
|
"stroke-linejoin": "round",
|
||||||
|
class: "lucide lucide-triangle-alert-icon lucide-triangle-alert"
|
||||||
|
},
|
||||||
|
[
|
||||||
|
svgEl("path", {
|
||||||
|
d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"
|
||||||
|
}),
|
||||||
|
svgEl("path", { d: "M12 9v4" }),
|
||||||
|
svgEl("path", { d: "M12 17h.01" })
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// src/podkop/tabs/diagnostic/renderCheckSection.ts
|
// src/podkop/tabs/diagnostic/renderCheckSection.ts
|
||||||
function renderCheckSummary(items) {
|
function renderCheckSummary(items) {
|
||||||
if (!items.length) {
|
if (!items.length) {
|
||||||
return E("div", {}, "");
|
return E("div", {}, "");
|
||||||
}
|
}
|
||||||
const renderedItems = items.map(
|
const renderedItems = items.map((item) => {
|
||||||
(item) => E(
|
function getIcon() {
|
||||||
|
const iconWrap = E("span", {
|
||||||
|
class: "pdk_diagnostic_alert__summary__item__icon"
|
||||||
|
});
|
||||||
|
if (item.state === "success") {
|
||||||
|
iconWrap.appendChild(renderCheckIcon24());
|
||||||
|
}
|
||||||
|
if (item.state === "warning") {
|
||||||
|
iconWrap.appendChild(renderTriangleAlertIcon24());
|
||||||
|
}
|
||||||
|
if (item.state === "error") {
|
||||||
|
iconWrap.appendChild(renderXIcon24());
|
||||||
|
}
|
||||||
|
return iconWrap;
|
||||||
|
}
|
||||||
|
return E(
|
||||||
"div",
|
"div",
|
||||||
{
|
{
|
||||||
class: `pdk_diagnostic_alert__summary__item pdk_diagnostic_alert__summary__item--${item.state}`
|
class: `pdk_diagnostic_alert__summary__item pdk_diagnostic_alert__summary__item--${item.state}`
|
||||||
},
|
},
|
||||||
[E("b", {}, item.key), E("div", {}, item.value)]
|
[getIcon(), E("b", {}, item.key), E("div", {}, item.value)]
|
||||||
)
|
);
|
||||||
);
|
});
|
||||||
return E("div", { class: "pdk_diagnostic_alert__summary" }, renderedItems);
|
return E("div", { class: "pdk_diagnostic_alert__summary" }, renderedItems);
|
||||||
}
|
}
|
||||||
function renderLoadingState3(props) {
|
function renderLoadingState3(props) {
|
||||||
@@ -2552,19 +2645,19 @@ async function runDnsCheck() {
|
|||||||
{
|
{
|
||||||
state: data.bootstrap_dns_status ? "success" : "error",
|
state: data.bootstrap_dns_status ? "success" : "error",
|
||||||
key: _("Bootsrap DNS"),
|
key: _("Bootsrap DNS"),
|
||||||
value: `${data.bootstrap_dns_server} ${data.bootstrap_dns_status ? "\u2705" : "\u274C"}`
|
value: data.bootstrap_dns_server
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
{
|
{
|
||||||
state: data.dns_status ? "success" : "error",
|
state: data.dns_status ? "success" : "error",
|
||||||
key: _("Main DNS"),
|
key: _("Main DNS"),
|
||||||
value: `${data.dns_server} [${data.dns_type}] ${data.dns_status ? "\u2705" : "\u274C"}`
|
value: `${data.dns_server} [${data.dns_type}]`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.local_dns_status ? "success" : "error",
|
state: data.local_dns_status ? "success" : "error",
|
||||||
key: _("Local DNS"),
|
key: _("Local DNS"),
|
||||||
value: data.local_dns_status ? "\u2705" : "\u274C"
|
value: ""
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -2616,32 +2709,32 @@ async function runSingBoxCheck() {
|
|||||||
{
|
{
|
||||||
state: data.sing_box_installed ? "success" : "error",
|
state: data.sing_box_installed ? "success" : "error",
|
||||||
key: _("Sing-box installed"),
|
key: _("Sing-box installed"),
|
||||||
value: data.sing_box_installed ? _("Yes") : _("No")
|
value: ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.sing_box_version_ok ? "success" : "error",
|
state: data.sing_box_version_ok ? "success" : "error",
|
||||||
key: _("Sing-box version >= 1.12.4"),
|
key: _("Sing-box version >= 1.12.4"),
|
||||||
value: data.sing_box_version_ok ? _("Yes") : _("No")
|
value: ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.sing_box_service_exist ? "success" : "error",
|
state: data.sing_box_service_exist ? "success" : "error",
|
||||||
key: _("Sing-box service exist"),
|
key: _("Sing-box service exist"),
|
||||||
value: data.sing_box_service_exist ? _("Yes") : _("No")
|
value: ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.sing_box_autostart_disabled ? "success" : "error",
|
state: data.sing_box_autostart_disabled ? "success" : "error",
|
||||||
key: _("Sing-box autostart disabled"),
|
key: _("Sing-box autostart disabled"),
|
||||||
value: data.sing_box_autostart_disabled ? _("Yes") : _("No")
|
value: ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.sing_box_process_running ? "success" : "error",
|
state: data.sing_box_process_running ? "success" : "error",
|
||||||
key: _("Sing-box process running"),
|
key: _("Sing-box process running"),
|
||||||
value: data.sing_box_process_running ? _("Yes") : _("No")
|
value: ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.sing_box_ports_listening ? "success" : "error",
|
state: data.sing_box_ports_listening ? "success" : "error",
|
||||||
key: _("Sing-box listening ports"),
|
key: _("Sing-box listening ports"),
|
||||||
value: data.sing_box_ports_listening ? _("Yes") : _("No")
|
value: ""
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -2650,9 +2743,39 @@ 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
|
// src/podkop/tabs/diagnostic/checks/runNftCheck.ts
|
||||||
async function runNftCheck() {
|
async function runNftCheck() {
|
||||||
const code = "nft_check";
|
const code = "nft_check";
|
||||||
|
await getFakeIpCheck();
|
||||||
|
await getIpCheck();
|
||||||
updateDiagnosticsCheck({
|
updateDiagnosticsCheck({
|
||||||
code,
|
code,
|
||||||
title: _("Nftables checks"),
|
title: _("Nftables checks"),
|
||||||
@@ -2693,42 +2816,42 @@ async function runNftCheck() {
|
|||||||
{
|
{
|
||||||
state: data.table_exist ? "success" : "error",
|
state: data.table_exist ? "success" : "error",
|
||||||
key: _("Table exist"),
|
key: _("Table exist"),
|
||||||
value: data.table_exist ? _("Yes") : _("No")
|
value: ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.rules_mangle_exist ? "success" : "error",
|
state: data.rules_mangle_exist ? "success" : "error",
|
||||||
key: _("Rules mangle exist"),
|
key: _("Rules mangle exist"),
|
||||||
value: data.rules_mangle_exist ? _("Yes") : _("No")
|
value: ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.rules_mangle_counters ? "success" : "error",
|
state: data.rules_mangle_counters ? "success" : "error",
|
||||||
key: _("Rules mangle counters"),
|
key: _("Rules mangle counters"),
|
||||||
value: data.rules_mangle_counters ? _("Yes") : _("No")
|
value: ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.rules_mangle_output_exist ? "success" : "error",
|
state: data.rules_mangle_output_exist ? "success" : "error",
|
||||||
key: _("Rules mangle output exist"),
|
key: _("Rules mangle output exist"),
|
||||||
value: data.rules_mangle_output_exist ? _("Yes") : _("No")
|
value: ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.rules_mangle_output_counters ? "success" : "error",
|
state: data.rules_mangle_output_counters ? "success" : "error",
|
||||||
key: _("Rules mangle output counters"),
|
key: _("Rules mangle output counters"),
|
||||||
value: data.rules_mangle_output_counters ? _("Yes") : _("No")
|
value: ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.rules_proxy_exist ? "success" : "error",
|
state: data.rules_proxy_exist ? "success" : "error",
|
||||||
key: _("Rules proxy exist"),
|
key: _("Rules proxy exist"),
|
||||||
value: data.rules_proxy_exist ? _("Yes") : _("No")
|
value: ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.rules_proxy_counters ? "success" : "error",
|
state: data.rules_proxy_counters ? "success" : "error",
|
||||||
key: _("Rules proxy counters"),
|
key: _("Rules proxy counters"),
|
||||||
value: data.rules_proxy_counters ? _("Yes") : _("No")
|
value: ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: data.rules_other_mark_exist ? "warning" : "success",
|
state: !data.rules_other_mark_exist ? "success" : "warning",
|
||||||
key: _("Rules other mark exist"),
|
key: _("None other Mark rules"),
|
||||||
value: data.rules_other_mark_exist ? _("Yes") : _("No")
|
value: ""
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -2745,7 +2868,23 @@ async function runFakeIPCheck() {
|
|||||||
title: _("Fake IP checks"),
|
title: _("Fake IP checks"),
|
||||||
description: _("Not implemented yet"),
|
description: _("Not implemented yet"),
|
||||||
state: "skipped",
|
state: "skipped",
|
||||||
items: []
|
items: [
|
||||||
|
{
|
||||||
|
state: "success",
|
||||||
|
key: "success",
|
||||||
|
value: ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
state: "warning",
|
||||||
|
key: "warning",
|
||||||
|
value: ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
state: "error",
|
||||||
|
key: "error",
|
||||||
|
value: ""
|
||||||
|
}
|
||||||
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2804,7 +2943,6 @@ return baseclass.extend({
|
|||||||
UPDATE_INTERVAL_OPTIONS,
|
UPDATE_INTERVAL_OPTIONS,
|
||||||
bulkValidate,
|
bulkValidate,
|
||||||
coreService,
|
coreService,
|
||||||
createBaseApiRequest,
|
|
||||||
executeShellCommand,
|
executeShellCommand,
|
||||||
getBaseUrl,
|
getBaseUrl,
|
||||||
getClashApiUrl,
|
getClashApiUrl,
|
||||||
|
|||||||
Reference in New Issue
Block a user