diff --git a/cmd/frpp/shared/cmd.go b/cmd/frpp/shared/cmd.go index 7d75575..14b31fc 100644 --- a/cmd/frpp/shared/cmd.go +++ b/cmd/frpp/shared/cmd.go @@ -352,35 +352,35 @@ func patchConfig(appInstance app.Application, commonArgs CommonArgs) conf.Config c := context.Background() tmpCfg := appInstance.GetConfig() - if commonArgs.RpcHost != nil { + if commonArgs.RpcHost != nil && len(*commonArgs.RpcHost) > 0 { tmpCfg.Master.RPCHost = *commonArgs.RpcHost tmpCfg.Master.APIHost = *commonArgs.RpcHost } - if commonArgs.ApiHost != nil { + if commonArgs.ApiHost != nil && len(*commonArgs.RpcHost) > 0 { tmpCfg.Master.APIHost = *commonArgs.ApiHost } - if commonArgs.RpcPort != nil { + if commonArgs.RpcPort != nil && *commonArgs.RpcPort > 0 { tmpCfg.Master.RPCPort = *commonArgs.RpcPort } - if commonArgs.ApiPort != nil { + if commonArgs.ApiPort != nil && *commonArgs.ApiPort > 0 { tmpCfg.Master.APIPort = *commonArgs.ApiPort } - if commonArgs.ApiScheme != nil { + if commonArgs.ApiScheme != nil && len(*commonArgs.ApiScheme) > 0 { tmpCfg.Master.APIScheme = *commonArgs.ApiScheme } - if commonArgs.ClientID != nil { + if commonArgs.ClientID != nil && len(*commonArgs.ClientID) > 0 { tmpCfg.Client.ID = *commonArgs.ClientID } - if commonArgs.ClientSecret != nil { + if commonArgs.ClientSecret != nil && len(*commonArgs.ClientSecret) > 0 { tmpCfg.Client.Secret = *commonArgs.ClientSecret } - if commonArgs.ApiUrl != nil { + if commonArgs.ApiUrl != nil && len(*commonArgs.ApiUrl) > 0 { tmpCfg.Client.APIUrl = *commonArgs.ApiUrl } - if commonArgs.RpcUrl != nil { + if commonArgs.RpcUrl != nil && len(*commonArgs.RpcUrl) > 0 { tmpCfg.Client.RPCUrl = *commonArgs.RpcUrl } diff --git a/www/components/proxy/mutate_proxy_config.tsx b/www/components/proxy/mutate_proxy_config.tsx index 348000a..f626f91 100644 --- a/www/components/proxy/mutate_proxy_config.tsx +++ b/www/components/proxy/mutate_proxy_config.tsx @@ -27,6 +27,8 @@ import { ProxyConfig, Server } from '@/lib/pb/common' import { TypedProxyConfigValid } from '@/lib/consts' import { toast } from 'sonner' import { $proxyTableRefetchTrigger } from '@/store/refetch-trigger' +import { Switch } from '../ui/switch' +import { Textarea } from '../ui/textarea' export type ProxyConfigMutateDialogProps = { overwrite?: boolean @@ -72,6 +74,9 @@ export const ProxyConfigMutateForm = ({ const [proxyType, setProxyType] = useState('http') const [selectedServer, setSelectedServer] = useState() const supportedProxyTypes: ProxyType[] = ['http', 'tcp', 'udp'] + // advanced mode toggle + const [advancedMode, setAdvancedMode] = useState(false) + const [rawConfig, setRawConfig] = useState('{}') const createProxyConfigMutation = useMutation({ mutationKey: ['createProxyConfig', newClientID, newServerID], @@ -99,10 +104,16 @@ export const ProxyConfigMutateForm = ({ useEffect(() => { if (proxyName && proxyType) { - setProxyConfigs([{...defaultProxyConfig, name: proxyName, type: proxyType }]) + setProxyConfigs([{ ...defaultProxyConfig, name: proxyName, type: proxyType }]) } }, [proxyName, proxyType]) + useEffect(() => { + if (proxyConfigs) { + setRawConfig(JSON.stringify(proxyConfigs, null, 2)) + } + }, [proxyConfigs, setRawConfig]) + useEffect(() => { if (defaultProxyConfig && defaultOriginalProxyConfig) { setProxyConfigs([defaultProxyConfig]) @@ -110,6 +121,7 @@ export const ProxyConfigMutateForm = ({ setProxyName(defaultProxyConfig.name) setNewClientID(defaultOriginalProxyConfig.originClientId) setNewServerID(defaultOriginalProxyConfig.serverId) + setRawConfig(JSON.stringify([defaultProxyConfig], null, 2)) } }, [defaultProxyConfig, defaultOriginalProxyConfig]) @@ -119,45 +131,76 @@ export const ProxyConfigMutateForm = ({ - - ({ value: type, label: type }))} - value={proxyType} - setValue={(value) => { - setProxyType(value as ProxyType) - }} - /> - {proxyConfigs && - selectedServer && - proxyConfigs.length > 0 && - proxyConfigs[0] && - TypedProxyConfigValid(proxyConfigs[0]) && ( -
-
- -
-
- )} - - setProxyName(e.target.value)} - disabled={disableChangeProxyName} - /> - {proxyName && newClientID && newServerID && ( - 0 ? proxyConfigs[0] : undefined} - clientProxyConfigs={proxyConfigs} - setClientProxyConfigs={setProxyConfigs} - enablePreview={false} - /> +
+ + +
+ {!advancedMode && ( + <> + + ({ value: type, label: type }))} + value={proxyType} + setValue={(value) => { + setProxyType(value as ProxyType) + }} + /> + {proxyConfigs && + selectedServer && + proxyConfigs.length > 0 && + proxyConfigs[0] && + TypedProxyConfigValid(proxyConfigs[0]) && ( +
+
+ +
+
+ )} + + setProxyName(e.target.value)} + disabled={disableChangeProxyName} + /> + {proxyName && newClientID && newServerID && ( + 0 ? proxyConfigs[0] : undefined} + clientProxyConfigs={proxyConfigs} + setClientProxyConfigs={setProxyConfigs} + enablePreview={false} + /> + )} + + )} + {advancedMode && ( + <> + +