Release 0.28.0 (#2092)

* compile client under freebsd (#1620)

Compile netbird client under freebsd and now support netstack and userspace modes.
Refactoring linux specific code to share same code with FreeBSD, move to *_unix.go files.

Not implemented yet:

Kernel mode not supported
DNS probably does not work yet
Routing also probably does not work yet
SSH support did not tested yet
Lack of test environment for freebsd (dedicated VM for github runners under FreeBSD required)
Lack of tests for freebsd specific code
info reporting need to review and also implement, for example OS reported as GENERIC instead of FreeBSD (lack of FreeBSD icon in management interface)
Lack of proper client setup under FreeBSD
Lack of FreeBSD port/package

* Add DNS routes (#1943)

Given domains are resolved periodically and resolved IPs are replaced with the new ones. Unless the flag keep_route is set to true, then only new ones are added.
This option is helpful if there are long-running connections that might still point to old IP addresses from changed DNS records.

* Add process posture check (#1693)

Introduces a process posture check to validate the existence and active status of specific binaries on peer systems. The check ensures that files are present at specified paths, and that corresponding processes are running. This check supports Linux, Windows, and macOS systems.


Co-authored-by: Evgenii <mail@skillcoder.com>
Co-authored-by: Pascal Fischer <pascal@netbird.io>
Co-authored-by: Zoltan Papp <zoltan.pmail@gmail.com>
Co-authored-by: Viktor Liu <17948409+lixmal@users.noreply.github.com>
Co-authored-by: Bethuel Mmbaga <bethuelmbaga12@gmail.com>
This commit is contained in:
Maycon Santos
2024-06-13 13:24:24 +02:00
committed by GitHub
parent 95299be52d
commit 4fec709bb1
149 changed files with 6509 additions and 2710 deletions

View File

@@ -2,12 +2,9 @@ package route
import "strings"
type HAUniqueID string
const haSeparator = "|"
// GetHAUniqueID returns a highly available route ID by combining Network ID and Network range address
func GetHAUniqueID(input *Route) HAUniqueID {
return HAUniqueID(string(input.NetID) + "-" + input.Network.String())
}
type HAUniqueID string
func (id HAUniqueID) String() string {
return string(id)
@@ -15,7 +12,7 @@ func (id HAUniqueID) String() string {
// NetID returns the Network ID from the HAUniqueID
func (id HAUniqueID) NetID() NetID {
if i := strings.LastIndex(string(id), "-"); i != -1 {
if i := strings.LastIndex(string(id), haSeparator); i != -1 {
return NetID(id[:i])
}
return NetID(id)

View File

@@ -1,8 +1,13 @@
package route
import (
"fmt"
"net/netip"
"slices"
log "github.com/sirupsen/logrus"
"github.com/netbirdio/netbird/management/domain"
"github.com/netbirdio/netbird/management/server/status"
)
@@ -25,6 +30,8 @@ const (
IPv4NetworkString = "IPv4"
// IPv6NetworkString IPv6 network type string
IPv6NetworkString = "IPv6"
// DomainNetworkString domain network type string
DomainNetworkString = "Domain"
)
const (
@@ -34,6 +41,8 @@ const (
IPv4Network
// IPv6Network IPv6 network type
IPv6Network
// DomainNetwork domain network type
DomainNetwork
)
type ID string
@@ -52,6 +61,8 @@ func (p NetworkType) String() string {
return IPv4NetworkString
case IPv6Network:
return IPv6NetworkString
case DomainNetwork:
return DomainNetworkString
default:
return InvalidNetworkString
}
@@ -64,6 +75,8 @@ func ToPrefixType(prefix string) NetworkType {
return IPv4Network
case IPv6NetworkString:
return IPv6Network
case DomainNetworkString:
return DomainNetwork
default:
return InvalidNetwork
}
@@ -73,8 +86,11 @@ func ToPrefixType(prefix string) NetworkType {
type Route struct {
ID ID `gorm:"primaryKey"`
// AccountID is a reference to Account that this object belongs
AccountID string `gorm:"index"`
AccountID string `gorm:"index"`
// Network and Domains are mutually exclusive
Network netip.Prefix `gorm:"serializer:json"`
Domains domain.List `gorm:"serializer:json"`
KeepRoute bool
NetID NetID
Description string
Peer string
@@ -88,7 +104,7 @@ type Route struct {
// EventMeta returns activity event meta related to the route
func (r *Route) EventMeta() map[string]any {
return map[string]any{"name": r.NetID, "network_range": r.Network.String(), "peer_id": r.Peer, "peer_groups": r.PeerGroups}
return map[string]any{"name": r.NetID, "network_range": r.Network.String(), "domains": r.Domains.SafeString(), "peer_id": r.Peer, "peer_groups": r.PeerGroups}
}
// Copy copies a route object
@@ -98,16 +114,16 @@ func (r *Route) Copy() *Route {
Description: r.Description,
NetID: r.NetID,
Network: r.Network,
Domains: slices.Clone(r.Domains),
KeepRoute: r.KeepRoute,
NetworkType: r.NetworkType,
Peer: r.Peer,
PeerGroups: make([]string, len(r.PeerGroups)),
PeerGroups: slices.Clone(r.PeerGroups),
Metric: r.Metric,
Masquerade: r.Masquerade,
Enabled: r.Enabled,
Groups: make([]string, len(r.Groups)),
Groups: slices.Clone(r.Groups),
}
copy(route.Groups, r.Groups)
copy(route.PeerGroups, r.PeerGroups)
return route
}
@@ -123,13 +139,32 @@ func (r *Route) IsEqual(other *Route) bool {
other.Description == r.Description &&
other.NetID == r.NetID &&
other.Network == r.Network &&
slices.Equal(r.Domains, other.Domains) &&
other.KeepRoute == r.KeepRoute &&
other.NetworkType == r.NetworkType &&
other.Peer == r.Peer &&
other.Metric == r.Metric &&
other.Masquerade == r.Masquerade &&
other.Enabled == r.Enabled &&
compareList(r.Groups, other.Groups) &&
compareList(r.PeerGroups, other.PeerGroups)
slices.Equal(r.Groups, other.Groups) &&
slices.Equal(r.PeerGroups, other.PeerGroups)
}
// IsDynamic returns if the route is dynamic, i.e. has domains
func (r *Route) IsDynamic() bool {
return r.NetworkType == DomainNetwork
}
func (r *Route) GetHAUniqueID() HAUniqueID {
if r.IsDynamic() {
domains, err := r.Domains.String()
if err != nil {
log.Errorf("Failed to convert domains to string: %v", err)
domains = r.Domains.PunycodeString()
}
return HAUniqueID(fmt.Sprintf("%s%s%s", r.NetID, haSeparator, domains))
}
return HAUniqueID(fmt.Sprintf("%s%s%s", r.NetID, haSeparator, r.Network.String()))
}
// ParseNetwork Parses a network prefix string and returns a netip.Prefix object and if is invalid, IPv4 or IPv6
@@ -151,23 +186,3 @@ func ParseNetwork(networkString string) (NetworkType, netip.Prefix, error) {
return IPv4Network, masked, nil
}
func compareList(list, other []string) bool {
if len(list) != len(other) {
return false
}
for _, id := range list {
match := false
for _, otherID := range other {
if id == otherID {
match = true
break
}
}
if !match {
return false
}
}
return true
}