forked from extern/smegmesh
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
This commit is contained in:
parent
2e6aed6f93
commit
6954608c32
@ -3,6 +3,7 @@ package lib
|
|||||||
import (
|
import (
|
||||||
"github.com/anandvarma/namegen"
|
"github.com/anandvarma/namegen"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
"github.com/lithammer/shortuuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
// IdGenerator generates unique ids
|
// IdGenerator generates unique ids
|
||||||
@ -19,6 +20,14 @@ func (g *UUIDGenerator) GetId() (string, error) {
|
|||||||
return id.String(), nil
|
return id.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ShortIDGenerator struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *ShortIDGenerator) GetId() (string, error) {
|
||||||
|
id := shortuuid.New()
|
||||||
|
return id, nil
|
||||||
|
}
|
||||||
|
|
||||||
type IDNameGenerator struct {
|
type IDNameGenerator struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/tim-beatham/wgmesh/pkg/conf"
|
"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
|
// SyncMeshes: Sync all meshes
|
||||||
func (s *SyncerImpl) SyncMeshes() error {
|
func (s *SyncerImpl) SyncMeshes() error {
|
||||||
for _, mesh := range s.manager.GetMeshes() {
|
var wg sync.WaitGroup
|
||||||
err := s.Sync(mesh)
|
|
||||||
|
|
||||||
if err != nil {
|
for _, mesh := range s.manager.GetMeshes() {
|
||||||
logging.Log.WriteErrorf(err.Error())
|
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")
|
logging.Log.WriteInfof("updating the WireGuard configuration")
|
||||||
|
Loading…
Reference in New Issue
Block a user