From 078fc54886ff8ff307dccda0cfb60afef83c3294 Mon Sep 17 00:00:00 2001 From: yaling888 <73897884+yaling888@users.noreply.github.com> Date: Fri, 6 May 2022 06:03:30 +0800 Subject: feat: add reload config-file & flush fake-ip pool to config page --- src/components/Config.tsx | 49 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) (limited to 'src/components') diff --git a/src/components/Config.tsx b/src/components/Config.tsx index 34bb20a..5035a86 100644 --- a/src/components/Config.tsx +++ b/src/components/Config.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { LogOut } from 'react-feather'; +import { LogOut, RotateCw, Trash2 } from 'react-feather'; import { useTranslation } from 'react-i18next'; import * as logsApi from 'src/api/logs'; import Select from 'src/components/shared/Select'; @@ -11,7 +11,7 @@ import { getLatencyTestUrl, getSelectedChartStyleIndex, } from '../store/app'; -import { fetchConfigs, getConfigs, updateConfigs } from '../store/configs'; +import { fetchConfigs, getConfigs, updateConfigs, reloadConfigs, flushFakeIPPool } from '../store/configs'; import { openModal } from '../store/modals'; import Button from './Button'; import s0 from './Config.module.scss'; @@ -29,8 +29,8 @@ const propsList = [{ id: 0 }, { id: 1 }, { id: 2 }, { id: 3 }]; const logLeveOptions = [ ['debug', 'Debug'], - ['warning', 'Warning'], ['info', 'Info'], + ['warning', 'Warning'], ['error', 'Error'], ['silent', 'Silent'], ]; @@ -40,6 +40,8 @@ const portFields = [ { key: 'socks-port', label: 'SOCKS5 Proxy Port' }, { key: 'mixed-port', label: 'Mixed Port' }, { key: 'redir-port', label: 'Redir Port' }, + { key: 'tproxy-port', label: 'tProxy Port' }, + { key: 'mitm-port', label: 'MITM Port' }, ]; const langOptions = [ @@ -50,6 +52,7 @@ const langOptions = [ const modeOptions = [ ['Global', 'Global'], ['Rule', 'Rule'], + ['Script', 'Script'], ['Direct', 'Direct'], ]; @@ -130,6 +133,8 @@ function ConfigImpl({ logsApi.reconnect({ ...apiConfig, logLevel: value }); } break; + case 'mitm-port': + case 'tproxy-port': case 'redir-port': case 'socks-port': case 'mixed-port': @@ -162,7 +167,9 @@ function ConfigImpl({ case 'port': case 'socks-port': case 'mixed-port': - case 'redir-port': { + case 'redir-port': + case 'tproxy-port': + case 'mitm-port': { const num = parseInt(value, 10); if (num < 0 || num > 65535) return; dispatch(updateConfigs(apiConfig, { [name]: num })); @@ -179,6 +186,14 @@ function ConfigImpl({ [apiConfig, dispatch, updateAppConfig] ); + const handleReloadConfigs = useCallback(() => { + dispatch(reloadConfigs(apiConfig)); + },[apiConfig, dispatch]); + + const handleFlushFakeIPPool = useCallback(() => { + dispatch(flushFakeIPPool(apiConfig)); + },[apiConfig, dispatch]); + const mode = useMemo(() => { const m = configState.mode; return typeof m === 'string' && m[0].toUpperCase() + m.slice(1); @@ -283,6 +298,32 @@ function ConfigImpl({ /> + +
+
+
+ +
+
+
Reload
+
+
+ +
+
+
FakeIP
+
+
); } -- cgit v1.3.1