From 06325cead9794909120e9658b87e9450c258dae5 Mon Sep 17 00:00:00 2001 From: Zoltan Papp Date: Fri, 9 Feb 2024 15:19:02 +0100 Subject: [PATCH 01/18] Add dummy integration --- additions/peer_validation.go | 5 ----- integrations/validator.go | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 integrations/validator.go diff --git a/additions/peer_validation.go b/additions/peer_validation.go index e862d8f..7661386 100644 --- a/additions/peer_validation.go +++ b/additions/peer_validation.go @@ -1,7 +1,6 @@ package additions import ( - "github.com/netbirdio/netbird/management/server/account" "github.com/netbirdio/netbird/management/server/activity" nbpeer "github.com/netbirdio/netbird/management/server/peer" ) @@ -13,7 +12,3 @@ func ValidatePeersUpdateRequest(update *nbpeer.Peer, peer *nbpeer.Peer, userID s func ValidatePeers(peers []*nbpeer.Peer) []*nbpeer.Peer { return peers } - -func PreparePeer(peer *nbpeer.Peer, extraSettings *account.ExtraSettings) *nbpeer.Peer { - return peer.Copy() -} diff --git a/integrations/validator.go b/integrations/validator.go new file mode 100644 index 0000000..d0a2470 --- /dev/null +++ b/integrations/validator.go @@ -0,0 +1,21 @@ +package integrations + +import ( + "github.com/netbirdio/netbird/management/server/account" + nbpeer "github.com/netbirdio/netbird/management/server/peer" +) + +type IntegratedValidatorImpl struct { +} + +func NewIntegratedValidator() *IntegratedValidatorImpl { + return &IntegratedValidatorImpl{} +} + +func (v *IntegratedValidatorImpl) PreparePeer(peer *nbpeer.Peer, _ *account.ExtraSettings, _ []string) *nbpeer.Peer { + return peer.Copy() +} + +func (v *IntegratedValidatorImpl) ValidatePeer(*nbpeer.Peer, []string) (bool, error) { + return true, nil +} From 24075f45a9b28c1abecac5859b47f3c3cf3717f6 Mon Sep 17 00:00:00 2001 From: Zoltan Papp Date: Wed, 14 Feb 2024 11:03:57 +0100 Subject: [PATCH 02/18] Rename --- integrations/approval.go | 21 +++++++++++++++++++++ integrations/validator.go | 21 --------------------- 2 files changed, 21 insertions(+), 21 deletions(-) create mode 100644 integrations/approval.go delete mode 100644 integrations/validator.go diff --git a/integrations/approval.go b/integrations/approval.go new file mode 100644 index 0000000..2bce16a --- /dev/null +++ b/integrations/approval.go @@ -0,0 +1,21 @@ +package integrations + +import ( + "github.com/netbirdio/netbird/management/server/account" + nbpeer "github.com/netbirdio/netbird/management/server/peer" +) + +type IntegratedApprovalImpl struct { +} + +func NewIntegratedApproval() *IntegratedApprovalImpl { + return &IntegratedApprovalImpl{} +} + +func (v *IntegratedApprovalImpl) PreparePeer(peer *nbpeer.Peer, _ *account.ExtraSettings, _ []string) *nbpeer.Peer { + return peer.Copy() +} + +func (v *IntegratedApprovalImpl) ValidatePeer(*nbpeer.Peer, []string) (bool, error) { + return true, nil +} diff --git a/integrations/validator.go b/integrations/validator.go deleted file mode 100644 index d0a2470..0000000 --- a/integrations/validator.go +++ /dev/null @@ -1,21 +0,0 @@ -package integrations - -import ( - "github.com/netbirdio/netbird/management/server/account" - nbpeer "github.com/netbirdio/netbird/management/server/peer" -) - -type IntegratedValidatorImpl struct { -} - -func NewIntegratedValidator() *IntegratedValidatorImpl { - return &IntegratedValidatorImpl{} -} - -func (v *IntegratedValidatorImpl) PreparePeer(peer *nbpeer.Peer, _ *account.ExtraSettings, _ []string) *nbpeer.Peer { - return peer.Copy() -} - -func (v *IntegratedValidatorImpl) ValidatePeer(*nbpeer.Peer, []string) (bool, error) { - return true, nil -} From 13cebc2c6f33efb50ead9d38c136c51c701e1ba6 Mon Sep 17 00:00:00 2001 From: Zoltan Papp Date: Wed, 14 Feb 2024 11:20:22 +0100 Subject: [PATCH 03/18] Remove unused argument --- integrations/approval.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integrations/approval.go b/integrations/approval.go index 2bce16a..454089b 100644 --- a/integrations/approval.go +++ b/integrations/approval.go @@ -12,7 +12,7 @@ func NewIntegratedApproval() *IntegratedApprovalImpl { return &IntegratedApprovalImpl{} } -func (v *IntegratedApprovalImpl) PreparePeer(peer *nbpeer.Peer, _ *account.ExtraSettings, _ []string) *nbpeer.Peer { +func (v *IntegratedApprovalImpl) PreparePeer(peer *nbpeer.Peer, _ *account.ExtraSettings) *nbpeer.Peer { return peer.Copy() } From cbd053ca41cc6f1282a7c752db0b9caa2438baad Mon Sep 17 00:00:00 2001 From: Zoltan Papp Date: Wed, 14 Feb 2024 11:32:16 +0100 Subject: [PATCH 04/18] Remove unused argument --- integrations/approval.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integrations/approval.go b/integrations/approval.go index 454089b..b274054 100644 --- a/integrations/approval.go +++ b/integrations/approval.go @@ -16,6 +16,6 @@ func (v *IntegratedApprovalImpl) PreparePeer(peer *nbpeer.Peer, _ *account.Extra return peer.Copy() } -func (v *IntegratedApprovalImpl) ValidatePeer(*nbpeer.Peer, []string) (bool, error) { +func (v *IntegratedApprovalImpl) ValidatePeer(*nbpeer.Peer) (bool, error) { return true, nil } From b95cf1cd2685846b99f3b0fbd86eefd3269f2355 Mon Sep 17 00:00:00 2001 From: Zoltan Papp Date: Fri, 16 Feb 2024 08:37:00 +0100 Subject: [PATCH 05/18] Change arguments --- integrations/approval.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integrations/approval.go b/integrations/approval.go index b274054..e092cc4 100644 --- a/integrations/approval.go +++ b/integrations/approval.go @@ -12,10 +12,10 @@ func NewIntegratedApproval() *IntegratedApprovalImpl { return &IntegratedApprovalImpl{} } -func (v *IntegratedApprovalImpl) PreparePeer(peer *nbpeer.Peer, _ *account.ExtraSettings) *nbpeer.Peer { +func (v *IntegratedApprovalImpl) PreparePeer(_ string, peer *nbpeer.Peer, _ []string, _ *account.ExtraSettings) *nbpeer.Peer { return peer.Copy() } -func (v *IntegratedApprovalImpl) ValidatePeer(*nbpeer.Peer) (bool, error) { +func (v *IntegratedApprovalImpl) ValidatePeer(string, *nbpeer.Peer, []string, []string) (bool, error) { return true, nil } From a1c786c89b705744cf9b2169afb33d7fcb98ea2e Mon Sep 17 00:00:00 2001 From: Zoltan Papp Date: Mon, 26 Feb 2024 16:13:59 +0100 Subject: [PATCH 06/18] Rename ValidatePeer to SyncPeer --- integrations/approval.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integrations/approval.go b/integrations/approval.go index e092cc4..5b5f1f6 100644 --- a/integrations/approval.go +++ b/integrations/approval.go @@ -16,6 +16,6 @@ func (v *IntegratedApprovalImpl) PreparePeer(_ string, peer *nbpeer.Peer, _ []st return peer.Copy() } -func (v *IntegratedApprovalImpl) ValidatePeer(string, *nbpeer.Peer, []string, []string) (bool, error) { +func (v *IntegratedApprovalImpl) SyncPeer(string, *nbpeer.Peer, []string, *account.ExtraSettings) (bool, error) { return true, nil } From 2e4fe2407450a6a7eddd665ade740c2c21806920 Mon Sep 17 00:00:00 2001 From: Zoltan Papp Date: Mon, 26 Feb 2024 16:18:41 +0100 Subject: [PATCH 07/18] Fix return params of SyncPeer --- integrations/approval.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integrations/approval.go b/integrations/approval.go index 5b5f1f6..584e58e 100644 --- a/integrations/approval.go +++ b/integrations/approval.go @@ -16,6 +16,6 @@ func (v *IntegratedApprovalImpl) PreparePeer(_ string, peer *nbpeer.Peer, _ []st return peer.Copy() } -func (v *IntegratedApprovalImpl) SyncPeer(string, *nbpeer.Peer, []string, *account.ExtraSettings) (bool, error) { - return true, nil +func (v *IntegratedApprovalImpl) SyncPeer(accountID string, peer *nbpeer.Peer, peersGroup []string, extraSettings *account.ExtraSettings) (*nbpeer.Peer, bool) { + return peer.Copy(), false } From fe3dfb0d002ecb7821b52e6b7b83eebc393d9eed Mon Sep 17 00:00:00 2001 From: Zoltan Papp Date: Thu, 29 Feb 2024 13:55:13 +0100 Subject: [PATCH 08/18] Add error as return parameter --- integrations/approval.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integrations/approval.go b/integrations/approval.go index 584e58e..e63eb8e 100644 --- a/integrations/approval.go +++ b/integrations/approval.go @@ -8,8 +8,8 @@ import ( type IntegratedApprovalImpl struct { } -func NewIntegratedApproval() *IntegratedApprovalImpl { - return &IntegratedApprovalImpl{} +func NewIntegratedApproval() (*IntegratedApprovalImpl, error) { + return &IntegratedApprovalImpl{}, nil } func (v *IntegratedApprovalImpl) PreparePeer(_ string, peer *nbpeer.Peer, _ []string, _ *account.ExtraSettings) *nbpeer.Peer { From 042e651aadc18c25aed7d730b90ec3b09bd2c5f8 Mon Sep 17 00:00:00 2001 From: Zoltan Papp Date: Mon, 4 Mar 2024 12:23:37 +0100 Subject: [PATCH 09/18] Followup interface changes --- integrations/approval.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integrations/approval.go b/integrations/approval.go index e63eb8e..0aa48ac 100644 --- a/integrations/approval.go +++ b/integrations/approval.go @@ -16,6 +16,6 @@ func (v *IntegratedApprovalImpl) PreparePeer(_ string, peer *nbpeer.Peer, _ []st return peer.Copy() } -func (v *IntegratedApprovalImpl) SyncPeer(accountID string, peer *nbpeer.Peer, peersGroup []string, extraSettings *account.ExtraSettings) (*nbpeer.Peer, bool) { - return peer.Copy(), false +func (v *IntegratedApprovalImpl) IsRequiresApproval(accountID string, peer *nbpeer.Peer, peersGroup []string, extraSettings *account.ExtraSettings) bool { + return false } From e576f907ddea9e065b57fd7f951c99a881c0daa8 Mon Sep 17 00:00:00 2001 From: Zoltan Papp Date: Mon, 4 Mar 2024 12:55:01 +0100 Subject: [PATCH 10/18] Add Stop method for integrated approval --- integrations/approval.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/integrations/approval.go b/integrations/approval.go index 0aa48ac..894410f 100644 --- a/integrations/approval.go +++ b/integrations/approval.go @@ -19,3 +19,6 @@ func (v *IntegratedApprovalImpl) PreparePeer(_ string, peer *nbpeer.Peer, _ []st func (v *IntegratedApprovalImpl) IsRequiresApproval(accountID string, peer *nbpeer.Peer, peersGroup []string, extraSettings *account.ExtraSettings) bool { return false } + +func (v *IntegratedApprovalImpl) Stop() { +} From 469a80446ac73189862c2417ca56ccc884a64b56 Mon Sep 17 00:00:00 2001 From: Zoltan Papp Date: Tue, 5 Mar 2024 14:05:59 +0100 Subject: [PATCH 11/18] Add event store for IntegratedApproval --- integrations/approval.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/integrations/approval.go b/integrations/approval.go index 894410f..0227c3a 100644 --- a/integrations/approval.go +++ b/integrations/approval.go @@ -2,13 +2,14 @@ package integrations import ( "github.com/netbirdio/netbird/management/server/account" + "github.com/netbirdio/netbird/management/server/activity" nbpeer "github.com/netbirdio/netbird/management/server/peer" ) type IntegratedApprovalImpl struct { } -func NewIntegratedApproval() (*IntegratedApprovalImpl, error) { +func NewIntegratedApproval(activity.Store) (*IntegratedApprovalImpl, error) { return &IntegratedApprovalImpl{}, nil } From 78fc48320b29530732031633ea9e76713a360284 Mon Sep 17 00:00:00 2001 From: Zoltan Papp Date: Wed, 13 Mar 2024 12:55:01 +0100 Subject: [PATCH 12/18] Update integrated peer approval Delete unused package --- additions/go.mod | 5 ----- additions/go.sum | 2 -- additions/peer_validation.go | 14 -------------- additions/settings_validation.go | 21 --------------------- integrations/approval.go | 18 +++++++++++++++++- 5 files changed, 17 insertions(+), 43 deletions(-) delete mode 100644 additions/go.mod delete mode 100644 additions/go.sum delete mode 100644 additions/peer_validation.go delete mode 100644 additions/settings_validation.go diff --git a/additions/go.mod b/additions/go.mod deleted file mode 100644 index 10b2351..0000000 --- a/additions/go.mod +++ /dev/null @@ -1,5 +0,0 @@ -module github.com/netbirdio/management-integrations/additions - -go 1.20 - -require github.com/netbirdio/netbird v0.24.3-0.20231128133457-bab420ca7798 diff --git a/additions/go.sum b/additions/go.sum deleted file mode 100644 index d27173e..0000000 --- a/additions/go.sum +++ /dev/null @@ -1,2 +0,0 @@ -github.com/netbirdio/netbird v0.24.3-0.20231128133457-bab420ca7798 h1:k0FvU2kxsZC/rikDD2JdC5CjuX5s09wUue6xq87f/AE= -github.com/netbirdio/netbird v0.24.3-0.20231128133457-bab420ca7798/go.mod h1:5TrGRLGrGQZDEsGLQVR5KW8T82atu6J2WvOJcxQmtmE= diff --git a/additions/peer_validation.go b/additions/peer_validation.go deleted file mode 100644 index 7661386..0000000 --- a/additions/peer_validation.go +++ /dev/null @@ -1,14 +0,0 @@ -package additions - -import ( - "github.com/netbirdio/netbird/management/server/activity" - nbpeer "github.com/netbirdio/netbird/management/server/peer" -) - -func ValidatePeersUpdateRequest(update *nbpeer.Peer, peer *nbpeer.Peer, userID string, accountID string, eventStore activity.Store, dnsDomain string) (*nbpeer.Peer, error) { - return update, nil -} - -func ValidatePeers(peers []*nbpeer.Peer) []*nbpeer.Peer { - return peers -} diff --git a/additions/settings_validation.go b/additions/settings_validation.go deleted file mode 100644 index f020480..0000000 --- a/additions/settings_validation.go +++ /dev/null @@ -1,21 +0,0 @@ -package additions - -import ( - "github.com/netbirdio/netbird/management/server/account" - "github.com/netbirdio/netbird/management/server/activity" - nbpeer "github.com/netbirdio/netbird/management/server/peer" - log "github.com/sirupsen/logrus" -) - -func ValidateExtraSettings(newExtraSettings *account.ExtraSettings, oldExtraSettings *account.ExtraSettings, peers map[string]*nbpeer.Peer, userID string, accountID string, eventStore activity.Store) error { - if newExtraSettings != nil { - if oldExtraSettings == nil { - log.Info("extra settings are only supported on the cloud version of NetBird") - } - if newExtraSettings.PeerApprovalEnabled { - log.Info("setting peer approval to false") - newExtraSettings.PeerApprovalEnabled = false - } - } - return nil -} diff --git a/integrations/approval.go b/integrations/approval.go index 0227c3a..0d66df5 100644 --- a/integrations/approval.go +++ b/integrations/approval.go @@ -13,13 +13,29 @@ func NewIntegratedApproval(activity.Store) (*IntegratedApprovalImpl, error) { return &IntegratedApprovalImpl{}, nil } +func (v *IntegratedApprovalImpl) UpdatePeerApprovalSetting(*account.ExtraSettings, *account.ExtraSettings, map[string]*nbpeer.Peer, string, string) error { + return nil +} + +func (v *IntegratedApprovalImpl) ApprovePeer(update *nbpeer.Peer, _ *nbpeer.Peer, _ string, _ string, _ string, _ []string, _ *account.ExtraSettings) (*nbpeer.Peer, error) { + return update, nil +} + func (v *IntegratedApprovalImpl) PreparePeer(_ string, peer *nbpeer.Peer, _ []string, _ *account.ExtraSettings) *nbpeer.Peer { return peer.Copy() } -func (v *IntegratedApprovalImpl) IsRequiresApproval(accountID string, peer *nbpeer.Peer, peersGroup []string, extraSettings *account.ExtraSettings) bool { +func (v *IntegratedApprovalImpl) IsRequiresApproval(_ string, _ *nbpeer.Peer, _ []string, _ *account.ExtraSettings) bool { return false } +func (v *IntegratedApprovalImpl) GetApprovedPeers(_ string, peers map[string]*nbpeer.Peer, _ *account.ExtraSettings) (map[string]struct{}, error) { + approvedPeers := make(map[string]struct{}) + for p := range peers { + approvedPeers[p] = struct{}{} + } + return approvedPeers, nil +} + func (v *IntegratedApprovalImpl) Stop() { } From 729b7fabb29806dbd159316944f52d612384d407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Papp?= Date: Wed, 13 Mar 2024 17:04:23 +0100 Subject: [PATCH 13/18] Rename --- integrations/approval.go | 41 --------------------------------------- integrations/validator.go | 41 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 41 deletions(-) delete mode 100644 integrations/approval.go create mode 100644 integrations/validator.go diff --git a/integrations/approval.go b/integrations/approval.go deleted file mode 100644 index 0d66df5..0000000 --- a/integrations/approval.go +++ /dev/null @@ -1,41 +0,0 @@ -package integrations - -import ( - "github.com/netbirdio/netbird/management/server/account" - "github.com/netbirdio/netbird/management/server/activity" - nbpeer "github.com/netbirdio/netbird/management/server/peer" -) - -type IntegratedApprovalImpl struct { -} - -func NewIntegratedApproval(activity.Store) (*IntegratedApprovalImpl, error) { - return &IntegratedApprovalImpl{}, nil -} - -func (v *IntegratedApprovalImpl) UpdatePeerApprovalSetting(*account.ExtraSettings, *account.ExtraSettings, map[string]*nbpeer.Peer, string, string) error { - return nil -} - -func (v *IntegratedApprovalImpl) ApprovePeer(update *nbpeer.Peer, _ *nbpeer.Peer, _ string, _ string, _ string, _ []string, _ *account.ExtraSettings) (*nbpeer.Peer, error) { - return update, nil -} - -func (v *IntegratedApprovalImpl) PreparePeer(_ string, peer *nbpeer.Peer, _ []string, _ *account.ExtraSettings) *nbpeer.Peer { - return peer.Copy() -} - -func (v *IntegratedApprovalImpl) IsRequiresApproval(_ string, _ *nbpeer.Peer, _ []string, _ *account.ExtraSettings) bool { - return false -} - -func (v *IntegratedApprovalImpl) GetApprovedPeers(_ string, peers map[string]*nbpeer.Peer, _ *account.ExtraSettings) (map[string]struct{}, error) { - approvedPeers := make(map[string]struct{}) - for p := range peers { - approvedPeers[p] = struct{}{} - } - return approvedPeers, nil -} - -func (v *IntegratedApprovalImpl) Stop() { -} diff --git a/integrations/validator.go b/integrations/validator.go new file mode 100644 index 0000000..822f6c6 --- /dev/null +++ b/integrations/validator.go @@ -0,0 +1,41 @@ +package integrations + +import ( + "github.com/netbirdio/netbird/management/server/account" + "github.com/netbirdio/netbird/management/server/activity" + nbpeer "github.com/netbirdio/netbird/management/server/peer" +) + +type IntegratedValidatorImpl struct { +} + +func NewIntegratedValidator(activity.Store) (*IntegratedValidatorImpl, error) { + return &IntegratedValidatorImpl{}, nil +} + +func (v *IntegratedValidatorImpl) ValidateExtraSettings(*account.ExtraSettings, *account.ExtraSettings, map[string]*nbpeer.Peer, string, string) error { + return nil +} + +func (v *IntegratedValidatorImpl) ValidatePeer(update *nbpeer.Peer, _ *nbpeer.Peer, _ string, _ string, _ string, _ []string, _ *account.ExtraSettings) (*nbpeer.Peer, error) { + return update, nil +} + +func (v *IntegratedValidatorImpl) PreparePeer(_ string, peer *nbpeer.Peer, _ []string, _ *account.ExtraSettings) *nbpeer.Peer { + return peer.Copy() +} + +func (v *IntegratedValidatorImpl) IsNotValidPeer(_ string, _ *nbpeer.Peer, _ []string, _ *account.ExtraSettings) bool { + return false +} + +func (v *IntegratedValidatorImpl) GetValidatedPeers(_ string, peers map[string]*nbpeer.Peer, _ *account.ExtraSettings) (map[string]struct{}, error) { + validatedPeers := make(map[string]struct{}) + for p := range peers { + validatedPeers[p] = struct{}{} + } + return validatedPeers, nil +} + +func (v *IntegratedValidatorImpl) Stop() { +} From 6edc7afcb8819439a1d1d538f82f9f86912cf329 Mon Sep 17 00:00:00 2001 From: Zoltan Papp Date: Wed, 20 Mar 2024 01:13:30 +0100 Subject: [PATCH 14/18] Extend the params with groupsOfPeers --- integrations/validator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integrations/validator.go b/integrations/validator.go index 822f6c6..d699603 100644 --- a/integrations/validator.go +++ b/integrations/validator.go @@ -29,7 +29,7 @@ func (v *IntegratedValidatorImpl) IsNotValidPeer(_ string, _ *nbpeer.Peer, _ []s return false } -func (v *IntegratedValidatorImpl) GetValidatedPeers(_ string, peers map[string]*nbpeer.Peer, _ *account.ExtraSettings) (map[string]struct{}, error) { +func (v *IntegratedValidatorImpl) GetValidatedPeers(_ string, _ map[string][]string, peers map[string]*nbpeer.Peer, _ *account.ExtraSettings) (map[string]struct{}, error) { validatedPeers := make(map[string]struct{}) for p := range peers { validatedPeers[p] = struct{}{} From 258ecd390e1290ef34e564bf2f80a43b751bdf30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Papp?= Date: Wed, 20 Mar 2024 13:44:57 +0100 Subject: [PATCH 15/18] Update IntegratedValidator default implementation --- integrations/go.mod | 22 +++++++++++----------- integrations/go.sum | 12 ++++++++++++ integrations/validator.go | 3 ++- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/integrations/go.mod b/integrations/go.mod index 96df006..ab8de4b 100644 --- a/integrations/go.mod +++ b/integrations/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/gorilla/mux v1.8.0 - github.com/netbirdio/netbird v0.24.4-0.20231205111114-3f8b500f0ba6 + github.com/netbirdio/netbird v0.26.4-0.20240320121139-fe64847a748c ) require ( @@ -27,7 +27,7 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/s2a-go v0.1.4 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect github.com/googleapis/gax-go/v2 v2.10.0 // indirect github.com/hashicorp/go-secure-stdlib/base62 v0.1.2 // indirect @@ -53,23 +53,23 @@ require ( go.opentelemetry.io/otel/sdk/metric v0.33.0 // indirect go.opentelemetry.io/otel/trace v1.11.1 // indirect goauthentik.io/api/v3 v3.2023051.3 // indirect - golang.org/x/crypto v0.14.0 // indirect - golang.org/x/exp v0.0.0-20220518171630-0b5c67f07fdf // indirect - golang.org/x/net v0.17.0 // indirect + golang.org/x/crypto v0.18.0 // indirect + golang.org/x/exp v0.0.0-20230725093048-515e97ebf090 // indirect + golang.org/x/net v0.20.0 // indirect golang.org/x/oauth2 v0.8.0 // indirect - golang.org/x/sync v0.2.0 // indirect - golang.org/x/sys v0.13.0 // indirect - golang.org/x/text v0.13.0 // indirect - golang.zx2c4.com/wireguard/wgctrl v0.0.0-20211215182854-7a385b3431de // indirect + golang.org/x/sync v0.3.0 // indirect + golang.org/x/sys v0.16.0 // indirect + golang.org/x/text v0.14.0 // indirect + golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6 // indirect golang.zx2c4.com/wireguard/windows v0.5.3 // indirect google.golang.org/api v0.126.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect google.golang.org/grpc v1.56.3 // indirect - google.golang.org/protobuf v1.30.0 // indirect + google.golang.org/protobuf v1.31.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/apimachinery v0.23.5 // indirect + k8s.io/apimachinery v0.23.16 // indirect ) diff --git a/integrations/go.sum b/integrations/go.sum index e470dcd..672f6b8 100644 --- a/integrations/go.sum +++ b/integrations/go.sum @@ -226,6 +226,7 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.2.3 h1:yk9/cqRKtT9wXZSsRH9aurXEpJX+U6FLtpYTdC3R06k= github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= @@ -339,6 +340,8 @@ github.com/netbirdio/netbird v0.24.3 h1:hs6LSVD7ieL40pEGMwZ+/0rhnDbcQH3IC134gnAq github.com/netbirdio/netbird v0.24.3/go.mod h1:7/o3WIP8LSUh4MWRQhm/XB8T78BKi0wG1/RRkh83vHg= github.com/netbirdio/netbird v0.24.4-0.20231205111114-3f8b500f0ba6 h1:aa3d+u6+xtAAv4aZStX/3JwhS42LNOWn9TkyXnYMq8w= github.com/netbirdio/netbird v0.24.4-0.20231205111114-3f8b500f0ba6/go.mod h1:5DLzeGKGwMVvvL7LMXYzdsDW+s2fzUFvlcvEyiFrZJE= +github.com/netbirdio/netbird v0.26.4-0.20240320121139-fe64847a748c h1:eqP3n1PN8kP+Ko1kM+1iqJN8WirEFtENh8+9n4M2Dmk= +github.com/netbirdio/netbird v0.26.4-0.20240320121139-fe64847a748c/go.mod h1:xC0DkmwLsDQRZ0X8tcFlQqbTXOkk2iVF0mIUKvm4Vsc= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= @@ -467,6 +470,7 @@ golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -479,6 +483,7 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20220518171630-0b5c67f07fdf h1:oXVg4h2qJDd9htKxb5SCpFBHLipW6hXmL3qpUixS2jw= golang.org/x/exp v0.0.0-20220518171630-0b5c67f07fdf/go.mod h1:yh0Ynu2b5ZUe3MQfp2nM0ecK7wsgouWTDN0FNeJuIys= +golang.org/x/exp v0.0.0-20230725093048-515e97ebf090/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -563,6 +568,7 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -587,6 +593,7 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -666,6 +673,7 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= @@ -684,6 +692,7 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -747,6 +756,7 @@ golang.zx2c4.com/wintun v0.0.0-20211104114900-415007cec224/go.mod h1:deeaetjYA+D golang.zx2c4.com/wireguard v0.0.0-20211129173154-2dd424e2d808/go.mod h1:TjUWrnD5ATh7bFvmm/ALEJZQ4ivKbETb6pmyj1vUoNI= golang.zx2c4.com/wireguard/wgctrl v0.0.0-20211215182854-7a385b3431de h1:qDZ+lyO5jC9RNJ7ANJA0GWXk3pSn0Fu5SlcAIlgw+6w= golang.zx2c4.com/wireguard/wgctrl v0.0.0-20211215182854-7a385b3431de/go.mod h1:Q2XNgour4QSkFj0BWCkVlW0HWJwQgNMsMahpSlI0Eno= +golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6/go.mod h1:3rxYc4HtVcSG9gVaTs2GEBdehh+sYPOwKtyUWEOTb80= golang.zx2c4.com/wireguard/windows v0.5.3 h1:On6j2Rpn3OEMXqBq00QEDC7bWSZrPIHKIus8eIuExIE= golang.zx2c4.com/wireguard/windows v0.5.3/go.mod h1:9TEe8TJmtwyQebdFwAkEWOPr3prrtqm+REGFifP60hI= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= @@ -845,6 +855,7 @@ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -888,6 +899,7 @@ honnef.co/go/tools v0.2.2/go.mod h1:lPVVZ2BS5TfnjLyizF7o7hv7j9/L+8cZY2hLyjP9cGY= k8s.io/apimachinery v0.0.0-20191123233150-4c4803ed55e3/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg= k8s.io/apimachinery v0.23.5 h1:Va7dwhp8wgkUPWsEXk6XglXWU4IKYLKNlv8VkX7SDM0= k8s.io/apimachinery v0.23.5/go.mod h1:BEuFMMBaIbcOqVIJqNZJXGFTP4W6AycEpb5+m/97hrM= +k8s.io/apimachinery v0.23.16/go.mod h1:RMMUoABRwnjoljQXKJ86jT5FkTZPPnZsNv70cMsKIP0= k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= diff --git a/integrations/validator.go b/integrations/validator.go index d699603..d2bffe7 100644 --- a/integrations/validator.go +++ b/integrations/validator.go @@ -3,6 +3,7 @@ package integrations import ( "github.com/netbirdio/netbird/management/server/account" "github.com/netbirdio/netbird/management/server/activity" + "github.com/netbirdio/netbird/management/server/group" nbpeer "github.com/netbirdio/netbird/management/server/peer" ) @@ -29,7 +30,7 @@ func (v *IntegratedValidatorImpl) IsNotValidPeer(_ string, _ *nbpeer.Peer, _ []s return false } -func (v *IntegratedValidatorImpl) GetValidatedPeers(_ string, _ map[string][]string, peers map[string]*nbpeer.Peer, _ *account.ExtraSettings) (map[string]struct{}, error) { +func (v *IntegratedValidatorImpl) GetValidatedPeers(_ string, _ map[string]*group.Group, peers map[string]*nbpeer.Peer, _ *account.ExtraSettings) (map[string]struct{}, error) { validatedPeers := make(map[string]struct{}) for p := range peers { validatedPeers[p] = struct{}{} From 4de220a65d0fca4b85a83dccd3103189b1abbc59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Papp?= Date: Thu, 21 Mar 2024 14:39:27 +0100 Subject: [PATCH 16/18] Add PeerDeleted function --- integrations/validator.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/integrations/validator.go b/integrations/validator.go index d2bffe7..b567257 100644 --- a/integrations/validator.go +++ b/integrations/validator.go @@ -38,5 +38,9 @@ func (v *IntegratedValidatorImpl) GetValidatedPeers(_ string, _ map[string]*grou return validatedPeers, nil } +func (v *IntegratedValidatorImpl) PeerDeleted(_, _ string) error { + return nil +} + func (v *IntegratedValidatorImpl) Stop() { } From 99218313701a59ba0af7a83bc51b93c951dac01d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Papp?= Date: Fri, 22 Mar 2024 19:16:56 +0100 Subject: [PATCH 17/18] Follow up default interface changes --- integrations/validator.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/integrations/validator.go b/integrations/validator.go index b567257..e6b7791 100644 --- a/integrations/validator.go +++ b/integrations/validator.go @@ -42,5 +42,9 @@ func (v *IntegratedValidatorImpl) PeerDeleted(_, _ string) error { return nil } +func (v *IntegratedValidatorImpl) SetPeerInvalidationListener(_ func(accountID string)) { + +} + func (v *IntegratedValidatorImpl) Stop() { } From 3682438fca9888ffaec7337452ae3aec35ac0816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Papp?= Date: Tue, 26 Mar 2024 09:38:46 +0100 Subject: [PATCH 18/18] Follow up IsNotValidPeer changes --- integrations/validator.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integrations/validator.go b/integrations/validator.go index e6b7791..843f7b7 100644 --- a/integrations/validator.go +++ b/integrations/validator.go @@ -26,8 +26,8 @@ func (v *IntegratedValidatorImpl) PreparePeer(_ string, peer *nbpeer.Peer, _ []s return peer.Copy() } -func (v *IntegratedValidatorImpl) IsNotValidPeer(_ string, _ *nbpeer.Peer, _ []string, _ *account.ExtraSettings) bool { - return false +func (v *IntegratedValidatorImpl) IsNotValidPeer(_ string, _ *nbpeer.Peer, _ []string, _ *account.ExtraSettings) (bool, bool) { + return false, false } func (v *IntegratedValidatorImpl) GetValidatedPeers(_ string, _ map[string]*group.Group, peers map[string]*nbpeer.Peer, _ *account.ExtraSettings) (map[string]struct{}, error) {