2023-10-01 20:01:35 +02:00
|
|
|
package middleware
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
|
2023-10-02 17:03:41 +02:00
|
|
|
logging "github.com/tim-beatham/wgmesh/pkg/log"
|
2023-10-01 20:01:35 +02:00
|
|
|
"github.com/tim-beatham/wgmesh/pkg/rpc"
|
|
|
|
)
|
|
|
|
|
2023-10-24 01:12:38 +02:00
|
|
|
// AuthRpcProvider implements the AuthRpcProvider service
|
2023-10-01 20:01:35 +02:00
|
|
|
type AuthRpcProvider struct {
|
|
|
|
rpc.UnimplementedAuthenticationServer
|
|
|
|
}
|
|
|
|
|
2023-10-24 01:12:38 +02:00
|
|
|
// JoinMesh handles a JoinMeshRequest. Succeeds by stating the node managed to join the mesh
|
|
|
|
// or returns an error if it failed
|
2023-10-01 20:01:35 +02:00
|
|
|
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")
|
|
|
|
}
|
|
|
|
|
2023-10-24 01:12:38 +02:00
|
|
|
logging.Log.WriteInfof("MeshID: " + in.MeshId)
|
2023-10-01 20:01:35 +02:00
|
|
|
|
2023-10-24 01:12:38 +02:00
|
|
|
var token string = ""
|
|
|
|
return &rpc.JoinAuthMeshReply{Success: true, Token: &token}, nil
|
2023-10-01 20:01:35 +02:00
|
|
|
}
|