From 6954608c326e091fcab7af5ca64b108c33ee1140 Mon Sep 17 00:00:00 2001 From: Tim Beatham Date: Sat, 30 Dec 2023 22:24:43 +0000 Subject: [PATCH 1/2] 66-ipv6-address-not-confirming-to-spec - UUID is not random just a name generator needs changing to shortuuid - When in multiple meshes there is no wait group --- pkg/lib/id.go | 9 +++++++++ pkg/sync/syncer.go | 19 +++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/pkg/lib/id.go b/pkg/lib/id.go index d1b85ec..7ba0a29 100644 --- a/pkg/lib/id.go +++ b/pkg/lib/id.go @@ -3,6 +3,7 @@ package lib import ( "github.com/anandvarma/namegen" "github.com/google/uuid" + "github.com/lithammer/shortuuid" ) // IdGenerator generates unique ids @@ -19,6 +20,14 @@ func (g *UUIDGenerator) GetId() (string, error) { return id.String(), nil } +type ShortIDGenerator struct { +} + +func (g *ShortIDGenerator) GetId() (string, error) { + id := shortuuid.New() + return id, nil +} + type IDNameGenerator struct { } diff --git a/pkg/sync/syncer.go b/pkg/sync/syncer.go index 71704c5..a052bd4 100644 --- a/pkg/sync/syncer.go +++ b/pkg/sync/syncer.go @@ -4,6 +4,7 @@ import ( "fmt" "io" "math/rand" + "sync" "time" "github.com/tim-beatham/wgmesh/pkg/conf" @@ -169,12 +170,22 @@ func (s *SyncerImpl) Pull(self mesh.MeshNode, mesh mesh.MeshProvider) error { // SyncMeshes: Sync all meshes func (s *SyncerImpl) SyncMeshes() error { - for _, mesh := range s.manager.GetMeshes() { - err := s.Sync(mesh) + var wg sync.WaitGroup - if err != nil { - logging.Log.WriteErrorf(err.Error()) + for _, mesh := range s.manager.GetMeshes() { + wg.Add(1) + + sync := func() { + defer wg.Done() + + err := s.Sync(mesh) + + if err != nil { + logging.Log.WriteErrorf(err.Error()) + } } + + go sync() } logging.Log.WriteInfof("updating the WireGuard configuration") From 1a9d9d61adc63d02c51886640f7a64efec7110dd Mon Sep 17 00:00:00 2001 From: Tim Beatham Date: Sat, 30 Dec 2023 22:26:08 +0000 Subject: [PATCH 2/2] 66-ipv6-address-not-conforming-to-spec - Missing commit --- pkg/ctrlserver/ctrlserver.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/ctrlserver/ctrlserver.go b/pkg/ctrlserver/ctrlserver.go index 464eb67..cb0c75f 100644 --- a/pkg/ctrlserver/ctrlserver.go +++ b/pkg/ctrlserver/ctrlserver.go @@ -34,7 +34,7 @@ func NewCtrlServer(params *NewCtrlServerParams) (*MeshCtrlServer, error) { nodeFactory := &crdt.MeshNodeFactory{ Config: *params.Conf, } - idGenerator := &lib.IDNameGenerator{} + idGenerator := &lib.ShortIDGenerator{} ipAllocator := &ip.ULABuilder{} interfaceManipulator := wg.NewWgInterfaceManipulator(params.Client) @@ -89,7 +89,6 @@ func NewCtrlServer(params *NewCtrlServerParams) (*MeshCtrlServer, error) { return ctrlServer, nil } - func (s *MeshCtrlServer) GetConfiguration() *conf.DaemonConfiguration { return s.Conf }