mirror of
https://github.com/itdoginfo/podkop.git
synced 2026-01-29 13:50:37 +03:00
feat: implement fakeip checks step
This commit is contained in:
24
fe-app-podkop/src/podkop/methods/getFakeIPCheck.ts
Normal file
24
fe-app-podkop/src/podkop/methods/getFakeIPCheck.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
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: '',
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -5,3 +5,4 @@ export * from './getSingBoxStatus';
|
|||||||
export * from './getDNSCheck';
|
export * from './getDNSCheck';
|
||||||
export * from './getNftRulesCheck';
|
export * from './getNftRulesCheck';
|
||||||
export * from './getSingBoxCheck';
|
export * from './getSingBoxCheck';
|
||||||
|
export * from './getFakeIPCheck';
|
||||||
|
|||||||
@@ -1,29 +1,101 @@
|
|||||||
|
import * as podkopMethods from '../../../methods';
|
||||||
|
import * as fakeIPMethods from '../../../../fakeip/methods';
|
||||||
import { updateDiagnosticsCheck } from '../updateDiagnosticsCheck';
|
import { updateDiagnosticsCheck } from '../updateDiagnosticsCheck';
|
||||||
|
import { insertIf } from '../../../../helpers';
|
||||||
|
import { IDiagnosticsChecksItem } from '../../../../store';
|
||||||
|
|
||||||
export async function runFakeIPCheck() {
|
export async function runFakeIPCheck() {
|
||||||
const code = 'fake_ip_check';
|
const code = 'fake_ip_check';
|
||||||
|
|
||||||
updateDiagnosticsCheck({
|
updateDiagnosticsCheck({
|
||||||
code,
|
code,
|
||||||
title: _('Fake IP checks'),
|
title: _('FakeIP checks'),
|
||||||
description: _('Not implemented yet'),
|
description: _('Checking FakeIP, please wait'),
|
||||||
state: 'skipped',
|
state: 'loading',
|
||||||
|
items: [],
|
||||||
|
});
|
||||||
|
|
||||||
|
const routerFakeIPResponse = await podkopMethods.getFakeIPCheck();
|
||||||
|
const checkFakeIPResponse = await fakeIPMethods.getFakeIpCheck();
|
||||||
|
const checkIPResponse = await fakeIPMethods.getIpCheck();
|
||||||
|
|
||||||
|
console.log('runFakeIPCheck', {
|
||||||
|
routerFakeIPResponse,
|
||||||
|
checkFakeIPResponse,
|
||||||
|
checkIPResponse,
|
||||||
|
});
|
||||||
|
|
||||||
|
const checks = {
|
||||||
|
router: routerFakeIPResponse.success && routerFakeIPResponse.data.fakeip,
|
||||||
|
browserFakeIP:
|
||||||
|
checkFakeIPResponse.success && checkFakeIPResponse.data.fakeip,
|
||||||
|
differentIP:
|
||||||
|
checkFakeIPResponse.success &&
|
||||||
|
checkIPResponse.success &&
|
||||||
|
checkFakeIPResponse.data.IP !== checkIPResponse.data.IP,
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log('checks', checks);
|
||||||
|
|
||||||
|
const allGood = checks.router || checks.browserFakeIP || checks.differentIP;
|
||||||
|
const atLeastOneGood =
|
||||||
|
checks.router && checks.browserFakeIP && checks.differentIP;
|
||||||
|
|
||||||
|
function getMeta(): {
|
||||||
|
description: string;
|
||||||
|
state: 'loading' | 'warning' | 'success' | 'error' | 'skipped';
|
||||||
|
} {
|
||||||
|
if (allGood) {
|
||||||
|
return {
|
||||||
|
state: 'success',
|
||||||
|
description: _('FakeIP checks passed'),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (atLeastOneGood) {
|
||||||
|
return {
|
||||||
|
state: 'warning',
|
||||||
|
description: _('FakeIP checks partially passed'),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
state: 'error',
|
||||||
|
description: _('FakeIP checks failed'),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const { state, description } = getMeta();
|
||||||
|
|
||||||
|
updateDiagnosticsCheck({
|
||||||
|
code,
|
||||||
|
title: _('FakeIP checks'),
|
||||||
|
description,
|
||||||
|
state,
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
state: 'success',
|
state: checks.router ? 'success' : 'warning',
|
||||||
key: 'success',
|
key: checks.router
|
||||||
|
? _('Router DNS is routed through sing-box')
|
||||||
|
: _('Router DNS is not routed through sing-box'),
|
||||||
value: '',
|
value: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: 'warning',
|
state: checks.browserFakeIP ? 'success' : 'error',
|
||||||
key: 'warning',
|
key: checks.browserFakeIP
|
||||||
value: '',
|
? _('Browser is using FakeIP correctly')
|
||||||
},
|
: _('Browser is not using FakeIP'),
|
||||||
{
|
|
||||||
state: 'error',
|
|
||||||
key: 'error',
|
|
||||||
value: '',
|
value: '',
|
||||||
},
|
},
|
||||||
|
...insertIf<IDiagnosticsChecksItem>(checks.browserFakeIP, [
|
||||||
|
{
|
||||||
|
state: checks.differentIP ? 'success' : 'error',
|
||||||
|
key: checks.differentIP
|
||||||
|
? _('Proxy traffic is routed via FakeIP')
|
||||||
|
: _('Proxy traffic is not routed via FakeIP'),
|
||||||
|
value: '',
|
||||||
|
},
|
||||||
|
]),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,6 @@ 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'),
|
||||||
@@ -16,6 +13,9 @@ export async function runNftCheck() {
|
|||||||
items: [],
|
items: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await getFakeIpCheck();
|
||||||
|
await getIpCheck();
|
||||||
|
|
||||||
const nftablesChecks = await getNftRulesCheck();
|
const nftablesChecks = await getNftRulesCheck();
|
||||||
|
|
||||||
if (!nftablesChecks.success) {
|
if (!nftablesChecks.success) {
|
||||||
|
|||||||
@@ -97,4 +97,9 @@ export namespace Podkop {
|
|||||||
sing_box_process_running: 0 | 1;
|
sing_box_process_running: 0 | 1;
|
||||||
sing_box_ports_listening: 0 | 1;
|
sing_box_ports_listening: 0 | 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface FakeIPCheckResult {
|
||||||
|
fakeip: boolean;
|
||||||
|
IP: string;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1268,6 +1268,25 @@ async function getSingBoxCheck() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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/services/tab.service.ts
|
// src/podkop/services/tab.service.ts
|
||||||
var TabService = class _TabService {
|
var TabService = class _TabService {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -2774,8 +2793,6 @@ async function getFakeIpCheck() {
|
|||||||
// 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"),
|
||||||
@@ -2783,6 +2800,8 @@ async function runNftCheck() {
|
|||||||
state: "loading",
|
state: "loading",
|
||||||
items: []
|
items: []
|
||||||
});
|
});
|
||||||
|
await getFakeIpCheck();
|
||||||
|
await getIpCheck();
|
||||||
const nftablesChecks = await getNftRulesCheck();
|
const nftablesChecks = await getNftRulesCheck();
|
||||||
if (!nftablesChecks.success) {
|
if (!nftablesChecks.success) {
|
||||||
updateDiagnosticsCheck({
|
updateDiagnosticsCheck({
|
||||||
@@ -2865,25 +2884,69 @@ async function runFakeIPCheck() {
|
|||||||
const code = "fake_ip_check";
|
const code = "fake_ip_check";
|
||||||
updateDiagnosticsCheck({
|
updateDiagnosticsCheck({
|
||||||
code,
|
code,
|
||||||
title: _("Fake IP checks"),
|
title: _("FakeIP checks"),
|
||||||
description: _("Not implemented yet"),
|
description: _("Checking FakeIP, please wait"),
|
||||||
state: "skipped",
|
state: "loading",
|
||||||
|
items: []
|
||||||
|
});
|
||||||
|
const routerFakeIPResponse = await getFakeIPCheck();
|
||||||
|
const checkFakeIPResponse = await getFakeIpCheck();
|
||||||
|
const checkIPResponse = await getIpCheck();
|
||||||
|
console.log("runFakeIPCheck", {
|
||||||
|
routerFakeIPResponse,
|
||||||
|
checkFakeIPResponse,
|
||||||
|
checkIPResponse
|
||||||
|
});
|
||||||
|
const checks = {
|
||||||
|
router: routerFakeIPResponse.success && routerFakeIPResponse.data.fakeip,
|
||||||
|
browserFakeIP: checkFakeIPResponse.success && checkFakeIPResponse.data.fakeip,
|
||||||
|
differentIP: checkFakeIPResponse.success && checkIPResponse.success && checkFakeIPResponse.data.IP !== checkIPResponse.data.IP
|
||||||
|
};
|
||||||
|
console.log("checks", checks);
|
||||||
|
const allGood = checks.router || checks.browserFakeIP || checks.differentIP;
|
||||||
|
const atLeastOneGood = checks.router && checks.browserFakeIP && checks.differentIP;
|
||||||
|
function getMeta() {
|
||||||
|
if (allGood) {
|
||||||
|
return {
|
||||||
|
state: "success",
|
||||||
|
description: _("FakeIP checks passed")
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (atLeastOneGood) {
|
||||||
|
return {
|
||||||
|
state: "warning",
|
||||||
|
description: _("FakeIP checks partially passed")
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
state: "error",
|
||||||
|
description: _("FakeIP checks failed")
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const { state, description } = getMeta();
|
||||||
|
updateDiagnosticsCheck({
|
||||||
|
code,
|
||||||
|
title: _("FakeIP checks"),
|
||||||
|
description,
|
||||||
|
state,
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
state: "success",
|
state: checks.router ? "success" : "warning",
|
||||||
key: "success",
|
key: checks.router ? _("Router DNS is routed through sing-box") : _("Router DNS is not routed through sing-box"),
|
||||||
value: ""
|
value: ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
state: "warning",
|
state: checks.browserFakeIP ? "success" : "error",
|
||||||
key: "warning",
|
key: checks.browserFakeIP ? _("Browser is using FakeIP correctly") : _("Browser is not using FakeIP"),
|
||||||
value: ""
|
value: ""
|
||||||
},
|
},
|
||||||
{
|
...insertIf(checks.browserFakeIP, [
|
||||||
state: "error",
|
{
|
||||||
key: "error",
|
state: checks.differentIP ? "success" : "error",
|
||||||
value: ""
|
key: checks.differentIP ? _("Proxy traffic is routed via FakeIP") : _("Proxy traffic is not routed via FakeIP"),
|
||||||
}
|
value: ""
|
||||||
|
}
|
||||||
|
])
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -2955,6 +3018,7 @@ return baseclass.extend({
|
|||||||
getConfigSections,
|
getConfigSections,
|
||||||
getDNSCheck,
|
getDNSCheck,
|
||||||
getDashboardSections,
|
getDashboardSections,
|
||||||
|
getFakeIPCheck,
|
||||||
getNftRulesCheck,
|
getNftRulesCheck,
|
||||||
getPodkopStatus,
|
getPodkopStatus,
|
||||||
getProxyUrlName,
|
getProxyUrlName,
|
||||||
|
|||||||
Reference in New Issue
Block a user