|
@@ -2,13 +2,10 @@ import { useCallback } from 'react';
|
|
|
import { useTranslation } from 'react-i18next';
|
|
import { useTranslation } from 'react-i18next';
|
|
|
import { Alert, Button, Input, Modal, Select, Space, Switch, Tabs } from 'antd';
|
|
import { Alert, Button, Input, Modal, Select, Space, Switch, Tabs } from 'antd';
|
|
|
import {
|
|
import {
|
|
|
- ApiOutlined,
|
|
|
|
|
BarChartOutlined,
|
|
BarChartOutlined,
|
|
|
- CloudOutlined,
|
|
|
|
|
FileTextOutlined,
|
|
FileTextOutlined,
|
|
|
ReloadOutlined,
|
|
ReloadOutlined,
|
|
|
SettingOutlined,
|
|
SettingOutlined,
|
|
|
- SwapOutlined,
|
|
|
|
|
} from '@ant-design/icons';
|
|
} from '@ant-design/icons';
|
|
|
|
|
|
|
|
import { OutboundDomainStrategies } from '@/schemas/primitives';
|
|
import { OutboundDomainStrategies } from '@/schemas/primitives';
|
|
@@ -20,29 +17,17 @@ import './BasicsTab.css';
|
|
|
|
|
|
|
|
import {
|
|
import {
|
|
|
ACCESS_LOG,
|
|
ACCESS_LOG,
|
|
|
- BITTORRENT_PROTOCOLS,
|
|
|
|
|
- BLOCK_DOMAINS_OPTIONS,
|
|
|
|
|
- DOMAINS_OPTIONS,
|
|
|
|
|
ERROR_LOG,
|
|
ERROR_LOG,
|
|
|
- IPS_OPTIONS,
|
|
|
|
|
LOG_LEVELS,
|
|
LOG_LEVELS,
|
|
|
MASK_ADDRESS,
|
|
MASK_ADDRESS,
|
|
|
ROUTING_DOMAIN_STRATEGIES,
|
|
ROUTING_DOMAIN_STRATEGIES,
|
|
|
- SERVICES_OPTIONS,
|
|
|
|
|
- directSettings,
|
|
|
|
|
- ipv4Settings,
|
|
|
|
|
} from './constants';
|
|
} from './constants';
|
|
|
-import { ruleGetter, ruleSetter, syncOutbound } from './helpers';
|
|
|
|
|
|
|
|
|
|
interface BasicsTabProps {
|
|
interface BasicsTabProps {
|
|
|
templateSettings: XraySettingsValue | null;
|
|
templateSettings: XraySettingsValue | null;
|
|
|
setTemplateSettings: SetTemplate;
|
|
setTemplateSettings: SetTemplate;
|
|
|
outboundTestUrl: string;
|
|
outboundTestUrl: string;
|
|
|
onChangeOutboundTestUrl: (v: string) => void;
|
|
onChangeOutboundTestUrl: (v: string) => void;
|
|
|
- warpExist: boolean;
|
|
|
|
|
- nordExist: boolean;
|
|
|
|
|
- onShowWarp: () => void;
|
|
|
|
|
- onShowNord: () => void;
|
|
|
|
|
onResetDefault: () => void;
|
|
onResetDefault: () => void;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -51,10 +36,6 @@ export default function BasicsTab({
|
|
|
setTemplateSettings,
|
|
setTemplateSettings,
|
|
|
outboundTestUrl,
|
|
outboundTestUrl,
|
|
|
onChangeOutboundTestUrl,
|
|
onChangeOutboundTestUrl,
|
|
|
- warpExist,
|
|
|
|
|
- nordExist,
|
|
|
|
|
- onShowWarp,
|
|
|
|
|
- onShowNord,
|
|
|
|
|
onResetDefault,
|
|
onResetDefault,
|
|
|
}: BasicsTabProps) {
|
|
}: BasicsTabProps) {
|
|
|
const { t } = useTranslation();
|
|
const { t } = useTranslation();
|
|
@@ -92,19 +73,6 @@ export default function BasicsTab({
|
|
|
const log = (templateSettings?.log || {}) as Record<string, unknown>;
|
|
const log = (templateSettings?.log || {}) as Record<string, unknown>;
|
|
|
const policy = (templateSettings?.policy?.system || {}) as Record<string, boolean>;
|
|
const policy = (templateSettings?.policy?.system || {}) as Record<string, boolean>;
|
|
|
|
|
|
|
|
- const blockedIPs = ruleGetter(templateSettings, 'blocked', 'ip');
|
|
|
|
|
- const blockedDomains = ruleGetter(templateSettings, 'blocked', 'domain');
|
|
|
|
|
- const blockedProtocols = ruleGetter(templateSettings, 'blocked', 'protocol');
|
|
|
|
|
- const directIPs = ruleGetter(templateSettings, 'direct', 'ip');
|
|
|
|
|
- const directDomains = ruleGetter(templateSettings, 'direct', 'domain');
|
|
|
|
|
- const ipv4Domains = ruleGetter(templateSettings, 'IPv4', 'domain');
|
|
|
|
|
- const warpDomains = ruleGetter(templateSettings, 'warp', 'domain');
|
|
|
|
|
- const nordTag =
|
|
|
|
|
- templateSettings?.outbounds?.find((o) => o?.tag?.startsWith?.('nord-'))?.tag || 'nord';
|
|
|
|
|
- const nordDomains = ruleGetter(templateSettings, nordTag, 'domain');
|
|
|
|
|
-
|
|
|
|
|
- const torrentActive = BITTORRENT_PROTOCOLS.every((p) => blockedProtocols.includes(p));
|
|
|
|
|
-
|
|
|
|
|
const items = [
|
|
const items = [
|
|
|
{
|
|
{
|
|
|
key: '1',
|
|
key: '1',
|
|
@@ -277,165 +245,6 @@ export default function BasicsTab({
|
|
|
</>
|
|
</>
|
|
|
),
|
|
),
|
|
|
},
|
|
},
|
|
|
- {
|
|
|
|
|
- key: '4',
|
|
|
|
|
- label: catTabLabel(<SwapOutlined />, t('pages.xray.basicRouting'), isMobile),
|
|
|
|
|
- children: (
|
|
|
|
|
- <>
|
|
|
|
|
- <Alert
|
|
|
|
|
- type="warning"
|
|
|
|
|
- showIcon
|
|
|
|
|
- className="mb-12 hint-alert"
|
|
|
|
|
- title={t('pages.xray.blockConnectionsConfigsDesc')}
|
|
|
|
|
- />
|
|
|
|
|
-
|
|
|
|
|
- <SettingListItem
|
|
|
|
|
- title={t('pages.xray.Torrent')}
|
|
|
|
|
- paddings="small"
|
|
|
|
|
- control={
|
|
|
|
|
- <Switch
|
|
|
|
|
- checked={torrentActive}
|
|
|
|
|
- onChange={(checked) => mutate((tt) => {
|
|
|
|
|
- const next = checked
|
|
|
|
|
- ? [...blockedProtocols, ...BITTORRENT_PROTOCOLS]
|
|
|
|
|
- : blockedProtocols.filter((d) => !BITTORRENT_PROTOCOLS.includes(d));
|
|
|
|
|
- ruleSetter(tt, 'blocked', 'protocol', next);
|
|
|
|
|
- })}
|
|
|
|
|
- />
|
|
|
|
|
- }
|
|
|
|
|
- />
|
|
|
|
|
-
|
|
|
|
|
- <SettingListItem
|
|
|
|
|
- title={t('pages.xray.blockips')}
|
|
|
|
|
- paddings="small"
|
|
|
|
|
- control={
|
|
|
|
|
- <Select
|
|
|
|
|
- mode="tags"
|
|
|
|
|
- value={blockedIPs}
|
|
|
|
|
- style={{ width: '100%' }}
|
|
|
|
|
- options={IPS_OPTIONS}
|
|
|
|
|
- onChange={(v) => mutate((tt) => ruleSetter(tt, 'blocked', 'ip', v))}
|
|
|
|
|
- />
|
|
|
|
|
- }
|
|
|
|
|
- />
|
|
|
|
|
-
|
|
|
|
|
- <SettingListItem
|
|
|
|
|
- title={t('pages.xray.blockdomains')}
|
|
|
|
|
- paddings="small"
|
|
|
|
|
- control={
|
|
|
|
|
- <Select
|
|
|
|
|
- mode="tags"
|
|
|
|
|
- value={blockedDomains}
|
|
|
|
|
- style={{ width: '100%' }}
|
|
|
|
|
- options={BLOCK_DOMAINS_OPTIONS}
|
|
|
|
|
- onChange={(v) => mutate((tt) => ruleSetter(tt, 'blocked', 'domain', v))}
|
|
|
|
|
- />
|
|
|
|
|
- }
|
|
|
|
|
- />
|
|
|
|
|
-
|
|
|
|
|
- <Alert
|
|
|
|
|
- type="warning"
|
|
|
|
|
- showIcon
|
|
|
|
|
- className="mb-12 hint-alert"
|
|
|
|
|
- title={t('pages.xray.directConnectionsConfigsDesc')}
|
|
|
|
|
- />
|
|
|
|
|
-
|
|
|
|
|
- <SettingListItem
|
|
|
|
|
- title={t('pages.xray.directips')}
|
|
|
|
|
- paddings="small"
|
|
|
|
|
- control={
|
|
|
|
|
- <Select
|
|
|
|
|
- mode="tags"
|
|
|
|
|
- value={directIPs}
|
|
|
|
|
- style={{ width: '100%' }}
|
|
|
|
|
- options={IPS_OPTIONS}
|
|
|
|
|
- onChange={(v) => mutate((tt) => {
|
|
|
|
|
- ruleSetter(tt, 'direct', 'ip', v);
|
|
|
|
|
- syncOutbound(tt, 'direct', directSettings);
|
|
|
|
|
- })}
|
|
|
|
|
- />
|
|
|
|
|
- }
|
|
|
|
|
- />
|
|
|
|
|
-
|
|
|
|
|
- <SettingListItem
|
|
|
|
|
- title={t('pages.xray.directdomains')}
|
|
|
|
|
- paddings="small"
|
|
|
|
|
- control={
|
|
|
|
|
- <Select
|
|
|
|
|
- mode="tags"
|
|
|
|
|
- value={directDomains}
|
|
|
|
|
- style={{ width: '100%' }}
|
|
|
|
|
- options={DOMAINS_OPTIONS}
|
|
|
|
|
- onChange={(v) => mutate((tt) => {
|
|
|
|
|
- ruleSetter(tt, 'direct', 'domain', v);
|
|
|
|
|
- syncOutbound(tt, 'direct', directSettings);
|
|
|
|
|
- })}
|
|
|
|
|
- />
|
|
|
|
|
- }
|
|
|
|
|
- />
|
|
|
|
|
-
|
|
|
|
|
- <SettingListItem
|
|
|
|
|
- title={t('pages.xray.ipv4Routing')}
|
|
|
|
|
- description={t('pages.xray.ipv4RoutingDesc')}
|
|
|
|
|
- paddings="small"
|
|
|
|
|
- control={
|
|
|
|
|
- <Select
|
|
|
|
|
- mode="tags"
|
|
|
|
|
- value={ipv4Domains}
|
|
|
|
|
- style={{ width: '100%' }}
|
|
|
|
|
- options={SERVICES_OPTIONS}
|
|
|
|
|
- onChange={(v) => mutate((tt) => {
|
|
|
|
|
- ruleSetter(tt, 'IPv4', 'domain', v);
|
|
|
|
|
- syncOutbound(tt, 'IPv4', ipv4Settings);
|
|
|
|
|
- })}
|
|
|
|
|
- />
|
|
|
|
|
- }
|
|
|
|
|
- />
|
|
|
|
|
-
|
|
|
|
|
- <SettingListItem
|
|
|
|
|
- title={t('pages.xray.warpRouting')}
|
|
|
|
|
- description={t('pages.xray.warpRoutingDesc')}
|
|
|
|
|
- paddings="small"
|
|
|
|
|
- control={
|
|
|
|
|
- warpExist ? (
|
|
|
|
|
- <Select
|
|
|
|
|
- mode="tags"
|
|
|
|
|
- value={warpDomains}
|
|
|
|
|
- style={{ width: '100%' }}
|
|
|
|
|
- options={SERVICES_OPTIONS}
|
|
|
|
|
- onChange={(v) => mutate((tt) => ruleSetter(tt, 'warp', 'domain', v))}
|
|
|
|
|
- />
|
|
|
|
|
- ) : (
|
|
|
|
|
- <Button type="primary" onClick={onShowWarp} icon={<CloudOutlined />}>
|
|
|
|
|
- WARP
|
|
|
|
|
- </Button>
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
- />
|
|
|
|
|
-
|
|
|
|
|
- <SettingListItem
|
|
|
|
|
- title={t('pages.xray.nordRouting')}
|
|
|
|
|
- description={t('pages.xray.nordRoutingDesc')}
|
|
|
|
|
- paddings="small"
|
|
|
|
|
- control={
|
|
|
|
|
- nordExist ? (
|
|
|
|
|
- <Select
|
|
|
|
|
- mode="tags"
|
|
|
|
|
- value={nordDomains}
|
|
|
|
|
- style={{ width: '100%' }}
|
|
|
|
|
- options={SERVICES_OPTIONS}
|
|
|
|
|
- onChange={(v) => mutate((tt) => ruleSetter(tt, nordTag, 'domain', v))}
|
|
|
|
|
- />
|
|
|
|
|
- ) : (
|
|
|
|
|
- <Button type="primary" onClick={onShowNord} icon={<ApiOutlined />}>
|
|
|
|
|
- NordVPN
|
|
|
|
|
- </Button>
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
- />
|
|
|
|
|
- </>
|
|
|
|
|
- ),
|
|
|
|
|
- },
|
|
|
|
|
{
|
|
{
|
|
|
key: 'reset',
|
|
key: 'reset',
|
|
|
label: catTabLabel(<ReloadOutlined />, t('pages.settings.resetDefaultConfig'), isMobile),
|
|
label: catTabLabel(<ReloadOutlined />, t('pages.settings.resetDefaultConfig'), isMobile),
|