mirror of
https://github.com/tim-beatham/smegmesh.git
synced 2024-12-13 10:01:22 +01:00
Tidied up code, made changes for benchmarking.
This commit is contained in:
parent
928f6af9ac
commit
579426e32d
@ -1,6 +1,6 @@
|
||||
certificatePath: "../../cert/cert.pem"
|
||||
privateKeyPath: "../../cert/priv.pem"
|
||||
caCertificatePath: "../../cert/cacert.pem"
|
||||
certificatePath: "/wgmesh/cert/cert.pem"
|
||||
privateKeyPath: "/wgmesh/cert/priv.pem"
|
||||
caCertificatePath: "/wgmesh/cert/cacert.pem"
|
||||
skipCertVerification: true
|
||||
gRPCPort: "8080"
|
||||
advertiseRoutes: true
|
||||
|
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/tim-beatham/wgmesh/pkg/conf"
|
||||
ctrlserver "github.com/tim-beatham/wgmesh/pkg/ctrlserver"
|
||||
@ -15,9 +16,15 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
conf, err := conf.ParseConfiguration("./configuration.yaml")
|
||||
if len(os.Args) != 2 {
|
||||
logging.Log.WriteErrorf("Need to provide configuration.yaml")
|
||||
return
|
||||
}
|
||||
|
||||
conf, err := conf.ParseConfiguration(os.Args[1])
|
||||
if err != nil {
|
||||
log.Fatalln("Could not parse configuration")
|
||||
logging.Log.WriteInfof("Could not parse configuration")
|
||||
return
|
||||
}
|
||||
|
||||
client, err := wgctrl.New()
|
||||
|
@ -50,7 +50,10 @@ func (m *MeshManager) CreateMesh(devName string, port int) (string, error) {
|
||||
}
|
||||
|
||||
m.Meshes[meshId] = nodeManager
|
||||
return meshId, err
|
||||
return meshId, m.interfaceManipulator.CreateInterface(&wg.CreateInterfaceParams{
|
||||
IfName: devName,
|
||||
Port: port,
|
||||
})
|
||||
}
|
||||
|
||||
type AddMeshParams struct {
|
||||
@ -81,7 +84,11 @@ func (m *MeshManager) AddMesh(params *AddMeshParams) error {
|
||||
}
|
||||
|
||||
m.Meshes[params.MeshId] = meshProvider
|
||||
return err
|
||||
|
||||
return m.interfaceManipulator.CreateInterface(&wg.CreateInterfaceParams{
|
||||
IfName: params.DevName,
|
||||
Port: params.WgPort,
|
||||
})
|
||||
}
|
||||
|
||||
// HasChanges returns true if the mesh has changes
|
||||
@ -214,11 +221,21 @@ func (s *MeshManager) GetSelf(meshId string) (MeshNode, error) {
|
||||
// UpdateTimeStamp updates the timestamp of this node in all meshes
|
||||
func (s *MeshManager) UpdateTimeStamp() error {
|
||||
for _, mesh := range s.Meshes {
|
||||
err := mesh.UpdateTimeStamp(s.HostParameters.HostEndpoint)
|
||||
snapshot, err := mesh.GetMesh()
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, exists := snapshot.GetNodes()[s.HostParameters.HostEndpoint]
|
||||
|
||||
if exists {
|
||||
err = mesh.UpdateTimeStamp(s.HostParameters.HostEndpoint)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -31,8 +31,9 @@ func (n *IpcHandler) CreateMesh(args *ipc.NewMeshArgs, reply *string) error {
|
||||
WgPort: args.WgPort,
|
||||
Endpoint: args.Endpoint,
|
||||
})
|
||||
|
||||
*reply = meshId
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
func (n *IpcHandler) ListMeshes(_ string, reply *ipc.ListMeshReply) error {
|
||||
@ -51,6 +52,10 @@ func (n *IpcHandler) ListMeshes(_ string, reply *ipc.ListMeshReply) error {
|
||||
func (n *IpcHandler) JoinMesh(args ipc.JoinMeshArgs, reply *string) error {
|
||||
peerConnection, err := n.Server.ConnectionManager.GetConnection(args.IpAdress)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
client, err := peerConnection.GetClient()
|
||||
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user