mirror of
https://github.com/netbirdio/netbird.git
synced 2025-06-26 12:42:32 +02:00
add support for skipping version checks for dev versions
Signed-off-by: bcmmbaga <bethuelmbaga12@gmail.com>
This commit is contained in:
parent
56f35628f4
commit
2d9767512d
@ -3,6 +3,7 @@ package posture
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/go-version"
|
"github.com/hashicorp/go-version"
|
||||||
@ -54,7 +55,11 @@ func (n *NBVersionCheck) Validate() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MeetsMinVersion checks if the peer's version meets or exceeds the minimum required version
|
// MeetsMinVersion checks if the peer's version meets or exceeds the minimum required version
|
||||||
func MeetsMinVersion(minVer, peerVer string) (bool, error) {
|
func MeetsMinVersion(minVer, peerVer string, skipVersionCheckFor ...string) (bool, error) {
|
||||||
|
if slices.Contains(skipVersionCheckFor, peerVer) {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
peerVer = sanitizeVersion(peerVer)
|
peerVer = sanitizeVersion(peerVer)
|
||||||
minVer = sanitizeVersion(minVer)
|
minVer = sanitizeVersion(minVer)
|
||||||
|
|
||||||
|
@ -41,6 +41,8 @@ const (
|
|||||||
firewallRuleMinPortRangesVer = "0.48.0"
|
firewallRuleMinPortRangesVer = "0.48.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var devVersions = []string{"dev"}
|
||||||
|
|
||||||
type LookupMap map[string]struct{}
|
type LookupMap map[string]struct{}
|
||||||
|
|
||||||
// AccountMeta is a struct that contains a stripped down version of the Account object.
|
// AccountMeta is a struct that contains a stripped down version of the Account object.
|
||||||
@ -1600,7 +1602,7 @@ func expandPortsAndRanges(base FirewallRule, rule *PolicyRule, peer *nbpeer.Peer
|
|||||||
|
|
||||||
var peerSupportsPortRanges bool
|
var peerSupportsPortRanges bool
|
||||||
|
|
||||||
meetMinVer, err := posture.MeetsMinVersion(firewallRuleMinPortRangesVer, peer.Meta.WtVersion)
|
meetMinVer, err := posture.MeetsMinVersion(firewallRuleMinPortRangesVer, peer.Meta.WtVersion, devVersions...)
|
||||||
if err == nil && meetMinVer {
|
if err == nil && meetMinVer {
|
||||||
peerSupportsPortRanges = true
|
peerSupportsPortRanges = true
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user