mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-10-06 10:06:36 +08:00
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.
This commit is contained in:
@@ -780,9 +780,6 @@ func (h *Handler) federationTunnelCreate(w http.ResponseWriter, r *http.Request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
tunnelType := 1
|
tunnelType := 1
|
||||||
if strings.ToLower(req.Protocol) == "udp" {
|
|
||||||
tunnelType = 2
|
|
||||||
}
|
|
||||||
|
|
||||||
tx, err := h.repo.DB().Begin()
|
tx, err := h.repo.DB().Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -569,12 +569,10 @@ func (h *Handler) tunnelCreate(w http.ResponseWriter, r *http.Request) {
|
|||||||
runtimeState.TunnelID = tunnelID
|
runtimeState.TunnelID = tunnelID
|
||||||
var federationBindings []sqlite.FederationTunnelBinding
|
var federationBindings []sqlite.FederationTunnelBinding
|
||||||
var federationReleaseRefs []federationRuntimeReleaseRef
|
var federationReleaseRefs []federationRuntimeReleaseRef
|
||||||
if typeVal == 2 {
|
federationBindings, federationReleaseRefs, err = h.applyFederationRuntime(runtimeState)
|
||||||
federationBindings, federationReleaseRefs, err = h.applyFederationRuntime(runtimeState)
|
if err != nil {
|
||||||
if err != nil {
|
response.WriteJSON(w, response.ErrDefault(err.Error()))
|
||||||
response.WriteJSON(w, response.ErrDefault(err.Error()))
|
return
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
applyTunnelPortsToRequest(req, runtimeState)
|
applyTunnelPortsToRequest(req, runtimeState)
|
||||||
if err := replaceTunnelChainsTx(tx, tunnelID, req); err != nil {
|
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 federationBindings []sqlite.FederationTunnelBinding
|
||||||
var federationReleaseRefs []federationRuntimeReleaseRef
|
var federationReleaseRefs []federationRuntimeReleaseRef
|
||||||
if typeVal == 2 {
|
federationBindings, federationReleaseRefs, err = h.applyFederationRuntime(runtimeState)
|
||||||
federationBindings, federationReleaseRefs, err = h.applyFederationRuntime(runtimeState)
|
if err != nil {
|
||||||
if err != nil {
|
response.WriteJSON(w, response.ErrDefault(err.Error()))
|
||||||
response.WriteJSON(w, response.ErrDefault(err.Error()))
|
return
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
applyTunnelPortsToRequest(req, runtimeState)
|
applyTunnelPortsToRequest(req, runtimeState)
|
||||||
|
|
||||||
@@ -2340,7 +2336,7 @@ func (h *Handler) federationLocalDomain() string {
|
|||||||
func (h *Handler) applyFederationRuntime(state *tunnelCreateState) ([]sqlite.FederationTunnelBinding, []federationRuntimeReleaseRef, error) {
|
func (h *Handler) applyFederationRuntime(state *tunnelCreateState) ([]sqlite.FederationTunnelBinding, []federationRuntimeReleaseRef, error) {
|
||||||
bindings := make([]sqlite.FederationTunnelBinding, 0)
|
bindings := make([]sqlite.FederationTunnelBinding, 0)
|
||||||
releaseRefs := make([]federationRuntimeReleaseRef, 0)
|
releaseRefs := make([]federationRuntimeReleaseRef, 0)
|
||||||
if h == nil || state == nil || state.Type != 2 {
|
if h == nil || state == nil {
|
||||||
return bindings, releaseRefs, nil
|
return bindings, releaseRefs, nil
|
||||||
}
|
}
|
||||||
fc := client.NewFederationClient()
|
fc := client.NewFederationClient()
|
||||||
|
|||||||
Reference in New Issue
Block a user