Skip to content
Snippets Groups Projects
Commit 6daa17db authored by Martin Stiemerling's avatar Martin Stiemerling :speech_balloon:
Browse files

Add peer via ETSI-alike grpc works

parent 9fd5a5fc
No related branches found
No related tags found
1 merge request!9First working draft version
......@@ -16,9 +16,10 @@ var (
type etsiServer struct {
pb.UnimplementedKmsETSIServer
handlingEkms *eKMS
}
func (kms *etsiServer) ETSICapabilities(ctx context.Context, in *pb.ETSICapabilitiesRequest) (capReply *pb.ETSICapabilitiesReply, err error) {
func (es *etsiServer) ETSICapabilities(ctx context.Context, in *pb.ETSICapabilitiesRequest) (capReply *pb.ETSICapabilitiesReply, err error) {
log.Printf("Received: %v", in.GetMyKmsName())
return &pb.ETSICapabilitiesReply{
......@@ -26,18 +27,18 @@ func (kms *etsiServer) ETSICapabilities(ctx context.Context, in *pb.ETSICapabili
}, nil
}
func (kms *etsiServer) ETSIAddKMSPeer(ctx context.Context, in *pb.ETSIKMSPeerRequest) (*pb.ETSIKMSPeerReply, error) {
func (es *etsiServer) ETSIAddKMSPeer(ctx context.Context, in *pb.ETSIKMSPeerRequest) (*pb.ETSIKMSPeerReply, error) {
//determine the kms structure to call
log.Printf("AddKMSPeer called.")
//etsiServer.AddPeer(in.GetKmsPeerSocket())
es.handlingEkms.AddPeer(in.GetKmsPeerSocket())
return &pb.ETSIKMSPeerReply{
//KmsPeerName: kms.kmsName,
KmsPeerName: es.handlingEkms.kmsName,
}, nil
}
func (kms *etsiServer) ETSIRemoveKMSPeer(ctx context.Context, in *pb.ETSIKMSPeerRequest) (*pb.ETSIKMSPeerReply, error) {
func (es *etsiServer) ETSIRemoveKMSPeer(ctx context.Context, in *pb.ETSIKMSPeerRequest) (*pb.ETSIKMSPeerReply, error) {
//kms.RemovePeer(in.GetKmsPeerSocket())
return &pb.ETSIKMSPeerReply{
......@@ -45,7 +46,7 @@ func (kms *etsiServer) ETSIRemoveKMSPeer(ctx context.Context, in *pb.ETSIKMSPeer
}, nil
}
func (kms *etsiServer) GetEncryptKeys256Bit(ctx context.Context, in *pb.ETSIGetEncryptKeys256BitRequest) (*pb.ETSIGetEncryptKeys256BitReply, error) {
func (es *etsiServer) GetEncryptKeys256Bit(ctx context.Context, in *pb.ETSIGetEncryptKeys256BitRequest) (*pb.ETSIGetEncryptKeys256BitReply, error) {
log.Printf("Received request for n=%d keys", in.GetAmount())
testBytes := []byte{120, 120, 120}
......@@ -57,7 +58,7 @@ func (kms *etsiServer) GetEncryptKeys256Bit(ctx context.Context, in *pb.ETSIGetE
}, nil
}
func StartETSI(listenAddr string) {
func StartETSI(listenAddr string, callingKMS *eKMS) {
flag.Parse()
//lis, err := net.Listen("tcp", fmt.Sprintf(":%d", *etsiPort))
......@@ -66,7 +67,9 @@ func StartETSI(listenAddr string) {
log.Fatalf("failed to listen: %v", err)
}
s := grpc.NewServer()
pb.RegisterKmsETSIServer(s, &etsiServer{})
pb.RegisterKmsETSIServer(s, &etsiServer{
handlingEkms: callingKMS,
})
log.Printf("server listening at %v", lis.Addr())
if err := s.Serve(lis); err != nil {
log.Fatalf("failed to serve: %v", err)
......
......@@ -74,7 +74,7 @@ func emulatedKMS(myName string, myUDPAddr string, peerUDPAddr string) {
myQL.QuantumElementLink.AddPeer(*udpQL2Addr)
// Start the SDN/management and key retrieval interface
go kms.StartETSI(peerUDPAddr)
go kms.StartETSI(peerUDPAddr, emuKMS)
// TODO/XXX catch errors!
emuKMS.GlobalKeyHandler(7 * time.Second)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment