mirror of
https://github.com/tim-beatham/smegmesh.git
synced 2024-12-13 10:01:22 +01:00
main
- DONE :)
This commit is contained in:
parent
b6fe352553
commit
a619838e9e
@ -55,7 +55,7 @@ func joinMesh(client *ipc.SmegmeshIpc, args ipc.JoinMeshArgs) {
|
|||||||
err := client.JoinMesh(args, &reply)
|
err := client.JoinMesh(args, &reply)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err.Error())
|
fmt.Print(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(reply)
|
fmt.Println(reply)
|
||||||
@ -67,7 +67,7 @@ func leaveMesh(client *ipc.SmegmeshIpc, meshId string) {
|
|||||||
err := client.LeaveMesh(meshId, &reply)
|
err := client.LeaveMesh(meshId, &reply)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err.Error())
|
fmt.Print(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ func getGraph(client *ipc.SmegmeshIpc) {
|
|||||||
err := client.ListMeshes(listMeshesReply)
|
err := client.ListMeshes(listMeshesReply)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err.Error())
|
fmt.Print(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ func putAlias(client *ipc.SmegmeshIpc, meshid, alias string) {
|
|||||||
}, &reply)
|
}, &reply)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err.Error())
|
fmt.Print(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ func setService(client *ipc.SmegmeshIpc, meshId, service, value string) {
|
|||||||
}, &reply)
|
}, &reply)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err.Error())
|
fmt.Print(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,7 +293,10 @@ func (m *WgMeshConfigApplyer) getClientConfig(params *GetConfigParams) (*wgtypes
|
|||||||
Peers: peerCfgs,
|
Peers: peerCfgs,
|
||||||
}
|
}
|
||||||
|
|
||||||
m.routeInstaller.InstallRoutes(params.dev.Name, installedRoutes...)
|
if params.dev != nil {
|
||||||
|
m.routeInstaller.InstallRoutes(params.dev.Name, installedRoutes...)
|
||||||
|
}
|
||||||
|
|
||||||
return &cfg, err
|
return &cfg, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,7 +403,11 @@ func (m *WgMeshConfigApplyer) updateWgConf(mesh MeshProvider, routes map[string]
|
|||||||
}
|
}
|
||||||
|
|
||||||
nodes := lib.MapValues(snap.GetNodes())
|
nodes := lib.MapValues(snap.GetNodes())
|
||||||
dev, _ := mesh.GetDevice()
|
dev, err := mesh.GetDevice()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
slices.SortFunc(nodes, func(a, b MeshNode) int {
|
slices.SortFunc(nodes, func(a, b MeshNode) int {
|
||||||
return strings.Compare(string(a.GetType()), string(b.GetType()))
|
return strings.Compare(string(a.GetType()), string(b.GetType()))
|
||||||
|
@ -202,7 +202,7 @@ func (n *IpcHandler) Query(params ipc.QueryMesh, reply *string) error {
|
|||||||
|
|
||||||
// PutDescription: change your description in the mesh
|
// PutDescription: change your description in the mesh
|
||||||
func (n *IpcHandler) PutDescription(args ipc.PutDescriptionArgs, reply *string) error {
|
func (n *IpcHandler) PutDescription(args ipc.PutDescriptionArgs, reply *string) error {
|
||||||
err := n.Server.GetMeshManager().SetDescription(args.MeshId, args.Description)
|
err := n.Server.GetMeshManager().SetDescription(args.MeshId, args.Description)z
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -82,7 +82,7 @@ func (s *SyncerImpl) Sync(correspondingMesh mesh.MeshProvider) (bool, error) {
|
|||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Peer with 2 nodes so that there is redundnacy in
|
// Peer with 2 nodes so that there is redundancy in
|
||||||
// the situation the node leaves pre-emptively
|
// the situation the node leaves pre-emptively
|
||||||
redundancyLength := min(len(neighbours), 2)
|
redundancyLength := min(len(neighbours), 2)
|
||||||
gossipNodes = neighbours[:redundancyLength]
|
gossipNodes = neighbours[:redundancyLength]
|
||||||
@ -126,13 +126,12 @@ func (s *SyncerImpl) Sync(correspondingMesh mesh.MeshProvider) (bool, error) {
|
|||||||
s.infectionCount++
|
s.infectionCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
changes := correspondingMesh.HasChanges()
|
|
||||||
correspondingMesh.SaveChanges()
|
correspondingMesh.SaveChanges()
|
||||||
|
|
||||||
s.lastSyncLock.Lock()
|
s.lastSyncLock.Lock()
|
||||||
s.lastSync[correspondingMesh.GetMeshId()] = time.Now().Unix()
|
s.lastSync[correspondingMesh.GetMeshId()] = time.Now().Unix()
|
||||||
s.lastSyncLock.Unlock()
|
s.lastSyncLock.Unlock()
|
||||||
return changes, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pull one node in the cluster, if there has not been message dissemination
|
// Pull one node in the cluster, if there has not been message dissemination
|
||||||
|
Loading…
Reference in New Issue
Block a user