mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-10-04 17:16:37 +08:00
fix: ensure tunnel protocol and KCP config are correctly processed and cleaned up
This commit is contained in:
@@ -825,7 +825,9 @@ func (h *Handler) tunnelUpdate(w http.ResponseWriter, r *http.Request) {
|
|||||||
defer func() { tx.Rollback() }()
|
defer func() { tx.Rollback() }()
|
||||||
|
|
||||||
updateProtocol := "tls"
|
updateProtocol := "tls"
|
||||||
if len(runtimeState.InNodes) > 0 && strings.TrimSpace(runtimeState.InNodes[0].Protocol) != "" {
|
if len(runtimeState.OutNodes) > 0 && strings.TrimSpace(runtimeState.OutNodes[0].Protocol) != "" {
|
||||||
|
updateProtocol = strings.TrimSpace(runtimeState.OutNodes[0].Protocol)
|
||||||
|
} else if len(runtimeState.InNodes) > 0 && strings.TrimSpace(runtimeState.InNodes[0].Protocol) != "" {
|
||||||
updateProtocol = strings.TrimSpace(runtimeState.InNodes[0].Protocol)
|
updateProtocol = strings.TrimSpace(runtimeState.InNodes[0].Protocol)
|
||||||
}
|
}
|
||||||
if err := h.repo.UpdateTunnelTx(
|
if err := h.repo.UpdateTunnelTx(
|
||||||
@@ -3405,14 +3407,22 @@ func (h *Handler) rollbackTunnelRuntime(chainNodeIDs, serviceNodeIDs []int64, tu
|
|||||||
protocol = "tls"
|
protocol = "tls"
|
||||||
}
|
}
|
||||||
seenServices := make(map[int64]struct{})
|
seenServices := make(map[int64]struct{})
|
||||||
serviceName := fmt.Sprintf("%d_%s", tunnelID, protocol)
|
serviceNames := []string{
|
||||||
|
fmt.Sprintf("%d_tls", tunnelID),
|
||||||
|
fmt.Sprintf("%d_kcp", tunnelID),
|
||||||
|
fmt.Sprintf("%d_wss", tunnelID),
|
||||||
|
fmt.Sprintf("%d_mtls", tunnelID),
|
||||||
|
fmt.Sprintf("%d_mwss", tunnelID),
|
||||||
|
fmt.Sprintf("%d_tcp", tunnelID),
|
||||||
|
fmt.Sprintf("%d_mtcp", tunnelID),
|
||||||
|
}
|
||||||
for i := len(serviceNodeIDs) - 1; i >= 0; i-- {
|
for i := len(serviceNodeIDs) - 1; i >= 0; i-- {
|
||||||
nodeID := serviceNodeIDs[i]
|
nodeID := serviceNodeIDs[i]
|
||||||
if _, ok := seenServices[nodeID]; ok {
|
if _, ok := seenServices[nodeID]; ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
seenServices[nodeID] = struct{}{}
|
seenServices[nodeID] = struct{}{}
|
||||||
_, _ = h.sendNodeCommand(nodeID, "DeleteService", map[string]interface{}{"services": []string{serviceName}}, false, true)
|
_, _ = h.sendNodeCommand(nodeID, "DeleteService", map[string]interface{}{"services": serviceNames}, false, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
seenChains := make(map[int64]struct{})
|
seenChains := make(map[int64]struct{})
|
||||||
|
|||||||
Executable
BIN
Binary file not shown.
@@ -105,6 +105,8 @@ func GetDuration(md metadata.Metadata, keys ...string) (v time.Duration) {
|
|||||||
switch vv := md.Get(key).(type) {
|
switch vv := md.Get(key).(type) {
|
||||||
case int:
|
case int:
|
||||||
v = time.Duration(vv) * time.Second
|
v = time.Duration(vv) * time.Second
|
||||||
|
case float64:
|
||||||
|
v = time.Duration(vv) * time.Second
|
||||||
case string:
|
case string:
|
||||||
v, _ = time.ParseDuration(vv)
|
v, _ = time.ParseDuration(vv)
|
||||||
if v == 0 {
|
if v == 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user