|
- {node.current_version || '未应用'}
+ {node.current_version || (node.node_type === 'tunnel_relay' ? '实时配置' : '未应用')}
|
-
+ {node.node_type === 'tunnel_relay' ? (
+ —
+ ) : (
+
+ )}
|
diff --git a/openflare_server/web/features/proxy-routes/components/proxy-route-config-page.tsx b/openflare_server/web/features/proxy-routes/components/proxy-route-config-page.tsx
index 961a0878..ff048a74 100644
--- a/openflare_server/web/features/proxy-routes/components/proxy-route-config-page.tsx
+++ b/openflare_server/web/features/proxy-routes/components/proxy-route-config-page.tsx
@@ -561,7 +561,7 @@ function ReverseProxySection({
upstream_type: route.upstream_type || 'direct',
origin_urls_text: route.upstream_list.join('\n'),
origin_host: route.origin_host || '',
- tunnel_id: route.tunnel_id ? String(route.tunnel_id) : '',
+ tunnel_id: route.tunnel_node_id ? String(route.tunnel_node_id) : '',
tunnel_target_addr: route.tunnel_target_addr || '',
tunnel_target_protocol: (route.tunnel_target_protocol as 'http' | 'https') || 'http',
custom_headers_text: customHeadersToText(route.custom_header_list),
@@ -574,7 +574,7 @@ function ReverseProxySection({
upstream_type: route.upstream_type || 'direct',
origin_urls_text: route.upstream_list.join('\n'),
origin_host: route.origin_host || '',
- tunnel_id: route.tunnel_id ? String(route.tunnel_id) : '',
+ tunnel_id: route.tunnel_node_id ? String(route.tunnel_node_id) : '',
tunnel_target_addr: route.tunnel_target_addr || '',
tunnel_target_protocol: (route.tunnel_target_protocol as 'http' | 'https') || 'http',
custom_headers_text: customHeadersToText(route.custom_header_list),
@@ -632,7 +632,7 @@ function ReverseProxySection({
custom_headers: headers,
remark: values.remark.trim(),
upstream_type: values.upstream_type,
- tunnel_id: values.upstream_type === 'tunnel' && values.tunnel_id ? Number(values.tunnel_id) : null,
+ tunnel_node_id: values.upstream_type === 'tunnel' && values.tunnel_id ? Number(values.tunnel_id) : null,
tunnel_target_addr: values.upstream_type === 'tunnel' ? values.tunnel_target_addr : '',
tunnel_target_protocol: values.upstream_type === 'tunnel' ? values.tunnel_target_protocol : '',
}),
diff --git a/openflare_server/web/features/proxy-routes/components/proxy-route-create-drawer.tsx b/openflare_server/web/features/proxy-routes/components/proxy-route-create-drawer.tsx
index bee296a8..37528698 100644
--- a/openflare_server/web/features/proxy-routes/components/proxy-route-create-drawer.tsx
+++ b/openflare_server/web/features/proxy-routes/components/proxy-route-create-drawer.tsx
@@ -249,7 +249,7 @@ export function ProxyRouteCreateDrawer({
basic_auth_enabled: false,
remark: values.remark.trim(),
upstream_type: values.upstream_type,
- tunnel_id: values.upstream_type === 'tunnel' && values.tunnel_id ? Number(values.tunnel_id) : null,
+ tunnel_node_id: values.upstream_type === 'tunnel' && values.tunnel_id ? Number(values.tunnel_id) : null,
tunnel_target_addr: values.upstream_type === 'tunnel' ? values.tunnel_target_addr : '',
tunnel_target_protocol: values.upstream_type === 'tunnel' ? values.tunnel_target_protocol : '',
});
diff --git a/openflare_server/web/features/proxy-routes/helpers.ts b/openflare_server/web/features/proxy-routes/helpers.ts
index 2541539c..a9ecd151 100644
--- a/openflare_server/web/features/proxy-routes/helpers.ts
+++ b/openflare_server/web/features/proxy-routes/helpers.ts
@@ -300,11 +300,20 @@ export function buildPayloadFromRoute(
basic_auth_enabled: route.basic_auth_enabled,
basic_auth_username: route.basic_auth_username,
basic_auth_password: route.basic_auth_password,
+ upstream_type: route.upstream_type,
+ tunnel_node_id: route.tunnel_node_id ?? route.tunnel_id ?? null,
+ tunnel_target_addr: route.tunnel_target_addr || '',
+ tunnel_target_protocol: route.tunnel_target_protocol || '',
...overrides,
};
}
export function getUpstreamSummary(route: ProxyRouteItem) {
+ if (route.upstream_type === 'tunnel') {
+ const protocol = route.tunnel_target_protocol || 'http';
+ const target = route.tunnel_target_addr || '未配置目标';
+ return `Tunnel → ${protocol}://${target}`;
+ }
if (route.upstream_list.length <= 1) {
return route.origin_url;
}
diff --git a/openflare_server/web/features/proxy-routes/types.ts b/openflare_server/web/features/proxy-routes/types.ts
index e98ad66f..536ee5dc 100644
--- a/openflare_server/web/features/proxy-routes/types.ts
+++ b/openflare_server/web/features/proxy-routes/types.ts
@@ -54,6 +54,7 @@ export interface ProxyRouteItem {
basic_auth_password: string;
remark: string;
upstream_type: 'direct' | 'tunnel';
+ tunnel_node_id?: number | null;
tunnel_id?: number | null;
tunnel_target_addr?: string;
tunnel_target_protocol?: string;
@@ -93,6 +94,7 @@ export interface ProxyRouteMutationPayload {
basic_auth_password?: string;
remark: string;
upstream_type?: 'direct' | 'tunnel';
+ tunnel_node_id?: number | null;
tunnel_id?: number | null;
tunnel_target_addr?: string;
tunnel_target_protocol?: string;
diff --git a/openflared/internal/frpc/manager.go b/openflared/internal/frpc/manager.go
index 6eaf190d..e5354b5e 100644
--- a/openflared/internal/frpc/manager.go
+++ b/openflared/internal/frpc/manager.go
@@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"log/slog"
+ "net"
"os"
"os/exec"
"path/filepath"
@@ -210,9 +211,17 @@ auth.token = "%s"
}
func parseAddr(addr string) (string, string) {
- parts := strings.Split(addr, ":")
- if len(parts) == 2 {
- return parts[0], parts[1]
+ addr = strings.TrimSpace(addr)
+ if addr == "" {
+ return "127.0.0.1", "7000"
+ }
+ host, port, err := net.SplitHostPort(addr)
+ if err == nil {
+ return strings.Trim(host, "[]"), port
+ }
+ lastColon := strings.LastIndex(addr, ":")
+ if lastColon > 0 && strings.Count(addr, ":") == 1 {
+ return addr[:lastColon], addr[lastColon+1:]
}
return addr, "7000"
}
|