diff --git a/internal/application/frpc/service.go b/internal/application/frpc/service.go index d84b779..a86bd85 100644 --- a/internal/application/frpc/service.go +++ b/internal/application/frpc/service.go @@ -169,6 +169,13 @@ func (fs *Service) genProxyCfgs(serverId *string) ([]v1.ProxyConfigurer, error) } proxyData["name"] = proxyMap.Name + "-" + proxyMap.Id + // Remove empty plugin map so frp doesn't try to parse a typeless plugin + if plugin, ok := proxyData["plugin"].(map[string]interface{}); ok { + if _, hasType := plugin["type"]; !hasType { + delete(proxyData, "plugin") + } + } + jsonData, err = json.Marshal(proxyData) if err != nil { return nil, err diff --git a/internal/domain/proxy/model.go b/internal/domain/proxy/model.go index 4fac08f..3776fd0 100644 --- a/internal/domain/proxy/model.go +++ b/internal/domain/proxy/model.go @@ -14,6 +14,7 @@ type Proxy struct { Subdomain string `db:"subdomain" json:"subdomain"` CustomDomains types.JSONStringArray `db:"customDomains" json:"customDomains"` Transport types.JSONMap `db:"transport" json:"transport"` + Plugin types.JSONMap `db:"plugin" json:"plugin,omitempty"` Description string `db:"description" json:"description"` Status string `db:"status" json:"status"` } diff --git a/site/src/components/RadioCardGroup.tsx b/site/src/components/RadioCardGroup.tsx index 5bfe9cb..ef37cc6 100644 --- a/site/src/components/RadioCardGroup.tsx +++ b/site/src/components/RadioCardGroup.tsx @@ -7,6 +7,8 @@ export interface RadioCardOption { label: string; icon?: string; comingSoon?: boolean; + incompatible?: boolean; + incompatibleLabel?: string; } interface RadioCardGroupProps { @@ -21,7 +23,7 @@ export function RadioCardGroup({ options, value, onChange, comingSoonLabel = "Co {options.map((opt) => { const isActive = value === opt.value; - const disabled = !!opt.comingSoon; + const disabled = !!opt.comingSoon || !!opt.incompatible; return ( ); diff --git a/site/src/locales/en.json b/site/src/locales/en.json index 912d78d..c319120 100644 --- a/site/src/locales/en.json +++ b/site/src/locales/en.json @@ -296,6 +296,7 @@ "sectionPlugin": "Plugin", "pluginEnable": "Enable Plugin", "pluginEnableDesc": "Use a frp plugin to extend proxy functionality", + "pluginTcpOnly": "TCP only", "pluginType": "Plugin Type", "pluginSupported": "Supported", "pluginUsername": "Username", @@ -315,7 +316,9 @@ "disabled": "Disabled", "errorInvalidName": "Invalid name (use alphanumeric, - or _)", "errorInvalidIP": "Invalid IP or hostname", - "errorInvalidPort": "Invalid port (1-65535)" + "errorInvalidPort": "Invalid port (1-65535)", + "errorRequired": "Required", + "errorSubdomainRequired": "Subdomain or custom domains required" }, "settings": { "title": "Settings", @@ -459,4 +462,4 @@ "settingsCreateFailed": "Failed to initialize system settings" } } -} +} \ No newline at end of file diff --git a/site/src/locales/zh.json b/site/src/locales/zh.json index f21ff36..ccbf2ae 100644 --- a/site/src/locales/zh.json +++ b/site/src/locales/zh.json @@ -296,6 +296,7 @@ "sectionPlugin": "插件", "pluginEnable": "启用插件", "pluginEnableDesc": "使用 frp 插件扩展代理功能", + "pluginTcpOnly": "仅限 TCP", "pluginType": "插件类型", "pluginSupported": "已支持", "pluginUsername": "用户名", @@ -315,7 +316,9 @@ "disabled": "已禁用", "errorInvalidName": "无效的名称(使用字母数字、- 或 _)", "errorInvalidIP": "无效的 IP 或主机名", - "errorInvalidPort": "无效的端口(1-65535)" + "errorInvalidPort": "无效的端口(1-65535)", + "errorRequired": "必填", + "errorSubdomainRequired": "子域名或自定义域名为必填项" }, "settings": { "title": "设置", @@ -459,4 +462,4 @@ "settingsCreateFailed": "初始化系统设置失败" } } -} +} \ No newline at end of file diff --git a/site/src/pages/Proxies/ProxiesPage.view.tsx b/site/src/pages/Proxies/ProxiesPage.view.tsx index c8e1c66..b005387 100644 --- a/site/src/pages/Proxies/ProxiesPage.view.tsx +++ b/site/src/pages/Proxies/ProxiesPage.view.tsx @@ -171,7 +171,7 @@ export function ProxiesView({ {proxies.map((proxy) => ( - {proxy.name} + {proxy.name || -} {proxy.proxyType.toUpperCase()} @@ -191,11 +191,52 @@ export function ProxiesView({ )} - - {proxy.localIP || "127.0.0.1"} - + {(() => { + const ip = proxy.localIP || "127.0.0.1"; + const copyKey = `${proxy.id}-localIP`; + const isCopied = copiedId === copyKey; + return ( + handleCopy(ip, copyKey)} + title={isCopied ? t("common.copied") : t("common.clickToCopy")} + > + {ip} + + + ); + })()} + + + {proxy.localPort ? (() => { + const copyKey = `${proxy.id}-localPort`; + const isCopied = copiedId === copyKey; + return ( + handleCopy(String(proxy.localPort), copyKey)} + title={isCopied ? t("common.copied") : t("common.clickToCopy")} + > + {proxy.localPort} + + + ); + })() : -} - {proxy.localPort} {(() => { if (proxy.proxyType === "http" || proxy.proxyType === "https") { diff --git a/site/src/pages/Proxies/ProxyFormPage/ProxyFormPage.view.tsx b/site/src/pages/Proxies/ProxyFormPage/ProxyFormPage.view.tsx index b09e6db..2897a49 100644 --- a/site/src/pages/Proxies/ProxyFormPage/ProxyFormPage.view.tsx +++ b/site/src/pages/Proxies/ProxyFormPage/ProxyFormPage.view.tsx @@ -34,16 +34,16 @@ const proxyTypes = [ { value: "xtcp", label: "XTCP", icon: "lucide:share-2", comingSoon: true }, ]; -const pluginTypes = [ - { value: "socks5", label: "SOCKS5", icon: "lucide:globe", comingSoon: false }, - { value: "http_proxy", label: "HTTPProxy", icon: "lucide:waypoints", comingSoon: true }, - { value: "static_file", label: "StaticFile", icon: "lucide:folder-open", comingSoon: true }, - { value: "unix_domain_socket", label: "UnixDomainSocket", icon: "lucide:cable", comingSoon: true }, - { value: "http2https", label: "HTTP2HTTPS", icon: "lucide:lock", comingSoon: true }, - { value: "https2http", label: "HTTPS2HTTP", icon: "lucide:lock-open", comingSoon: true }, - { value: "https2https", label: "HTTPS2HTTPS", icon: "lucide:shield-check", comingSoon: true }, - { value: "tls2raw", label: "TLS2Raw", icon: "lucide:zap", comingSoon: true }, - { value: "virtual_net", label: "VirtualNet", icon: "lucide:network", comingSoon: true }, +const BASE_PLUGIN_TYPES = [ + { value: "socks5", label: "SOCKS5", icon: "lucide:globe", comingSoon: false, tcpOnly: true }, + { value: "http_proxy", label: "HTTPProxy", icon: "lucide:waypoints", comingSoon: true, tcpOnly: false }, + { value: "static_file", label: "StaticFile", icon: "lucide:folder-open", comingSoon: true, tcpOnly: false }, + { value: "unix_domain_socket", label: "UnixDomainSocket", icon: "lucide:cable", comingSoon: true, tcpOnly: false }, + { value: "http2https", label: "HTTP2HTTPS", icon: "lucide:lock", comingSoon: true, tcpOnly: false }, + { value: "https2http", label: "HTTPS2HTTP", icon: "lucide:lock-open", comingSoon: true, tcpOnly: false }, + { value: "https2https", label: "HTTPS2HTTPS", icon: "lucide:shield-check", comingSoon: true, tcpOnly: false }, + { value: "tls2raw", label: "TLS2Raw", icon: "lucide:zap", comingSoon: true, tcpOnly: false }, + { value: "virtual_net", label: "VirtualNet", icon: "lucide:network", comingSoon: true, tcpOnly: false }, ]; @@ -56,7 +56,7 @@ interface ProxyFormPageViewProps { submitting: boolean; errors: Partial>; isHttpType: boolean; - isSubmitDisabled: boolean; + isSocks5Plugin: boolean; mounted: boolean; onChange: (field: keyof ProxyFormData, value: string | boolean) => void; onSubmit: () => void; @@ -73,7 +73,7 @@ export function ProxyFormPageView({ submitting, errors, isHttpType, - isSubmitDisabled, + isSocks5Plugin, mounted, onChange, onSubmit, @@ -198,31 +198,44 @@ export function ProxyFormPageView({
- - - - onChange("localIp", e.target.value)} - color={errors.localIp ? "red" : undefined} - /> - - - - - onChange("localPort", e.target.value)} - color={errors.localPort ? "red" : undefined} - /> - - - + + {!isSocks5Plugin && ( + + + + + onChange("localIp", e.target.value)} + color={errors.localIp ? "red" : undefined} + /> + + + + + onChange("localPort", e.target.value)} + color={errors.localPort ? "red" : undefined} + /> + + + + + )} + {isHttpType ? ( <> @@ -334,7 +347,11 @@ export function ProxyFormPageView({ > ({ + ...pt, + incompatible: pt.tcpOnly && formData.type !== "tcp", + incompatibleLabel: t("proxy.pluginTcpOnly"), + }))} value={formData.pluginType} onChange={(v) => onChange("pluginType", v as ProxyFormData["pluginType"])} comingSoonLabel={t("common.comingSoon")} @@ -392,7 +409,7 @@ export function ProxyFormPageView({