mirror of
https://github.com/tim-beatham/smegmesh.git
synced 2024-12-13 18:11:25 +01:00
30 lines
759 B
Go
30 lines
759 B
Go
package middleware
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
logging "github.com/tim-beatham/wgmesh/pkg/log"
|
|
"github.com/tim-beatham/wgmesh/pkg/rpc"
|
|
)
|
|
|
|
// AuthRpcProvider implements the AuthRpcProvider service
|
|
type AuthRpcProvider struct {
|
|
rpc.UnimplementedAuthenticationServer
|
|
}
|
|
|
|
// JoinMesh handles a JoinMeshRequest. Succeeds by stating the node managed to join the mesh
|
|
// or returns an error if it failed
|
|
func (a *AuthRpcProvider) JoinMesh(ctx context.Context, in *rpc.JoinAuthMeshRequest) (*rpc.JoinAuthMeshReply, error) {
|
|
meshId := in.MeshId
|
|
|
|
if meshId == "" {
|
|
return nil, errors.New("Must specify the meshId")
|
|
}
|
|
|
|
logging.Log.WriteInfof("MeshID: " + in.MeshId)
|
|
|
|
var token string = ""
|
|
return &rpc.JoinAuthMeshReply{Success: true, Token: &token}, nil
|
|
}
|