mirror of
https://github.com/tim-beatham/smegmesh.git
synced 2024-12-14 02:21:30 +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"
|
certificatePath: "/wgmesh/cert/cert.pem"
|
||||||
privateKeyPath: "../../cert/priv.pem"
|
privateKeyPath: "/wgmesh/cert/priv.pem"
|
||||||
caCertificatePath: "../../cert/cacert.pem"
|
caCertificatePath: "/wgmesh/cert/cacert.pem"
|
||||||
skipCertVerification: true
|
skipCertVerification: true
|
||||||
gRPCPort: "8080"
|
gRPCPort: "8080"
|
||||||
advertiseRoutes: true
|
advertiseRoutes: true
|
||||||
|
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/tim-beatham/wgmesh/pkg/conf"
|
"github.com/tim-beatham/wgmesh/pkg/conf"
|
||||||
ctrlserver "github.com/tim-beatham/wgmesh/pkg/ctrlserver"
|
ctrlserver "github.com/tim-beatham/wgmesh/pkg/ctrlserver"
|
||||||
@ -15,9 +16,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
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 {
|
if err != nil {
|
||||||
log.Fatalln("Could not parse configuration")
|
logging.Log.WriteInfof("Could not parse configuration")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
client, err := wgctrl.New()
|
client, err := wgctrl.New()
|
||||||
|
@ -50,7 +50,10 @@ func (m *MeshManager) CreateMesh(devName string, port int) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m.Meshes[meshId] = nodeManager
|
m.Meshes[meshId] = nodeManager
|
||||||
return meshId, err
|
return meshId, m.interfaceManipulator.CreateInterface(&wg.CreateInterfaceParams{
|
||||||
|
IfName: devName,
|
||||||
|
Port: port,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type AddMeshParams struct {
|
type AddMeshParams struct {
|
||||||
@ -81,7 +84,11 @@ func (m *MeshManager) AddMesh(params *AddMeshParams) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m.Meshes[params.MeshId] = meshProvider
|
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
|
// 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
|
// UpdateTimeStamp updates the timestamp of this node in all meshes
|
||||||
func (s *MeshManager) UpdateTimeStamp() error {
|
func (s *MeshManager) UpdateTimeStamp() error {
|
||||||
for _, mesh := range s.Meshes {
|
for _, mesh := range s.Meshes {
|
||||||
err := mesh.UpdateTimeStamp(s.HostParameters.HostEndpoint)
|
snapshot, err := mesh.GetMesh()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, exists := snapshot.GetNodes()[s.HostParameters.HostEndpoint]
|
||||||
|
|
||||||
|
if exists {
|
||||||
|
err = mesh.UpdateTimeStamp(s.HostParameters.HostEndpoint)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -31,8 +31,9 @@ func (n *IpcHandler) CreateMesh(args *ipc.NewMeshArgs, reply *string) error {
|
|||||||
WgPort: args.WgPort,
|
WgPort: args.WgPort,
|
||||||
Endpoint: args.Endpoint,
|
Endpoint: args.Endpoint,
|
||||||
})
|
})
|
||||||
|
|
||||||
*reply = meshId
|
*reply = meshId
|
||||||
return nil
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *IpcHandler) ListMeshes(_ string, reply *ipc.ListMeshReply) error {
|
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 {
|
func (n *IpcHandler) JoinMesh(args ipc.JoinMeshArgs, reply *string) error {
|
||||||
peerConnection, err := n.Server.ConnectionManager.GetConnection(args.IpAdress)
|
peerConnection, err := n.Server.ConnectionManager.GetConnection(args.IpAdress)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
client, err := peerConnection.GetClient()
|
client, err := peerConnection.GetClient()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user