forked from extern/smegmesh
dbc18bddc6
- Performing DAD to check if IPv6 address present before adding outselves to mesh - Changing name from wgmesh to smegmesh
31 lines
567 B
Go
31 lines
567 B
Go
package robin
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"github.com/tim-beatham/smegmesh/pkg/ctrlserver"
|
|
"github.com/tim-beatham/smegmesh/pkg/rpc"
|
|
)
|
|
|
|
type WgRpc struct {
|
|
rpc.UnimplementedMeshCtrlServerServer
|
|
Server *ctrlserver.MeshCtrlServer
|
|
}
|
|
|
|
func (m *WgRpc) GetMesh(ctx context.Context, request *rpc.GetMeshRequest) (*rpc.GetMeshReply, error) {
|
|
mesh := m.Server.MeshManager.GetMesh(request.MeshId)
|
|
|
|
if mesh == nil {
|
|
return nil, errors.New("mesh does not exist")
|
|
}
|
|
|
|
meshBytes := mesh.Save()
|
|
|
|
reply := rpc.GetMeshReply{
|
|
Mesh: meshBytes,
|
|
}
|
|
|
|
return &reply, nil
|
|
}
|