diff options
| author | Haishan <[email protected]> | 2020-06-30 22:26:06 +0800 |
|---|---|---|
| committer | Haishan <[email protected]> | 2020-06-30 22:49:15 +0800 |
| commit | 9055ea8f7e6cd1307f4277834656ba59cc7d928c (patch) | |
| tree | ad0d9c1179354048b1e32fef492670cfcd4c633d /src/components/Config.js | |
| parent | 9cd5b4efc234a39e541df27d11ddbc11c29ef817 (diff) | |
feat: support mixed-port
Diffstat (limited to 'src/components/Config.js')
| -rw-r--r-- | src/components/Config.js | 51 |
1 files changed, 21 insertions, 30 deletions
diff --git a/src/components/Config.js b/src/components/Config.js index 3bf2043..f3c56d2 100644 --- a/src/components/Config.js +++ b/src/components/Config.js @@ -60,6 +60,13 @@ const optionsLogLevel = [ }, ]; +const portFields = [ + { key: 'port', label: 'HTTP Proxy Port' }, + { key: 'socks-port', label: 'SOCKS5 Proxy Port' }, + { key: 'mixed-port', label: 'Mixed Port' }, + { key: 'redir-port', label: 'Redir Port' }, +]; + const mapState = (s) => ({ configs: getConfigs(s), apiConfig: getClashAPIConfig(s), @@ -153,6 +160,7 @@ function ConfigImpl({ switch (name) { case 'port': case 'socks-port': + case 'mixed-port': case 'redir-port': { const num = parseInt(value, 10); if (num < 0 || num > 65535) return; @@ -179,36 +187,19 @@ function ConfigImpl({ <div> <ContentHeader title="Config" /> <div className={s0.root}> - <div> - <div className={s0.label}>HTTP Proxy Port</div> - <Input - name="port" - value={configState.port} - onChange={handleInputOnChange} - onBlur={handleInputOnBlur} - /> - </div> - - <div> - <div className={s0.label}>SOCKS5 Proxy Port</div> - <Input - name="socks-port" - value={configState['socks-port']} - onChange={handleInputOnChange} - onBlur={handleInputOnBlur} - /> - </div> - - <div> - <div className={s0.label}>Redir Port</div> - <Input - name="redir-port" - value={configState['redir-port']} - onChange={handleInputOnChange} - onBlur={handleInputOnBlur} - /> - </div> - + {portFields.map((f) => + configState[f.key] !== undefined ? ( + <div key={f.key}> + <div className={s0.label}>{f.label}</div> + <Input + name={f.key} + value={configState[f.key]} + onChange={handleInputOnChange} + onBlur={handleInputOnBlur} + /> + </div> + ) : null + )} <div> <div className={s0.label}>Allow LAN</div> <Switch |
