forked from extern/smegmesh
Migrated to using grpc for handling rpc calls
This commit is contained in:
parent
86756903c7
commit
6e9ca4f31f
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"editor.insertSpaces": true,
|
||||
"editor.tabSize": 4,
|
||||
"editor.detectIndentation": false
|
||||
}
|
@ -2,16 +2,17 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/rpc"
|
||||
ipcRpc "net/rpc"
|
||||
"os"
|
||||
|
||||
"github.com/akamensky/argparse"
|
||||
"github.com/tim-beatham/wgmesh/pkg/ctrlserver"
|
||||
"github.com/tim-beatham/wgmesh/pkg/ipc"
|
||||
)
|
||||
|
||||
const SockAddr = "/tmp/wgmesh_ipc.sock"
|
||||
|
||||
func createNewMesh(client *rpc.Client) {
|
||||
func createNewMesh(client *ipcRpc.Client) {
|
||||
var reply string
|
||||
err := client.Call("Mesh.CreateNewMesh", "", &reply)
|
||||
|
||||
@ -23,7 +24,7 @@ func createNewMesh(client *rpc.Client) {
|
||||
fmt.Println(reply)
|
||||
}
|
||||
|
||||
func listMeshes(client *rpc.Client) {
|
||||
func listMeshes(client *ipcRpc.Client) {
|
||||
var reply map[string]ctrlserver.Mesh
|
||||
|
||||
err := client.Call("Mesh.ListMeshes", "", &reply)
|
||||
@ -38,8 +39,19 @@ func listMeshes(client *rpc.Client) {
|
||||
}
|
||||
}
|
||||
|
||||
func joinMesh(client *rpc.Client, meshId string, ipAddress string) {
|
||||
fmt.Println(meshId + " " + ipAddress)
|
||||
func joinMesh(client *ipcRpc.Client, meshId string, ipAddress string) {
|
||||
var reply string
|
||||
|
||||
args := ipc.JoinMeshArgs{MeshId: meshId, IpAdress: ipAddress}
|
||||
|
||||
err := client.Call("Mesh.JoinMesh", &args, &reply)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(reply)
|
||||
}
|
||||
|
||||
func main() {
|
||||
@ -50,8 +62,8 @@ func main() {
|
||||
listMeshCmd := parser.NewCommand("list-meshes", "List meshes the node is connected to")
|
||||
joinMeshCmd := parser.NewCommand("join-mesh", "Join a mesh network")
|
||||
|
||||
var meshId *string = joinMeshCmd.StringPositional(&argparse.Options{Required: true})
|
||||
var ipAddress *string = joinMeshCmd.StringPositional(&argparse.Options{Required: true})
|
||||
var meshId *string = joinMeshCmd.String("m", "mesh", &argparse.Options{Required: true})
|
||||
var ipAddress *string = joinMeshCmd.String("i", "ip", &argparse.Options{Required: true})
|
||||
|
||||
err := parser.Parse(os.Args)
|
||||
|
||||
@ -60,7 +72,7 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
client, err := rpc.DialHTTP("unix", SockAddr)
|
||||
client, err := ipcRpc.DialHTTP("unix", SockAddr)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
return
|
||||
|
@ -1,14 +1,36 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
ctrlserver "github.com/tim-beatham/wgmesh/pkg/ctrlserver"
|
||||
"github.com/tim-beatham/wgmesh/pkg/ctrlserver/api"
|
||||
"github.com/tim-beatham/wgmesh/pkg/ctrlserver/ipc"
|
||||
"github.com/tim-beatham/wgmesh/pkg/ctrlserver/rpc"
|
||||
wg "github.com/tim-beatham/wgmesh/pkg/wg"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type meshCtrlServer struct {
|
||||
rpc.UnimplementedMeshCtrlServerServer
|
||||
server *ctrlserver.MeshCtrlServer
|
||||
}
|
||||
|
||||
func newServer(ctrl *ctrlserver.MeshCtrlServer) *meshCtrlServer {
|
||||
return &meshCtrlServer{server: ctrl}
|
||||
}
|
||||
|
||||
func (m *meshCtrlServer) GetMesh(ctx context.Context, request *rpc.GetMeshRequest) (*rpc.GetMeshReply, error) {
|
||||
mesh, contains := m.server.Meshes[request.MeshId]
|
||||
|
||||
if !contains {
|
||||
return nil, errors.New("Element is not in the mesh")
|
||||
}
|
||||
return &rpc.GetMeshReply{MeshId: mesh.SharedKey.String()}, nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
wgClient, err := wg.CreateClient("wgmesh")
|
||||
|
||||
@ -18,7 +40,19 @@ func main() {
|
||||
}
|
||||
|
||||
ctrlServer := ctrlserver.NewCtrlServer("0.0.0.0", 21910, wgClient)
|
||||
ipc.RunIpcHandler(ctrlServer)
|
||||
r := api.RunAPI(ctrlServer)
|
||||
r.Run(ctrlServer.GetEndpoint())
|
||||
|
||||
fmt.Println("Running IPC Handler")
|
||||
go ipc.RunIpcHandler(ctrlServer)
|
||||
|
||||
fmt.Println("Running gRPC server")
|
||||
|
||||
grpc := grpc.NewServer()
|
||||
|
||||
rpcServer := newServer(ctrlServer)
|
||||
rpc.RegisterMeshCtrlServerServer(grpc, rpcServer)
|
||||
|
||||
lis, err := net.Listen("tcp", ":8080")
|
||||
if err := grpc.Serve(lis); err != nil {
|
||||
fmt.Print(err.Error())
|
||||
}
|
||||
}
|
||||
|
11
go.mod
11
go.mod
@ -18,7 +18,10 @@ require (
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.15.4 // indirect
|
||||
github.com/goccy/go-json v0.10.2 // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/google/go-cmp v0.5.9 // indirect
|
||||
github.com/gorilla/mux v1.8.0 // indirect
|
||||
github.com/gorilla/rpc v1.2.0 // indirect
|
||||
github.com/josharian/native v1.1.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
|
||||
@ -26,7 +29,7 @@ require (
|
||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||
github.com/mdlayher/genetlink v1.3.2 // indirect
|
||||
github.com/mdlayher/netlink v1.7.2 // indirect
|
||||
github.com/mdlayher/socket v0.4.1 // indirect
|
||||
github.com/mdlayher/socket v0.5.0 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
|
||||
@ -35,10 +38,12 @@ require (
|
||||
golang.org/x/arch v0.5.0 // indirect
|
||||
golang.org/x/crypto v0.13.0 // indirect
|
||||
golang.org/x/net v0.15.0 // indirect
|
||||
golang.org/x/sync v0.1.0 // indirect
|
||||
golang.org/x/sync v0.3.0 // indirect
|
||||
golang.org/x/sys v0.12.0 // indirect
|
||||
golang.org/x/text v0.13.0 // indirect
|
||||
golang.zx2c4.com/wireguard v0.0.0-20230325221338-052af4a8072b // indirect
|
||||
golang.zx2c4.com/wireguard v0.0.0-20230704135630-469159ecf7d1 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
|
||||
google.golang.org/grpc v1.58.1 // indirect
|
||||
google.golang.org/protobuf v1.31.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
18
go.sum
18
go.sum
@ -30,10 +30,16 @@ github.com/go-playground/validator/v10 v10.15.4/go.mod h1:9iXMNT7sEkjXb0I+enO7QX
|
||||
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
||||
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
|
||||
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
|
||||
github.com/gorilla/rpc v1.2.0 h1:WvvdC2lNeT1SP32zrIce5l0ECBfbAlmrmSBsuc57wfk=
|
||||
github.com/gorilla/rpc v1.2.0/go.mod h1:V4h9r+4sF5HnzqbwIez0fKSpANP0zlYd3qR7p36jkTQ=
|
||||
github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
|
||||
github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
@ -52,6 +58,8 @@ github.com/mdlayher/netlink v1.7.2 h1:/UtM3ofJap7Vl4QWCPDGXY8d3GIY2UGSDbK+QWmY8/
|
||||
github.com/mdlayher/netlink v1.7.2/go.mod h1:xraEF7uJbxLhc5fpHL4cPe221LI2bdttWlU+ZGLfQSw=
|
||||
github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U=
|
||||
github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA=
|
||||
github.com/mdlayher/socket v0.5.0 h1:ilICZmJcQz70vrWVes1MFera4jGiWNocSkykwwoy3XI=
|
||||
github.com/mdlayher/socket v0.5.0/go.mod h1:WkcBFfvyG8QENs5+hfQPl1X6Jpd2yeLIYgrGFmJiJxI=
|
||||
github.com/mikioh/ipaddr v0.0.0-20190404000644-d465c8ab6721 h1:RlZweED6sbSArvlE924+mUcZuXKLBHA35U7LN621Bws=
|
||||
github.com/mikioh/ipaddr v0.0.0-20190404000644-d465c8ab6721/go.mod h1:Ickgr2WtCLZ2MDGd4Gr0geeCH5HybhRJbonOgQpvSxc=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
@ -87,6 +95,8 @@ golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
|
||||
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
||||
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
|
||||
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
|
||||
@ -96,9 +106,17 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.zx2c4.com/wireguard v0.0.0-20230325221338-052af4a8072b h1:J1CaxgLerRR5lgx3wnr6L04cJFbWoceSK9JWBdglINo=
|
||||
golang.zx2c4.com/wireguard v0.0.0-20230325221338-052af4a8072b/go.mod h1:tqur9LnfstdR9ep2LaJT4lFUl0EjlHtge+gAjmsHUG4=
|
||||
golang.zx2c4.com/wireguard v0.0.0-20230704135630-469159ecf7d1 h1:EY138uSo1JYlDq+97u1FtcOUwPpIU6WL1Lkt7WpYjPA=
|
||||
golang.zx2c4.com/wireguard v0.0.0-20230704135630-469159ecf7d1/go.mod h1:tqur9LnfstdR9ep2LaJT4lFUl0EjlHtge+gAjmsHUG4=
|
||||
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6 h1:CawjfCvYQH2OU3/TnxLx97WDSUDRABfT18pCOYwc2GE=
|
||||
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6/go.mod h1:3rxYc4HtVcSG9gVaTs2GEBdehh+sYPOwKtyUWEOTb80=
|
||||
google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 h1:Z0hjGZePRE0ZBWotvtrwxFNrNE9CUAGtplaDK5NNI/g=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM=
|
||||
google.golang.org/grpc v1.58.1 h1:OL+Vz23DTtrrldqHK49FUOPHyY75rvFqJfXC84NYW58=
|
||||
google.golang.org/grpc v1.58.1/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
|
||||
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
|
@ -1,17 +0,0 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
ctrlserver "github.com/tim-beatham/wgmesh/pkg/ctrlserver"
|
||||
"github.com/tim-beatham/wgmesh/pkg/ctrlserver/api/mesh"
|
||||
)
|
||||
|
||||
func RunAPI(server *ctrlserver.MeshCtrlServer) *gin.Engine {
|
||||
r := gin.Default()
|
||||
|
||||
r.POST("/mesh", func(ctx *gin.Context) {
|
||||
mesh.JoinMesh(ctx, server)
|
||||
})
|
||||
|
||||
return r
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package mesh
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
ctrlserver "github.com/tim-beatham/wgmesh/pkg/ctrlserver"
|
||||
)
|
||||
|
||||
type JoinMeshInput struct {
|
||||
MeshId string `json:"mesh-id" binding:"required`
|
||||
}
|
||||
|
||||
func JoinMesh(c *gin.Context, server *ctrlserver.MeshCtrlServer) {
|
||||
var input JoinMeshInput
|
||||
|
||||
if err := c.ShouldBindJSON(&input); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"status": "success"})
|
||||
}
|
@ -1,14 +1,20 @@
|
||||
package ipc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/rpc"
|
||||
ipcRpc "net/rpc"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/tim-beatham/wgmesh/pkg/ctrlserver"
|
||||
"github.com/tim-beatham/wgmesh/pkg/ctrlserver/rpc"
|
||||
ipctypes "github.com/tim-beatham/wgmesh/pkg/ipc"
|
||||
"github.com/tim-beatham/wgmesh/pkg/wg"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
|
||||
const SockAddr = "/tmp/wgmesh_ipc.sock"
|
||||
@ -34,9 +40,33 @@ func (n Mesh) CreateNewMesh(name *string, reply *string) error {
|
||||
}
|
||||
|
||||
func (n Mesh) ListMeshes(name *string, reply *map[string]ctrlserver.Mesh) error {
|
||||
meshes := n.Server.Meshes
|
||||
*reply = meshes
|
||||
return nil
|
||||
meshes := n.Server.Meshes
|
||||
*reply = meshes
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n Mesh) JoinMesh(args *ipctypes.JoinMeshArgs, reply *string) error {
|
||||
conn, err := grpc.Dial(args.IpAdress+":8080", grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer conn.Close()
|
||||
|
||||
c := rpc.NewMeshCtrlServerClient(conn)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
|
||||
r, err := c.GetMesh(ctx, &rpc.GetMeshRequest{MeshId: args.MeshId})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*reply = r.GetMeshId()
|
||||
return nil
|
||||
}
|
||||
|
||||
func RunIpcHandler(server *ctrlserver.MeshCtrlServer) error {
|
||||
@ -46,8 +76,8 @@ func RunIpcHandler(server *ctrlserver.MeshCtrlServer) error {
|
||||
|
||||
newMeshIpc := new(Mesh)
|
||||
newMeshIpc.Server = server
|
||||
rpc.Register(newMeshIpc)
|
||||
rpc.HandleHTTP()
|
||||
ipcRpc.Register(newMeshIpc)
|
||||
ipcRpc.HandleHTTP()
|
||||
|
||||
l, e := net.Listen("unix", SockAddr)
|
||||
if e != nil {
|
||||
|
214
pkg/ctrlserver/rpc/ctrlserver.pb.go
Normal file
214
pkg/ctrlserver/rpc/ctrlserver.pb.go
Normal file
@ -0,0 +1,214 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.21.12
|
||||
// source: pkg/grpc/ctrlserver/ctrlserver.proto
|
||||
|
||||
package rpc
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type GetMeshRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
MeshId string `protobuf:"bytes,1,opt,name=meshId,proto3" json:"meshId,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetMeshRequest) Reset() {
|
||||
*x = GetMeshRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_pkg_grpc_ctrlserver_ctrlserver_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetMeshRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetMeshRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetMeshRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_pkg_grpc_ctrlserver_ctrlserver_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetMeshRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetMeshRequest) Descriptor() ([]byte, []int) {
|
||||
return file_pkg_grpc_ctrlserver_ctrlserver_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *GetMeshRequest) GetMeshId() string {
|
||||
if x != nil {
|
||||
return x.MeshId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetMeshReply struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
MeshId string `protobuf:"bytes,1,opt,name=meshId,proto3" json:"meshId,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetMeshReply) Reset() {
|
||||
*x = GetMeshReply{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_pkg_grpc_ctrlserver_ctrlserver_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetMeshReply) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetMeshReply) ProtoMessage() {}
|
||||
|
||||
func (x *GetMeshReply) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_pkg_grpc_ctrlserver_ctrlserver_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetMeshReply.ProtoReflect.Descriptor instead.
|
||||
func (*GetMeshReply) Descriptor() ([]byte, []int) {
|
||||
return file_pkg_grpc_ctrlserver_ctrlserver_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *GetMeshReply) GetMeshId() string {
|
||||
if x != nil {
|
||||
return x.MeshId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_pkg_grpc_ctrlserver_ctrlserver_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_pkg_grpc_ctrlserver_ctrlserver_proto_rawDesc = []byte{
|
||||
0x0a, 0x24, 0x70, 0x6b, 0x67, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x74, 0x72, 0x6c, 0x73,
|
||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x63, 0x74, 0x72, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x72, 0x70, 0x63, 0x74, 0x79, 0x70, 0x65, 0x73,
|
||||
0x22, 0x28, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x4d, 0x65, 0x73, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x73, 0x68, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x73, 0x68, 0x49, 0x64, 0x22, 0x26, 0x0a, 0x0c, 0x47, 0x65,
|
||||
0x74, 0x4d, 0x65, 0x73, 0x68, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65,
|
||||
0x73, 0x68, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x73, 0x68,
|
||||
0x49, 0x64, 0x32, 0x4f, 0x0a, 0x0e, 0x4d, 0x65, 0x73, 0x68, 0x43, 0x74, 0x72, 0x6c, 0x53, 0x65,
|
||||
0x72, 0x76, 0x65, 0x72, 0x12, 0x3d, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x4d, 0x65, 0x73, 0x68, 0x12,
|
||||
0x18, 0x2e, 0x72, 0x70, 0x63, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x47, 0x65, 0x74, 0x4d, 0x65,
|
||||
0x73, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x70, 0x63, 0x74,
|
||||
0x79, 0x70, 0x65, 0x73, 0x2e, 0x47, 0x65, 0x74, 0x4d, 0x65, 0x73, 0x68, 0x52, 0x65, 0x70, 0x6c,
|
||||
0x79, 0x22, 0x00, 0x42, 0x14, 0x5a, 0x12, 0x70, 0x6b, 0x67, 0x2f, 0x63, 0x74, 0x72, 0x6c, 0x73,
|
||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_pkg_grpc_ctrlserver_ctrlserver_proto_rawDescOnce sync.Once
|
||||
file_pkg_grpc_ctrlserver_ctrlserver_proto_rawDescData = file_pkg_grpc_ctrlserver_ctrlserver_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_pkg_grpc_ctrlserver_ctrlserver_proto_rawDescGZIP() []byte {
|
||||
file_pkg_grpc_ctrlserver_ctrlserver_proto_rawDescOnce.Do(func() {
|
||||
file_pkg_grpc_ctrlserver_ctrlserver_proto_rawDescData = protoimpl.X.CompressGZIP(file_pkg_grpc_ctrlserver_ctrlserver_proto_rawDescData)
|
||||
})
|
||||
return file_pkg_grpc_ctrlserver_ctrlserver_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_pkg_grpc_ctrlserver_ctrlserver_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_pkg_grpc_ctrlserver_ctrlserver_proto_goTypes = []interface{}{
|
||||
(*GetMeshRequest)(nil), // 0: rpctypes.GetMeshRequest
|
||||
(*GetMeshReply)(nil), // 1: rpctypes.GetMeshReply
|
||||
}
|
||||
var file_pkg_grpc_ctrlserver_ctrlserver_proto_depIdxs = []int32{
|
||||
0, // 0: rpctypes.MeshCtrlServer.GetMesh:input_type -> rpctypes.GetMeshRequest
|
||||
1, // 1: rpctypes.MeshCtrlServer.GetMesh:output_type -> rpctypes.GetMeshReply
|
||||
1, // [1:2] is the sub-list for method output_type
|
||||
0, // [0:1] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_pkg_grpc_ctrlserver_ctrlserver_proto_init() }
|
||||
func file_pkg_grpc_ctrlserver_ctrlserver_proto_init() {
|
||||
if File_pkg_grpc_ctrlserver_ctrlserver_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_pkg_grpc_ctrlserver_ctrlserver_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetMeshRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_grpc_ctrlserver_ctrlserver_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetMeshReply); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_pkg_grpc_ctrlserver_ctrlserver_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 2,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_pkg_grpc_ctrlserver_ctrlserver_proto_goTypes,
|
||||
DependencyIndexes: file_pkg_grpc_ctrlserver_ctrlserver_proto_depIdxs,
|
||||
MessageInfos: file_pkg_grpc_ctrlserver_ctrlserver_proto_msgTypes,
|
||||
}.Build()
|
||||
File_pkg_grpc_ctrlserver_ctrlserver_proto = out.File
|
||||
file_pkg_grpc_ctrlserver_ctrlserver_proto_rawDesc = nil
|
||||
file_pkg_grpc_ctrlserver_ctrlserver_proto_goTypes = nil
|
||||
file_pkg_grpc_ctrlserver_ctrlserver_proto_depIdxs = nil
|
||||
}
|
105
pkg/ctrlserver/rpc/ctrlserver_grpc.pb.go
Normal file
105
pkg/ctrlserver/rpc/ctrlserver_grpc.pb.go
Normal file
@ -0,0 +1,105 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.2.0
|
||||
// - protoc v3.21.12
|
||||
// source: pkg/grpc/ctrlserver/ctrlserver.proto
|
||||
|
||||
package rpc
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
// MeshCtrlServerClient is the client API for MeshCtrlServer service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type MeshCtrlServerClient interface {
|
||||
GetMesh(ctx context.Context, in *GetMeshRequest, opts ...grpc.CallOption) (*GetMeshReply, error)
|
||||
}
|
||||
|
||||
type meshCtrlServerClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewMeshCtrlServerClient(cc grpc.ClientConnInterface) MeshCtrlServerClient {
|
||||
return &meshCtrlServerClient{cc}
|
||||
}
|
||||
|
||||
func (c *meshCtrlServerClient) GetMesh(ctx context.Context, in *GetMeshRequest, opts ...grpc.CallOption) (*GetMeshReply, error) {
|
||||
out := new(GetMeshReply)
|
||||
err := c.cc.Invoke(ctx, "/rpctypes.MeshCtrlServer/GetMesh", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// MeshCtrlServerServer is the server API for MeshCtrlServer service.
|
||||
// All implementations must embed UnimplementedMeshCtrlServerServer
|
||||
// for forward compatibility
|
||||
type MeshCtrlServerServer interface {
|
||||
GetMesh(context.Context, *GetMeshRequest) (*GetMeshReply, error)
|
||||
mustEmbedUnimplementedMeshCtrlServerServer()
|
||||
}
|
||||
|
||||
// UnimplementedMeshCtrlServerServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedMeshCtrlServerServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedMeshCtrlServerServer) GetMesh(context.Context, *GetMeshRequest) (*GetMeshReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetMesh not implemented")
|
||||
}
|
||||
func (UnimplementedMeshCtrlServerServer) mustEmbedUnimplementedMeshCtrlServerServer() {}
|
||||
|
||||
// UnsafeMeshCtrlServerServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to MeshCtrlServerServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeMeshCtrlServerServer interface {
|
||||
mustEmbedUnimplementedMeshCtrlServerServer()
|
||||
}
|
||||
|
||||
func RegisterMeshCtrlServerServer(s grpc.ServiceRegistrar, srv MeshCtrlServerServer) {
|
||||
s.RegisterService(&MeshCtrlServer_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _MeshCtrlServer_GetMesh_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetMeshRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MeshCtrlServerServer).GetMesh(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/rpctypes.MeshCtrlServer/GetMesh",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MeshCtrlServerServer).GetMesh(ctx, req.(*GetMeshRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// MeshCtrlServer_ServiceDesc is the grpc.ServiceDesc for MeshCtrlServer service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var MeshCtrlServer_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "rpctypes.MeshCtrlServer",
|
||||
HandlerType: (*MeshCtrlServerServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "GetMesh",
|
||||
Handler: _MeshCtrlServer_GetMesh_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "pkg/grpc/ctrlserver/ctrlserver.proto",
|
||||
}
|
1
pkg/ctrlserver/rpc/rpchandler.go
Normal file
1
pkg/ctrlserver/rpc/rpchandler.go
Normal file
@ -0,0 +1 @@
|
||||
package rpc
|
6
pkg/ipc/ipctypes.go
Normal file
6
pkg/ipc/ipctypes.go
Normal file
@ -0,0 +1,6 @@
|
||||
package ipc
|
||||
|
||||
type JoinMeshArgs struct {
|
||||
MeshId string
|
||||
IpAdress string
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user