Skip to content

Commit

Permalink
security: Implement IPsecGet()
Browse files Browse the repository at this point in the history
This implements the IPsecGet() API by fetching resulting data from Redis
based on the uuid passed i.

Signed-off-by: Kyle Mestery <mestery@mestery.com>
  • Loading branch information
mestery authored and glimchb committed Aug 8, 2022
1 parent 9cd0996 commit 93bd8c7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions server/ipsec.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,30 @@ func (s *server) IPsecGet(ctx context.Context, in *pb.IPsecGetRequest) (*pb.IPse
reqId := in.GetId().GetValue()
log.Printf("IPsecGet: Received: %v", reqId)

// Retreive from Redis
val, err := rdb.Get(ctx, reqId).Result()
if err != nil {
panic(err)
}
p_blob, err := base64.StdEncoding.DecodeString(val)
if err != nil {
log.Fatal("Cannot decode data")
}
ipsec_req := &pb.IPsecCreateRequest{}
err = proto.Unmarshal(p_blob, ipsec_req)
if err != nil {
log.Fatal("Cannot unmarshal data")
}

log.Printf("Dumping unmarshaled protobuf\n%v\n", ipsec_req)

ip_ret := pb.IPsecGetResponse {
Id: &pb.Uuid {
Value: in.GetId().GetValue(),
},
Tunnel: ipsec_req.Tunnel,
Policy: ipsec_req.Policy,
Sa: ipsec_req.Sa,
}

return &ip_ret, nil
Expand Down

0 comments on commit 93bd8c7

Please sign in to comment.