mirror of
https://github.com/tim-beatham/smegmesh.git
synced 2024-12-12 09:30:52 +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)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
fmt.Print(err.Error())
|
||||
}
|
||||
|
||||
fmt.Println(reply)
|
||||
@ -67,7 +67,7 @@ func leaveMesh(client *ipc.SmegmeshIpc, meshId string) {
|
||||
err := client.LeaveMesh(meshId, &reply)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
fmt.Print(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ func getGraph(client *ipc.SmegmeshIpc) {
|
||||
err := client.ListMeshes(listMeshesReply)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
fmt.Print(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ func putAlias(client *ipc.SmegmeshIpc, meshid, alias string) {
|
||||
}, &reply)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
fmt.Print(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@ -171,7 +171,7 @@ func setService(client *ipc.SmegmeshIpc, meshId, service, value string) {
|
||||
}, &reply)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
fmt.Print(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -293,7 +293,10 @@ func (m *WgMeshConfigApplyer) getClientConfig(params *GetConfigParams) (*wgtypes
|
||||
Peers: peerCfgs,
|
||||
}
|
||||
|
||||
m.routeInstaller.InstallRoutes(params.dev.Name, installedRoutes...)
|
||||
if params.dev != nil {
|
||||
m.routeInstaller.InstallRoutes(params.dev.Name, installedRoutes...)
|
||||
}
|
||||
|
||||
return &cfg, err
|
||||
}
|
||||
|
||||
@ -400,7 +403,11 @@ func (m *WgMeshConfigApplyer) updateWgConf(mesh MeshProvider, routes map[string]
|
||||
}
|
||||
|
||||
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 {
|
||||
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
|
||||
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 {
|
||||
return err
|
||||
|
@ -82,7 +82,7 @@ func (s *SyncerImpl) Sync(correspondingMesh mesh.MeshProvider) (bool, error) {
|
||||
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
|
||||
redundancyLength := min(len(neighbours), 2)
|
||||
gossipNodes = neighbours[:redundancyLength]
|
||||
@ -126,13 +126,12 @@ func (s *SyncerImpl) Sync(correspondingMesh mesh.MeshProvider) (bool, error) {
|
||||
s.infectionCount++
|
||||
}
|
||||
|
||||
changes := correspondingMesh.HasChanges()
|
||||
correspondingMesh.SaveChanges()
|
||||
|
||||
s.lastSyncLock.Lock()
|
||||
s.lastSync[correspondingMesh.GetMeshId()] = time.Now().Unix()
|
||||
s.lastSyncLock.Unlock()
|
||||
return changes, nil
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// Pull one node in the cluster, if there has not been message dissemination
|
||||
|
Loading…
Reference in New Issue
Block a user