From 5d4b972b9a03355aadd57c8312423ab4e19fa358 Mon Sep 17 00:00:00 2001 From: Benjamin Bengfort Date: Wed, 10 Apr 2024 16:23:34 -0500 Subject: [PATCH] rVASP Status Check --- .github/workflows/containers.yml | 99 ++------ cmd/rvasp/main.go | 31 +++ pkg/rvasp/pb/v1/api.pb.go | 378 ++++++++++++++++++++++++------- pkg/rvasp/pb/v1/api_grpc.pb.go | 37 +++ pkg/rvasp/peer.go | 2 +- pkg/rvasp/rvasp.go | 17 ++ pkg/version.go | 4 +- proto/rvasp/v1/api.proto | 20 ++ 8 files changed, 428 insertions(+), 160 deletions(-) diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml index abf9f43..6677fc3 100644 --- a/.github/workflows/containers.yml +++ b/.github/workflows/containers.yml @@ -21,16 +21,16 @@ jobs: steps: - name: Checkout Code uses: actions/checkout@v3 - + - name: Set Envrionment id: vars run: | - echo "::set-output name=tag::${GITHUB_REF#refs/*/}" - echo "::set-output name=revision::$(git rev-parse --short HEAD)" + echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + echo "revision=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - name: Docker Metadata id: meta - uses: docker/metadata-action@v3 + uses: docker/metadata-action@v4 with: images: | trisa/rvasp @@ -40,24 +40,24 @@ jobs: type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=sha,prefix=,suffix=,format=short - + - name: Setup QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v2 - name: Setup Docker Buildx id: buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 - name: Login to DockerHub if: github.event_name != 'pull_request' - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to GCR if: github.event_name != 'pull_request' - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: registry: gcr.io username: _json_key @@ -65,7 +65,7 @@ jobs: - name: Build and push id: docker_build - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: # context and Dockerfile - should be configured for each image context: . @@ -75,82 +75,23 @@ jobs: labels: ${{ steps.meta.outputs.labels }} build-args: | GIT_REVISION=${{ steps.vars.outputs.revision }} - openvasp: - name: openvasp - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v3 - - - name: Set Envrionment - id: vars - run: | - echo "::set-output name=tag::${GITHUB_REF#refs/*/}" - echo "::set-output name=revision::$(git rev-parse --short HEAD)" - - - name: Docker Metadata - id: meta - uses: docker/metadata-action@v3 - with: - images: | - trisa/openvasp - gcr.io/trisa-gds/openvasp - tags: | - type=semver,pattern={{raw}} - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=sha,prefix=,suffix=,format=short - - - name: Setup QEMU - uses: docker/setup-qemu-action@v1 - - - name: Setup Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - - name: Login to DockerHub - if: github.event_name == 'pull_request' - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Login to GCR - if: github.event_name == 'pull_request' - uses: docker/login-action@v1 - with: - registry: gcr.io - username: _json_key - password: ${{ secrets.GCR_JSON_KEY }} - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v2 - with: - # context and Dockerfile - should be configured for each image - context: . - file: ./containers/openvasp/Dockerfile - push: ${{ github.event_name == 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - GIT_REVISION=${{ steps.vars.outputs.revision }} migrate: name: migrate runs-on: ubuntu-latest steps: - name: Checkout Code uses: actions/checkout@v3 - + - name: Set Envrionment id: vars run: | - echo "::set-output name=tag::${GITHUB_REF#refs/*/}" - echo "::set-output name=revision::$(git rev-parse --short HEAD)" + echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + echo "revision=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - name: Docker Metadata id: meta - uses: docker/metadata-action@v3 + uses: docker/metadata-action@v4 with: images: | trisa/rvasp-migrate @@ -160,24 +101,24 @@ jobs: type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=sha,prefix=,suffix=,format=short - + - name: Setup QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v2 - name: Setup Docker Buildx id: buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 - name: Login to DockerHub if: github.event_name != 'pull_request' - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to GCR if: github.event_name != 'pull_request' - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: registry: gcr.io username: _json_key @@ -185,7 +126,7 @@ jobs: - name: Build and push id: docker_build - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: # context and Dockerfile - should be configured for each image context: . diff --git a/cmd/rvasp/main.go b/cmd/rvasp/main.go index 78d39bd..622c67d 100644 --- a/cmd/rvasp/main.go +++ b/cmd/rvasp/main.go @@ -202,6 +202,20 @@ func main() { }, }, }, + { + Name: "status", + Usage: "get the current rVASP status and certificate info", + Category: "client", + Action: rvaspStatus, + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "e, endpoint", + Usage: "the address and port to connect to the server on", + Value: "localhost:4434", + EnvVar: "RVASP_ADDR", + }, + }, + }, } app.Run(os.Args) @@ -459,6 +473,23 @@ func stream(c *cli.Context) (err error) { } } +func rvaspStatus(c *cli.Context) (err error) { + client, err := makeClient(c) + if err != nil { + return cli.NewExitError(err, 1) + } + + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + var status *pb.ServerStatus + if status, err = client.Status(ctx, &pb.Empty{}); err != nil { + return cli.NewExitError(err, 1) + } + + return printJSON(status) +} + // helper function to create the GRPC client with default options func makeClient(c *cli.Context) (_ pb.TRISAIntegrationClient, err error) { var opts []grpc.DialOption diff --git a/pkg/rvasp/pb/v1/api.pb.go b/pkg/rvasp/pb/v1/api.pb.go index a1f63b6..fde50bf 100644 --- a/pkg/rvasp/pb/v1/api.pb.go +++ b/pkg/rvasp/pb/v1/api.pb.go @@ -200,6 +200,61 @@ func (MessageCategory) EnumDescriptor() ([]byte, []int) { return file_rvasp_v1_api_proto_rawDescGZIP(), []int{2} } +type ServerStatus_Status int32 + +const ( + ServerStatus_UNKNOWN ServerStatus_Status = 0 + ServerStatus_ONLINE ServerStatus_Status = 1 + ServerStatus_MAINTENANCE ServerStatus_Status = 2 + ServerStatus_UNHEALTHY ServerStatus_Status = 3 + ServerStatus_OFFLINE ServerStatus_Status = 4 +) + +// Enum value maps for ServerStatus_Status. +var ( + ServerStatus_Status_name = map[int32]string{ + 0: "UNKNOWN", + 1: "ONLINE", + 2: "MAINTENANCE", + 3: "UNHEALTHY", + 4: "OFFLINE", + } + ServerStatus_Status_value = map[string]int32{ + "UNKNOWN": 0, + "ONLINE": 1, + "MAINTENANCE": 2, + "UNHEALTHY": 3, + "OFFLINE": 4, + } +) + +func (x ServerStatus_Status) Enum() *ServerStatus_Status { + p := new(ServerStatus_Status) + *p = x + return p +} + +func (x ServerStatus_Status) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ServerStatus_Status) Descriptor() protoreflect.EnumDescriptor { + return file_rvasp_v1_api_proto_enumTypes[3].Descriptor() +} + +func (ServerStatus_Status) Type() protoreflect.EnumType { + return &file_rvasp_v1_api_proto_enumTypes[3] +} + +func (x ServerStatus_Status) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ServerStatus_Status.Descriptor instead. +func (ServerStatus_Status) EnumDescriptor() ([]byte, []int) { + return file_rvasp_v1_api_proto_rawDescGZIP(), []int{10, 0} +} + // Allows for standardized error handling for demo purposes. type Error struct { state protoimpl.MessageState @@ -999,6 +1054,123 @@ func (*Message_Transfer) isMessage_Reply() {} func (*Message_Account) isMessage_Reply() {} +type Empty struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *Empty) Reset() { + *x = Empty{} + if protoimpl.UnsafeEnabled { + mi := &file_rvasp_v1_api_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Empty) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Empty) ProtoMessage() {} + +func (x *Empty) ProtoReflect() protoreflect.Message { + mi := &file_rvasp_v1_api_proto_msgTypes[9] + 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 Empty.ProtoReflect.Descriptor instead. +func (*Empty) Descriptor() ([]byte, []int) { + return file_rvasp_v1_api_proto_rawDescGZIP(), []int{9} +} + +type ServerStatus struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Status ServerStatus_Status `protobuf:"varint,1,opt,name=status,proto3,enum=rvasp.v1.ServerStatus_Status" json:"status,omitempty"` + Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` + CommonName string `protobuf:"bytes,3,opt,name=common_name,json=commonName,proto3" json:"common_name,omitempty"` + NotBefore string `protobuf:"bytes,4,opt,name=not_before,json=notBefore,proto3" json:"not_before,omitempty"` + NotAfter string `protobuf:"bytes,5,opt,name=not_after,json=notAfter,proto3" json:"not_after,omitempty"` +} + +func (x *ServerStatus) Reset() { + *x = ServerStatus{} + if protoimpl.UnsafeEnabled { + mi := &file_rvasp_v1_api_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ServerStatus) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServerStatus) ProtoMessage() {} + +func (x *ServerStatus) ProtoReflect() protoreflect.Message { + mi := &file_rvasp_v1_api_proto_msgTypes[10] + 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 ServerStatus.ProtoReflect.Descriptor instead. +func (*ServerStatus) Descriptor() ([]byte, []int) { + return file_rvasp_v1_api_proto_rawDescGZIP(), []int{10} +} + +func (x *ServerStatus) GetStatus() ServerStatus_Status { + if x != nil { + return x.Status + } + return ServerStatus_UNKNOWN +} + +func (x *ServerStatus) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +func (x *ServerStatus) GetCommonName() string { + if x != nil { + return x.CommonName + } + return "" +} + +func (x *ServerStatus) GetNotBefore() string { + if x != nil { + return x.NotBefore + } + return "" +} + +func (x *ServerStatus) GetNotAfter() string { + if x != nil { + return x.NotAfter + } + return "" +} + var File_rvasp_v1_api_proto protoreflect.FileDescriptor var file_rvasp_v1_api_proto_rawDesc = []byte{ @@ -1113,47 +1285,67 @@ var file_rvasp_v1_api_proto_rawDesc = []byte{ 0x32, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x72, 0x76, 0x61, 0x73, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x48, 0x00, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x42, 0x07, 0x0a, 0x05, 0x72, 0x65, 0x70, 0x6c, 0x79, 0x2a, 0xd5, 0x01, 0x0a, - 0x10, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x10, 0x00, 0x12, 0x12, - 0x0a, 0x0e, 0x41, 0x57, 0x41, 0x49, 0x54, 0x49, 0x4e, 0x47, 0x5f, 0x52, 0x45, 0x50, 0x4c, 0x59, - 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x50, 0x45, 0x4e, 0x44, 0x49, 0x4e, 0x47, 0x5f, 0x53, 0x45, - 0x4e, 0x54, 0x10, 0x02, 0x12, 0x1a, 0x0a, 0x16, 0x41, 0x57, 0x41, 0x49, 0x54, 0x49, 0x4e, 0x47, - 0x5f, 0x46, 0x55, 0x4c, 0x4c, 0x5f, 0x54, 0x52, 0x41, 0x4e, 0x53, 0x46, 0x45, 0x52, 0x10, 0x03, - 0x12, 0x14, 0x0a, 0x10, 0x50, 0x45, 0x4e, 0x44, 0x49, 0x4e, 0x47, 0x5f, 0x52, 0x45, 0x43, 0x45, - 0x49, 0x56, 0x45, 0x44, 0x10, 0x04, 0x12, 0x18, 0x0a, 0x14, 0x50, 0x45, 0x4e, 0x44, 0x49, 0x4e, - 0x47, 0x5f, 0x41, 0x43, 0x4b, 0x4e, 0x4f, 0x57, 0x4c, 0x45, 0x44, 0x47, 0x45, 0x44, 0x10, 0x05, - 0x12, 0x0c, 0x0a, 0x08, 0x41, 0x43, 0x43, 0x45, 0x50, 0x54, 0x45, 0x44, 0x10, 0x06, 0x12, 0x0a, - 0x0a, 0x06, 0x46, 0x41, 0x49, 0x4c, 0x45, 0x44, 0x10, 0x07, 0x12, 0x0b, 0x0a, 0x07, 0x45, 0x58, - 0x50, 0x49, 0x52, 0x45, 0x44, 0x10, 0x08, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x45, 0x4a, 0x45, 0x43, - 0x54, 0x45, 0x44, 0x10, 0x09, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, 0x4d, 0x50, 0x4c, 0x45, 0x54, - 0x45, 0x44, 0x10, 0x0a, 0x2a, 0x2b, 0x0a, 0x03, 0x52, 0x50, 0x43, 0x12, 0x09, 0x0a, 0x05, 0x4e, - 0x4f, 0x52, 0x50, 0x43, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x54, 0x52, 0x41, 0x4e, 0x53, 0x46, - 0x45, 0x52, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x41, 0x43, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x10, - 0x02, 0x2a, 0x53, 0x0a, 0x0f, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x43, 0x61, 0x74, 0x65, - 0x67, 0x6f, 0x72, 0x79, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x45, 0x44, 0x47, 0x45, 0x52, 0x10, 0x00, - 0x12, 0x0b, 0x0a, 0x07, 0x54, 0x52, 0x49, 0x53, 0x41, 0x44, 0x53, 0x10, 0x01, 0x12, 0x0c, 0x0a, - 0x08, 0x54, 0x52, 0x49, 0x53, 0x41, 0x50, 0x32, 0x50, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x42, - 0x4c, 0x4f, 0x43, 0x4b, 0x43, 0x48, 0x41, 0x49, 0x4e, 0x10, 0x03, 0x12, 0x09, 0x0a, 0x05, 0x45, - 0x52, 0x52, 0x4f, 0x52, 0x10, 0x04, 0x32, 0x44, 0x0a, 0x09, 0x54, 0x52, 0x49, 0x53, 0x41, 0x44, - 0x65, 0x6d, 0x6f, 0x12, 0x37, 0x0a, 0x0b, 0x4c, 0x69, 0x76, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x73, 0x12, 0x11, 0x2e, 0x72, 0x76, 0x61, 0x73, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x1a, 0x11, 0x2e, 0x72, 0x76, 0x61, 0x73, 0x70, 0x2e, 0x76, 0x31, - 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x28, 0x01, 0x30, 0x01, 0x32, 0x95, 0x01, 0x0a, - 0x10, 0x54, 0x52, 0x49, 0x53, 0x41, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x12, 0x3e, 0x0a, 0x08, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x12, 0x19, 0x2e, - 0x72, 0x76, 0x61, 0x73, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65, - 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x76, 0x61, 0x73, 0x70, - 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x52, 0x65, 0x70, 0x6c, - 0x79, 0x12, 0x41, 0x0a, 0x0d, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x12, 0x18, 0x2e, 0x72, 0x76, 0x61, 0x73, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, - 0x76, 0x61, 0x73, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, - 0x65, 0x70, 0x6c, 0x79, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x74, 0x72, 0x69, 0x73, 0x61, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2f, 0x74, - 0x65, 0x73, 0x74, 0x6e, 0x65, 0x74, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x72, 0x76, 0x61, 0x73, 0x70, - 0x2f, 0x70, 0x62, 0x2f, 0x76, 0x31, 0x3b, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x75, 0x6e, 0x74, 0x42, 0x07, 0x0a, 0x05, 0x72, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x07, 0x0a, 0x05, + 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x8c, 0x02, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x35, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1d, 0x2e, 0x72, 0x76, 0x61, 0x73, 0x70, 0x2e, 0x76, + 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, + 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, + 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x6f, + 0x6d, 0x6d, 0x6f, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x6e, 0x6f, 0x74, 0x5f, + 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x6f, + 0x74, 0x42, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x6f, 0x74, 0x5f, 0x61, + 0x66, 0x74, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x6f, 0x74, 0x41, + 0x66, 0x74, 0x65, 0x72, 0x22, 0x4e, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0b, + 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4f, + 0x4e, 0x4c, 0x49, 0x4e, 0x45, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x4d, 0x41, 0x49, 0x4e, 0x54, + 0x45, 0x4e, 0x41, 0x4e, 0x43, 0x45, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x55, 0x4e, 0x48, 0x45, + 0x41, 0x4c, 0x54, 0x48, 0x59, 0x10, 0x03, 0x12, 0x0b, 0x0a, 0x07, 0x4f, 0x46, 0x46, 0x4c, 0x49, + 0x4e, 0x45, 0x10, 0x04, 0x2a, 0xd5, 0x01, 0x0a, 0x10, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x49, 0x4e, 0x56, + 0x41, 0x4c, 0x49, 0x44, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x57, 0x41, 0x49, 0x54, 0x49, + 0x4e, 0x47, 0x5f, 0x52, 0x45, 0x50, 0x4c, 0x59, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x50, 0x45, + 0x4e, 0x44, 0x49, 0x4e, 0x47, 0x5f, 0x53, 0x45, 0x4e, 0x54, 0x10, 0x02, 0x12, 0x1a, 0x0a, 0x16, + 0x41, 0x57, 0x41, 0x49, 0x54, 0x49, 0x4e, 0x47, 0x5f, 0x46, 0x55, 0x4c, 0x4c, 0x5f, 0x54, 0x52, + 0x41, 0x4e, 0x53, 0x46, 0x45, 0x52, 0x10, 0x03, 0x12, 0x14, 0x0a, 0x10, 0x50, 0x45, 0x4e, 0x44, + 0x49, 0x4e, 0x47, 0x5f, 0x52, 0x45, 0x43, 0x45, 0x49, 0x56, 0x45, 0x44, 0x10, 0x04, 0x12, 0x18, + 0x0a, 0x14, 0x50, 0x45, 0x4e, 0x44, 0x49, 0x4e, 0x47, 0x5f, 0x41, 0x43, 0x4b, 0x4e, 0x4f, 0x57, + 0x4c, 0x45, 0x44, 0x47, 0x45, 0x44, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x41, 0x43, 0x43, 0x45, + 0x50, 0x54, 0x45, 0x44, 0x10, 0x06, 0x12, 0x0a, 0x0a, 0x06, 0x46, 0x41, 0x49, 0x4c, 0x45, 0x44, + 0x10, 0x07, 0x12, 0x0b, 0x0a, 0x07, 0x45, 0x58, 0x50, 0x49, 0x52, 0x45, 0x44, 0x10, 0x08, 0x12, + 0x0c, 0x0a, 0x08, 0x52, 0x45, 0x4a, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x09, 0x12, 0x0d, 0x0a, + 0x09, 0x43, 0x4f, 0x4d, 0x50, 0x4c, 0x45, 0x54, 0x45, 0x44, 0x10, 0x0a, 0x2a, 0x2b, 0x0a, 0x03, + 0x52, 0x50, 0x43, 0x12, 0x09, 0x0a, 0x05, 0x4e, 0x4f, 0x52, 0x50, 0x43, 0x10, 0x00, 0x12, 0x0c, + 0x0a, 0x08, 0x54, 0x52, 0x41, 0x4e, 0x53, 0x46, 0x45, 0x52, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, + 0x41, 0x43, 0x43, 0x4f, 0x55, 0x4e, 0x54, 0x10, 0x02, 0x2a, 0x53, 0x0a, 0x0f, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x0a, 0x0a, 0x06, + 0x4c, 0x45, 0x44, 0x47, 0x45, 0x52, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x54, 0x52, 0x49, 0x53, + 0x41, 0x44, 0x53, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x54, 0x52, 0x49, 0x53, 0x41, 0x50, 0x32, + 0x50, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x42, 0x4c, 0x4f, 0x43, 0x4b, 0x43, 0x48, 0x41, 0x49, + 0x4e, 0x10, 0x03, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x04, 0x32, 0x44, + 0x0a, 0x09, 0x54, 0x52, 0x49, 0x53, 0x41, 0x44, 0x65, 0x6d, 0x6f, 0x12, 0x37, 0x0a, 0x0b, 0x4c, + 0x69, 0x76, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x73, 0x12, 0x11, 0x2e, 0x72, 0x76, 0x61, + 0x73, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x1a, 0x11, 0x2e, + 0x72, 0x76, 0x61, 0x73, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x28, 0x01, 0x30, 0x01, 0x32, 0xc8, 0x01, 0x0a, 0x10, 0x54, 0x52, 0x49, 0x53, 0x41, 0x49, 0x6e, + 0x74, 0x65, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3e, 0x0a, 0x08, 0x54, 0x72, 0x61, + 0x6e, 0x73, 0x66, 0x65, 0x72, 0x12, 0x19, 0x2e, 0x72, 0x76, 0x61, 0x73, 0x70, 0x2e, 0x76, 0x31, + 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x17, 0x2e, 0x72, 0x76, 0x61, 0x73, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, 0x6e, + 0x73, 0x66, 0x65, 0x72, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x41, 0x0a, 0x0d, 0x41, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x2e, 0x72, 0x76, 0x61, + 0x73, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x76, 0x61, 0x73, 0x70, 0x2e, 0x76, 0x31, 0x2e, + 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x31, 0x0a, 0x06, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0f, 0x2e, 0x72, 0x76, 0x61, 0x73, 0x70, 0x2e, 0x76, + 0x31, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x72, 0x76, 0x61, 0x73, 0x70, 0x2e, + 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, + 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x72, + 0x69, 0x73, 0x61, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x6e, 0x65, + 0x74, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x72, 0x76, 0x61, 0x73, 0x70, 0x2f, 0x70, 0x62, 0x2f, 0x76, + 0x31, 0x3b, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1168,48 +1360,54 @@ func file_rvasp_v1_api_proto_rawDescGZIP() []byte { return file_rvasp_v1_api_proto_rawDescData } -var file_rvasp_v1_api_proto_enumTypes = make([]protoimpl.EnumInfo, 3) -var file_rvasp_v1_api_proto_msgTypes = make([]protoimpl.MessageInfo, 9) +var file_rvasp_v1_api_proto_enumTypes = make([]protoimpl.EnumInfo, 4) +var file_rvasp_v1_api_proto_msgTypes = make([]protoimpl.MessageInfo, 11) var file_rvasp_v1_api_proto_goTypes = []interface{}{ - (TransactionState)(0), // 0: rvasp.v1.TransactionState - (RPC)(0), // 1: rvasp.v1.RPC - (MessageCategory)(0), // 2: rvasp.v1.MessageCategory - (*Error)(nil), // 3: rvasp.v1.Error - (*Account)(nil), // 4: rvasp.v1.Account - (*Transaction)(nil), // 5: rvasp.v1.Transaction - (*TransferRequest)(nil), // 6: rvasp.v1.TransferRequest - (*TransferReply)(nil), // 7: rvasp.v1.TransferReply - (*AccountRequest)(nil), // 8: rvasp.v1.AccountRequest - (*AccountReply)(nil), // 9: rvasp.v1.AccountReply - (*Command)(nil), // 10: rvasp.v1.Command - (*Message)(nil), // 11: rvasp.v1.Message + (TransactionState)(0), // 0: rvasp.v1.TransactionState + (RPC)(0), // 1: rvasp.v1.RPC + (MessageCategory)(0), // 2: rvasp.v1.MessageCategory + (ServerStatus_Status)(0), // 3: rvasp.v1.ServerStatus.Status + (*Error)(nil), // 4: rvasp.v1.Error + (*Account)(nil), // 5: rvasp.v1.Account + (*Transaction)(nil), // 6: rvasp.v1.Transaction + (*TransferRequest)(nil), // 7: rvasp.v1.TransferRequest + (*TransferReply)(nil), // 8: rvasp.v1.TransferReply + (*AccountRequest)(nil), // 9: rvasp.v1.AccountRequest + (*AccountReply)(nil), // 10: rvasp.v1.AccountReply + (*Command)(nil), // 11: rvasp.v1.Command + (*Message)(nil), // 12: rvasp.v1.Message + (*Empty)(nil), // 13: rvasp.v1.Empty + (*ServerStatus)(nil), // 14: rvasp.v1.ServerStatus } var file_rvasp_v1_api_proto_depIdxs = []int32{ - 4, // 0: rvasp.v1.Transaction.originator:type_name -> rvasp.v1.Account - 4, // 1: rvasp.v1.Transaction.beneficiary:type_name -> rvasp.v1.Account + 5, // 0: rvasp.v1.Transaction.originator:type_name -> rvasp.v1.Account + 5, // 1: rvasp.v1.Transaction.beneficiary:type_name -> rvasp.v1.Account 0, // 2: rvasp.v1.Transaction.state:type_name -> rvasp.v1.TransactionState - 3, // 3: rvasp.v1.TransferReply.error:type_name -> rvasp.v1.Error - 5, // 4: rvasp.v1.TransferReply.transaction:type_name -> rvasp.v1.Transaction - 3, // 5: rvasp.v1.AccountReply.error:type_name -> rvasp.v1.Error - 5, // 6: rvasp.v1.AccountReply.transactions:type_name -> rvasp.v1.Transaction + 4, // 3: rvasp.v1.TransferReply.error:type_name -> rvasp.v1.Error + 6, // 4: rvasp.v1.TransferReply.transaction:type_name -> rvasp.v1.Transaction + 4, // 5: rvasp.v1.AccountReply.error:type_name -> rvasp.v1.Error + 6, // 6: rvasp.v1.AccountReply.transactions:type_name -> rvasp.v1.Transaction 1, // 7: rvasp.v1.Command.type:type_name -> rvasp.v1.RPC - 6, // 8: rvasp.v1.Command.transfer:type_name -> rvasp.v1.TransferRequest - 8, // 9: rvasp.v1.Command.account:type_name -> rvasp.v1.AccountRequest + 7, // 8: rvasp.v1.Command.transfer:type_name -> rvasp.v1.TransferRequest + 9, // 9: rvasp.v1.Command.account:type_name -> rvasp.v1.AccountRequest 1, // 10: rvasp.v1.Message.type:type_name -> rvasp.v1.RPC 2, // 11: rvasp.v1.Message.category:type_name -> rvasp.v1.MessageCategory - 7, // 12: rvasp.v1.Message.transfer:type_name -> rvasp.v1.TransferReply - 9, // 13: rvasp.v1.Message.account:type_name -> rvasp.v1.AccountReply - 10, // 14: rvasp.v1.TRISADemo.LiveUpdates:input_type -> rvasp.v1.Command - 6, // 15: rvasp.v1.TRISAIntegration.Transfer:input_type -> rvasp.v1.TransferRequest - 8, // 16: rvasp.v1.TRISAIntegration.AccountStatus:input_type -> rvasp.v1.AccountRequest - 11, // 17: rvasp.v1.TRISADemo.LiveUpdates:output_type -> rvasp.v1.Message - 7, // 18: rvasp.v1.TRISAIntegration.Transfer:output_type -> rvasp.v1.TransferReply - 9, // 19: rvasp.v1.TRISAIntegration.AccountStatus:output_type -> rvasp.v1.AccountReply - 17, // [17:20] is the sub-list for method output_type - 14, // [14:17] is the sub-list for method input_type - 14, // [14:14] is the sub-list for extension type_name - 14, // [14:14] is the sub-list for extension extendee - 0, // [0:14] is the sub-list for field type_name + 8, // 12: rvasp.v1.Message.transfer:type_name -> rvasp.v1.TransferReply + 10, // 13: rvasp.v1.Message.account:type_name -> rvasp.v1.AccountReply + 3, // 14: rvasp.v1.ServerStatus.status:type_name -> rvasp.v1.ServerStatus.Status + 11, // 15: rvasp.v1.TRISADemo.LiveUpdates:input_type -> rvasp.v1.Command + 7, // 16: rvasp.v1.TRISAIntegration.Transfer:input_type -> rvasp.v1.TransferRequest + 9, // 17: rvasp.v1.TRISAIntegration.AccountStatus:input_type -> rvasp.v1.AccountRequest + 13, // 18: rvasp.v1.TRISAIntegration.Status:input_type -> rvasp.v1.Empty + 12, // 19: rvasp.v1.TRISADemo.LiveUpdates:output_type -> rvasp.v1.Message + 8, // 20: rvasp.v1.TRISAIntegration.Transfer:output_type -> rvasp.v1.TransferReply + 10, // 21: rvasp.v1.TRISAIntegration.AccountStatus:output_type -> rvasp.v1.AccountReply + 14, // 22: rvasp.v1.TRISAIntegration.Status:output_type -> rvasp.v1.ServerStatus + 19, // [19:23] is the sub-list for method output_type + 15, // [15:19] is the sub-list for method input_type + 15, // [15:15] is the sub-list for extension type_name + 15, // [15:15] is the sub-list for extension extendee + 0, // [0:15] is the sub-list for field type_name } func init() { file_rvasp_v1_api_proto_init() } @@ -1326,6 +1524,30 @@ func file_rvasp_v1_api_proto_init() { return nil } } + file_rvasp_v1_api_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Empty); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rvasp_v1_api_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ServerStatus); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } file_rvasp_v1_api_proto_msgTypes[7].OneofWrappers = []interface{}{ (*Command_Transfer)(nil), @@ -1340,8 +1562,8 @@ func file_rvasp_v1_api_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_rvasp_v1_api_proto_rawDesc, - NumEnums: 3, - NumMessages: 9, + NumEnums: 4, + NumMessages: 11, NumExtensions: 0, NumServices: 2, }, diff --git a/pkg/rvasp/pb/v1/api_grpc.pb.go b/pkg/rvasp/pb/v1/api_grpc.pb.go index 812efc1..ece3149 100644 --- a/pkg/rvasp/pb/v1/api_grpc.pb.go +++ b/pkg/rvasp/pb/v1/api_grpc.pb.go @@ -143,6 +143,7 @@ var TRISADemo_ServiceDesc = grpc.ServiceDesc{ const ( TRISAIntegration_Transfer_FullMethodName = "/rvasp.v1.TRISAIntegration/Transfer" TRISAIntegration_AccountStatus_FullMethodName = "/rvasp.v1.TRISAIntegration/AccountStatus" + TRISAIntegration_Status_FullMethodName = "/rvasp.v1.TRISAIntegration/Status" ) // TRISAIntegrationClient is the client API for TRISAIntegration service. @@ -151,6 +152,7 @@ const ( type TRISAIntegrationClient interface { Transfer(ctx context.Context, in *TransferRequest, opts ...grpc.CallOption) (*TransferReply, error) AccountStatus(ctx context.Context, in *AccountRequest, opts ...grpc.CallOption) (*AccountReply, error) + Status(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*ServerStatus, error) } type tRISAIntegrationClient struct { @@ -179,12 +181,22 @@ func (c *tRISAIntegrationClient) AccountStatus(ctx context.Context, in *AccountR return out, nil } +func (c *tRISAIntegrationClient) Status(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*ServerStatus, error) { + out := new(ServerStatus) + err := c.cc.Invoke(ctx, TRISAIntegration_Status_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // TRISAIntegrationServer is the server API for TRISAIntegration service. // All implementations must embed UnimplementedTRISAIntegrationServer // for forward compatibility type TRISAIntegrationServer interface { Transfer(context.Context, *TransferRequest) (*TransferReply, error) AccountStatus(context.Context, *AccountRequest) (*AccountReply, error) + Status(context.Context, *Empty) (*ServerStatus, error) mustEmbedUnimplementedTRISAIntegrationServer() } @@ -198,6 +210,9 @@ func (UnimplementedTRISAIntegrationServer) Transfer(context.Context, *TransferRe func (UnimplementedTRISAIntegrationServer) AccountStatus(context.Context, *AccountRequest) (*AccountReply, error) { return nil, status.Errorf(codes.Unimplemented, "method AccountStatus not implemented") } +func (UnimplementedTRISAIntegrationServer) Status(context.Context, *Empty) (*ServerStatus, error) { + return nil, status.Errorf(codes.Unimplemented, "method Status not implemented") +} func (UnimplementedTRISAIntegrationServer) mustEmbedUnimplementedTRISAIntegrationServer() {} // UnsafeTRISAIntegrationServer may be embedded to opt out of forward compatibility for this service. @@ -247,6 +262,24 @@ func _TRISAIntegration_AccountStatus_Handler(srv interface{}, ctx context.Contex return interceptor(ctx, in, info, handler) } +func _TRISAIntegration_Status_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TRISAIntegrationServer).Status(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: TRISAIntegration_Status_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TRISAIntegrationServer).Status(ctx, req.(*Empty)) + } + return interceptor(ctx, in, info, handler) +} + // TRISAIntegration_ServiceDesc is the grpc.ServiceDesc for TRISAIntegration service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -262,6 +295,10 @@ var TRISAIntegration_ServiceDesc = grpc.ServiceDesc{ MethodName: "AccountStatus", Handler: _TRISAIntegration_AccountStatus_Handler, }, + { + MethodName: "Status", + Handler: _TRISAIntegration_Status_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "rvasp/v1/api.proto", diff --git a/pkg/rvasp/peer.go b/pkg/rvasp/peer.go index 94d13b6..ae2a8ce 100644 --- a/pkg/rvasp/peer.go +++ b/pkg/rvasp/peer.go @@ -44,7 +44,7 @@ func (s *Server) fetchSigningKey(peer *peers.Peer) (key *rsa.PublicKey, err erro // send key exchange activity to network activity handler activity.KeyExchange().Add() // If no key is available, perform a key exchange with the remote peer - if peer.ExchangeKeys(true); err != nil { + if _, err = peer.ExchangeKeys(true); err != nil { log.Warn().Str("common_name", peer.String()).Err(err).Msg("could not exchange keys with remote peer") return nil, fmt.Errorf("could not exchange keys with remote peer: %s", err) } diff --git a/pkg/rvasp/rvasp.go b/pkg/rvasp/rvasp.go index efc42cf..312f249 100644 --- a/pkg/rvasp/rvasp.go +++ b/pkg/rvasp/rvasp.go @@ -3,6 +3,7 @@ package rvasp import ( "context" "crypto/rsa" + "crypto/x509" "encoding/json" "errors" "fmt" @@ -1134,3 +1135,19 @@ func (s *Server) handleTransaction(client string, req *pb.Command) (err error) { return s.updates.Send(client, rep) } + +func (s *Server) Status(context.Context, *pb.Empty) (_ *pb.ServerStatus, err error) { + var cert *x509.Certificate + if cert, err = s.trisa.certs.GetLeafCertificate(); err != nil { + log.Warn().Err(err).Msg("could not get trisa leaf certificate") + return nil, status.Error(codes.FailedPrecondition, "could not parse trisa certificate") + } + + return &pb.ServerStatus{ + Status: pb.ServerStatus_ONLINE, + Version: pkg.Version(), + CommonName: cert.Subject.CommonName, + NotBefore: cert.NotBefore.Format(time.RFC3339), + NotAfter: cert.NotAfter.Format(time.RFC3339), + }, nil +} diff --git a/pkg/version.go b/pkg/version.go index d2987a3..f828102 100644 --- a/pkg/version.go +++ b/pkg/version.go @@ -5,8 +5,8 @@ import "fmt" // Version component constants for the current build. const ( VersionMajor = 1 - VersionMinor = 1 - VersionPatch = 3 + VersionMinor = 2 + VersionPatch = 0 VersionReleaseLevel = "" VersionReleaseNumber = 0 ) diff --git a/proto/rvasp/v1/api.proto b/proto/rvasp/v1/api.proto index 4334be4..0e008cb 100644 --- a/proto/rvasp/v1/api.proto +++ b/proto/rvasp/v1/api.proto @@ -20,6 +20,7 @@ service TRISADemo { service TRISAIntegration { rpc Transfer (TransferRequest) returns (TransferReply); rpc AccountStatus (AccountRequest) returns (AccountReply); + rpc Status (Empty) returns (ServerStatus); } // Allows for standardized error handling for demo purposes. @@ -158,3 +159,22 @@ message Message { } } + +message Empty{} + + +message ServerStatus { + enum Status { + UNKNOWN = 0; + ONLINE = 1; + MAINTENANCE = 2; + UNHEALTHY = 3; + OFFLINE = 4; + } + + Status status = 1; + string version = 2; + string common_name = 3; + string not_before = 4; + string not_after = 5; +} \ No newline at end of file