mirror of
https://github.com/kubenetworks/kubevpn.git
synced 2025-12-24 11:51:13 +08:00
hotfix: swap envoy rule header nil to last position (#662)
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -260,6 +261,17 @@ func addVirtualRule(v []*controlplane.Virtual, ns, nodeID string, port []control
|
||||
if v[index].Ports == nil {
|
||||
v[index].Ports = port
|
||||
}
|
||||
|
||||
// envoy rule have order, eg:
|
||||
// 1. null header to a
|
||||
// 2. foo=bar to b
|
||||
// then will never hit to b
|
||||
// so needs to let null header to last rule
|
||||
for x := range v {
|
||||
sort.SliceStable(v[x].Rules, func(i, j int) bool {
|
||||
return len(v[x].Rules[i].Headers) != 0
|
||||
})
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user