From 8dc31383e0abf0b0171cec626fee2f3af0a2a2e4 Mon Sep 17 00:00:00 2001 From: sagit <36596628+Sagit-chu@users.noreply.github.com> Date: Sun, 15 Feb 2026 12:12:54 +0800 Subject: [PATCH] fix(backend): correct federation port forwarding tunnel type handling (#123) - Fix Type 1 (port forwarding) tunnels to call applyFederationRuntime Previously only Type 2 tunnels applied federation runtime, causing port forwarding tunnels to not be properly configured in federation mode - Remove incorrect UDP tunnel type override in federationTunnelCreate UDP tunnels were being incorrectly set to Type 2, which conflicted with the federation runtime logic that expects Type 1 for port forwarding These fixes ensure all tunnel types are properly handled in federation mode with correct runtime configuration applied. --- .../internal/http/handler/federation.go | 3 --- go-backend/internal/http/handler/mutations.go | 22 ++++++++----------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/go-backend/internal/http/handler/federation.go b/go-backend/internal/http/handler/federation.go index 402a00f..90c5cd9 100644 --- a/go-backend/internal/http/handler/federation.go +++ b/go-backend/internal/http/handler/federation.go @@ -780,9 +780,6 @@ func (h *Handler) federationTunnelCreate(w http.ResponseWriter, r *http.Request) } tunnelType := 1 - if strings.ToLower(req.Protocol) == "udp" { - tunnelType = 2 - } tx, err := h.repo.DB().Begin() if err != nil { diff --git a/go-backend/internal/http/handler/mutations.go b/go-backend/internal/http/handler/mutations.go index a1f4f80..ba1d683 100644 --- a/go-backend/internal/http/handler/mutations.go +++ b/go-backend/internal/http/handler/mutations.go @@ -569,12 +569,10 @@ func (h *Handler) tunnelCreate(w http.ResponseWriter, r *http.Request) { runtimeState.TunnelID = tunnelID var federationBindings []sqlite.FederationTunnelBinding var federationReleaseRefs []federationRuntimeReleaseRef - if typeVal == 2 { - federationBindings, federationReleaseRefs, err = h.applyFederationRuntime(runtimeState) - if err != nil { - response.WriteJSON(w, response.ErrDefault(err.Error())) - return - } + federationBindings, federationReleaseRefs, err = h.applyFederationRuntime(runtimeState) + if err != nil { + response.WriteJSON(w, response.ErrDefault(err.Error())) + return } applyTunnelPortsToRequest(req, runtimeState) if err := replaceTunnelChainsTx(tx, tunnelID, req); err != nil { @@ -693,12 +691,10 @@ func (h *Handler) tunnelUpdate(w http.ResponseWriter, r *http.Request) { var federationBindings []sqlite.FederationTunnelBinding var federationReleaseRefs []federationRuntimeReleaseRef - if typeVal == 2 { - federationBindings, federationReleaseRefs, err = h.applyFederationRuntime(runtimeState) - if err != nil { - response.WriteJSON(w, response.ErrDefault(err.Error())) - return - } + federationBindings, federationReleaseRefs, err = h.applyFederationRuntime(runtimeState) + if err != nil { + response.WriteJSON(w, response.ErrDefault(err.Error())) + return } applyTunnelPortsToRequest(req, runtimeState) @@ -2340,7 +2336,7 @@ func (h *Handler) federationLocalDomain() string { func (h *Handler) applyFederationRuntime(state *tunnelCreateState) ([]sqlite.FederationTunnelBinding, []federationRuntimeReleaseRef, error) { bindings := make([]sqlite.FederationTunnelBinding, 0) releaseRefs := make([]federationRuntimeReleaseRef, 0) - if h == nil || state == nil || state.Type != 2 { + if h == nil || state == nil { return bindings, releaseRefs, nil } fc := client.NewFederationClient()