From e04737b0246b86e9ffb803e71b96ad98a050c159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nico=20Waldisp=C3=BChl?= Date: Sat, 15 Jul 2023 22:49:42 +0200 Subject: [PATCH] Adds version information to the software: - adds version flag which is printed on startup - adds build information (version, commit hash) to grpc server info structure --- .github/workflows/build.yml | 3 + .github/workflows/publish.yml | 3 + Dockerfile | 5 + buildinfo/buildinfo.go | 29 ++++++ buildinfo/commit.txt | 1 + buildinfo/get_commit.sh | 6 ++ buildinfo/get_version.sh | 6 ++ buildinfo/version.txt | 1 + cmd/serve/main.go | 6 +- internal/services/server_service.go | 2 + proto/buildinfo.proto | 10 ++ proto/proto/buildinfo.pb.go | 154 ++++++++++++++++++++++++++++ proto/proto/server.pb.go | 131 ++++++++++++----------- proto/server.proto | 2 + website/src/sdk/buildinfo_pb.ts | 112 ++++++++++++++++++++ website/src/sdk/server_pb.ts | 31 ++++++ 16 files changed, 443 insertions(+), 59 deletions(-) create mode 100644 buildinfo/buildinfo.go create mode 100644 buildinfo/commit.txt create mode 100644 buildinfo/get_commit.sh create mode 100644 buildinfo/get_version.sh create mode 100644 buildinfo/version.txt create mode 100644 proto/buildinfo.proto create mode 100644 proto/proto/buildinfo.pb.go create mode 100644 website/src/sdk/buildinfo_pb.ts diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fa223938..a352dcd9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,6 +43,9 @@ jobs: cache-to: type=gha,mode=max tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=${{ github.head_ref }} + COMMIT=${{ github.sha }} - name: Inspect Docker image run: docker image inspect ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 28307025..59daa8e7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -54,3 +54,6 @@ jobs: cache-to: type=gha,mode=max tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=${{ github.head_ref }} + COMMIT=${{ github.sha }} diff --git a/Dockerfile b/Dockerfile index 97ac0573..660f6dae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,8 @@ FROM golang:1.20.5-alpine as server RUN apk add --no-cache gcc musl-dev WORKDIR /code ENV CGO_ENABLED=1 +ARG VERSION=development +ARG COMMIT="-" COPY ./go.mod ./ COPY ./go.sum ./ RUN go mod download @@ -21,6 +23,9 @@ COPY ./main.go ./main.go COPY ./cmd/ ./cmd/ COPY ./pkg/ ./pkg/ COPY ./internal/ ./internal/ +COPY ./buildinfo/ ./buildinfo/ +RUN echo "Using: Version: ${VERSION}, Commit: ${COMMIT}" +RUN go generate buildinfo/buildinfo.go RUN go build -o wg-access-server ### Server diff --git a/buildinfo/buildinfo.go b/buildinfo/buildinfo.go new file mode 100644 index 00000000..53e9ca79 --- /dev/null +++ b/buildinfo/buildinfo.go @@ -0,0 +1,29 @@ +package buildinfo + +import ( + "strings" + _ "embed" +) + +//go:generate sh get_version.sh +//go:embed version.txt +var VersionRaw string + +//go:generate sh get_commit.sh +//go:embed commit.txt +var CommitHashRaw string + +func Version() string { + return strings.TrimSpace(VersionRaw) +} + +func CommitHash() string { + return strings.TrimSpace(CommitHashRaw) +} + +func ShortCommitHash() string { + if 7 < len(CommitHash()) { + return CommitHash()[0:7] + } + return CommitHash() +} diff --git a/buildinfo/commit.txt b/buildinfo/commit.txt new file mode 100644 index 00000000..39cdd0de --- /dev/null +++ b/buildinfo/commit.txt @@ -0,0 +1 @@ +- diff --git a/buildinfo/get_commit.sh b/buildinfo/get_commit.sh new file mode 100644 index 00000000..e27ba305 --- /dev/null +++ b/buildinfo/get_commit.sh @@ -0,0 +1,6 @@ +#!/bin/sh +if [ -z "${COMMIT}" ]; then + echo "-" > commit.txt +else + echo "${COMMIT}" > commit.txt +fi diff --git a/buildinfo/get_version.sh b/buildinfo/get_version.sh new file mode 100644 index 00000000..8e49c6dc --- /dev/null +++ b/buildinfo/get_version.sh @@ -0,0 +1,6 @@ +#!/bin/sh +if [ -z "$VERSION" ] ; then + echo "development" > version.txt +else + echo "${VERSION}" > version.txt +fi diff --git a/buildinfo/version.txt b/buildinfo/version.txt new file mode 100644 index 00000000..23e31850 --- /dev/null +++ b/buildinfo/version.txt @@ -0,0 +1 @@ +development diff --git a/cmd/serve/main.go b/cmd/serve/main.go index 7f49d434..3ab5de22 100644 --- a/cmd/serve/main.go +++ b/cmd/serve/main.go @@ -33,6 +33,7 @@ import ( "github.com/freifunkMUC/wg-access-server/internal/storage" "github.com/freifunkMUC/wg-access-server/pkg/authnz" "github.com/freifunkMUC/wg-access-server/pkg/authnz/authconfig" + "github.com/freifunkMUC/wg-access-server/buildinfo" ) func Register(app *kingpin.Application) *servecmd { @@ -80,6 +81,9 @@ func (cmd *servecmd) Name() string { func (cmd *servecmd) Run() { conf := cmd.ReadConfig() + // Software banner + logrus.Infof("+++ wg-access-server %s (%s)", buildinfo.Version(), buildinfo.ShortCommitHash()) + // Get the server's IP addresses within the VPN var vpnip, vpnipv6 netip.Prefix var err error @@ -125,7 +129,7 @@ func (cmd *servecmd) Run() { defer wgimpl.Close() wg = wgimpl - logrus.Infof("Starting WireGuard server on :%d", conf.WireGuard.Port) + logrus.Infof("Starting WireGuard on :%d", conf.WireGuard.Port) wgconfig := &wgembed.ConfigFile{ Interface: wgembed.IfaceConfig{ diff --git a/internal/services/server_service.go b/internal/services/server_service.go index dc17225e..2eb57f89 100644 --- a/internal/services/server_service.go +++ b/internal/services/server_service.go @@ -13,6 +13,7 @@ import ( "github.com/freifunkMUC/wg-access-server/internal/network" "github.com/freifunkMUC/wg-access-server/pkg/authnz/authsession" "github.com/freifunkMUC/wg-access-server/proto/proto" + "github.com/freifunkMUC/wg-access-server/buildinfo" ) type ServerService struct { @@ -73,6 +74,7 @@ func (s *ServerService) Info(ctx context.Context, req *proto.InfoReq) (*proto.In ClientConfigDnsServers: clientConfigDnsServers(s.Config), ClientConfigDnsSearchDomain: s.Config.ClientConfig.DNSSearchDomain, ClientConfigMtu: int32(s.Config.ClientConfig.MTU), + BuildInfo: &proto.BuildInfo{Version: buildinfo.Version(), Commit: buildinfo.ShortCommitHash()}, }, nil } diff --git a/proto/buildinfo.proto b/proto/buildinfo.proto new file mode 100644 index 00000000..3249d87d --- /dev/null +++ b/proto/buildinfo.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; + +package proto; + +option go_package = "github.com/freifunkMUC/wg-access-server/proto/proto"; + +message BuildInfo { + string version = 1; + string commit = 2; +} diff --git a/proto/proto/buildinfo.pb.go b/proto/proto/buildinfo.pb.go new file mode 100644 index 00000000..a6a48887 --- /dev/null +++ b/proto/proto/buildinfo.pb.go @@ -0,0 +1,154 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.21.9 +// source: buildinfo.proto + +package proto + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type BuildInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` + Commit string `protobuf:"bytes,2,opt,name=commit,proto3" json:"commit,omitempty"` +} + +func (x *BuildInfo) Reset() { + *x = BuildInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_buildinfo_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BuildInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BuildInfo) ProtoMessage() {} + +func (x *BuildInfo) ProtoReflect() protoreflect.Message { + mi := &file_buildinfo_proto_msgTypes[0] + 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 BuildInfo.ProtoReflect.Descriptor instead. +func (*BuildInfo) Descriptor() ([]byte, []int) { + return file_buildinfo_proto_rawDescGZIP(), []int{0} +} + +func (x *BuildInfo) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +func (x *BuildInfo) GetCommit() string { + if x != nil { + return x.Commit + } + return "" +} + +var File_buildinfo_proto protoreflect.FileDescriptor + +var file_buildinfo_proto_rawDesc = []byte{ + 0x0a, 0x0f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x69, 0x6e, 0x66, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x3d, 0x0a, 0x09, 0x42, 0x75, 0x69, 0x6c, + 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, + 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x42, 0x35, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x72, 0x65, 0x69, 0x66, 0x75, 0x6e, 0x6b, 0x4d, 0x55, + 0x43, 0x2f, 0x77, 0x67, 0x2d, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x2d, 0x73, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_buildinfo_proto_rawDescOnce sync.Once + file_buildinfo_proto_rawDescData = file_buildinfo_proto_rawDesc +) + +func file_buildinfo_proto_rawDescGZIP() []byte { + file_buildinfo_proto_rawDescOnce.Do(func() { + file_buildinfo_proto_rawDescData = protoimpl.X.CompressGZIP(file_buildinfo_proto_rawDescData) + }) + return file_buildinfo_proto_rawDescData +} + +var file_buildinfo_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_buildinfo_proto_goTypes = []interface{}{ + (*BuildInfo)(nil), // 0: proto.BuildInfo +} +var file_buildinfo_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_buildinfo_proto_init() } +func file_buildinfo_proto_init() { + if File_buildinfo_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_buildinfo_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BuildInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_buildinfo_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_buildinfo_proto_goTypes, + DependencyIndexes: file_buildinfo_proto_depIdxs, + MessageInfos: file_buildinfo_proto_msgTypes, + }.Build() + File_buildinfo_proto = out.File + file_buildinfo_proto_rawDesc = nil + file_buildinfo_proto_goTypes = nil + file_buildinfo_proto_depIdxs = nil +} diff --git a/proto/proto/server.pb.go b/proto/proto/server.pb.go index a91e9b5a..eabcb7ff 100644 --- a/proto/proto/server.pb.go +++ b/proto/proto/server.pb.go @@ -80,6 +80,7 @@ type InfoRes struct { ClientConfigDnsServers string `protobuf:"bytes,13,opt,name=client_config_dns_servers,json=clientConfigDnsServers,proto3" json:"client_config_dns_servers,omitempty"` ClientConfigDnsSearchDomain string `protobuf:"bytes,14,opt,name=client_config_dns_search_domain,json=clientConfigDnsSearchDomain,proto3" json:"client_config_dns_search_domain,omitempty"` ClientConfigMtu int32 `protobuf:"varint,15,opt,name=client_config_mtu,json=clientConfigMtu,proto3" json:"client_config_mtu,omitempty"` + BuildInfo *BuildInfo `protobuf:"bytes,16,opt,name=build_info,json=buildInfo,proto3" json:"build_info,omitempty"` } func (x *InfoRes) Reset() { @@ -219,6 +220,13 @@ func (x *InfoRes) GetClientConfigMtu() int32 { return 0 } +func (x *InfoRes) GetBuildInfo() *BuildInfo { + if x != nil { + return x.BuildInfo + } + return nil +} + var File_server_proto protoreflect.FileDescriptor var file_server_proto_rawDesc = []byte{ @@ -227,57 +235,61 @@ var file_server_proto_rawDesc = []byte{ 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x09, 0x0a, 0x07, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, - 0x22, 0xa5, 0x05, 0x0a, 0x07, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, - 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x30, 0x0a, 0x04, 0x68, - 0x6f, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, - 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, - 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x6f, 0x72, - 0x74, 0x12, 0x1e, 0x0a, 0x0b, 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x76, 0x70, 0x6e, 0x5f, 0x69, 0x70, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x68, 0x6f, 0x73, 0x74, 0x56, 0x70, 0x6e, 0x49, - 0x70, 0x12, 0x29, 0x0a, 0x10, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x65, 0x6e, - 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x6d, 0x65, 0x74, - 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x19, 0x0a, 0x08, - 0x69, 0x73, 0x5f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, - 0x69, 0x73, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x6c, 0x6c, 0x6f, 0x77, - 0x65, 0x64, 0x5f, 0x69, 0x70, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x6c, - 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x49, 0x70, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x6e, 0x73, 0x5f, - 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x64, - 0x6e, 0x73, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x6e, 0x73, - 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, - 0x64, 0x6e, 0x73, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, - 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, - 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x47, 0x0a, 0x20, 0x69, 0x6e, 0x61, 0x63, 0x74, 0x69, - 0x76, 0x65, 0x5f, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x69, - 0x6f, 0x6e, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x1d, 0x69, 0x6e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, - 0x5a, 0x0a, 0x1c, 0x69, 0x6e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x64, 0x65, 0x76, 0x69, - 0x63, 0x65, 0x5f, 0x67, 0x72, 0x61, 0x63, 0x65, 0x5f, 0x70, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x18, - 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x52, 0x19, 0x69, 0x6e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, - 0x47, 0x72, 0x61, 0x63, 0x65, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x12, 0x39, 0x0a, 0x19, 0x63, - 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x64, 0x6e, 0x73, - 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x16, - 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x44, 0x6e, 0x73, 0x53, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x12, 0x44, 0x0a, 0x1f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, - 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x64, 0x6e, 0x73, 0x5f, 0x73, 0x65, 0x61, 0x72, - 0x63, 0x68, 0x5f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x1b, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x44, 0x6e, 0x73, - 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x2a, 0x0a, 0x11, - 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x6d, 0x74, - 0x75, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4d, 0x74, 0x75, 0x32, 0x32, 0x0a, 0x06, 0x53, 0x65, 0x72, 0x76, - 0x65, 0x72, 0x12, 0x28, 0x0a, 0x04, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x1a, 0x0e, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x22, 0x00, 0x42, 0x35, 0x5a, 0x33, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x72, 0x65, 0x69, 0x66, - 0x75, 0x6e, 0x6b, 0x4d, 0x55, 0x43, 0x2f, 0x77, 0x67, 0x2d, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, - 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x69, 0x6e, 0x66, 0x6f, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x09, 0x0a, 0x07, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, + 0x71, 0x22, 0xd6, 0x05, 0x0a, 0x07, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x12, 0x1d, 0x0a, + 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x30, 0x0a, 0x04, + 0x68, 0x6f, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, + 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x6f, + 0x72, 0x74, 0x12, 0x1e, 0x0a, 0x0b, 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x76, 0x70, 0x6e, 0x5f, 0x69, + 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x68, 0x6f, 0x73, 0x74, 0x56, 0x70, 0x6e, + 0x49, 0x70, 0x12, 0x29, 0x0a, 0x10, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x65, + 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x6d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x19, 0x0a, + 0x08, 0x69, 0x73, 0x5f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x07, 0x69, 0x73, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x6c, 0x6c, 0x6f, + 0x77, 0x65, 0x64, 0x5f, 0x69, 0x70, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, + 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x49, 0x70, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x6e, 0x73, + 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, + 0x64, 0x6e, 0x73, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x6e, + 0x73, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0a, 0x64, 0x6e, 0x73, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x66, + 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, + 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x47, 0x0a, 0x20, 0x69, 0x6e, 0x61, 0x63, 0x74, + 0x69, 0x76, 0x65, 0x5f, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x64, 0x65, 0x6c, 0x65, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x1d, 0x69, 0x6e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x44, 0x65, 0x76, 0x69, 0x63, + 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, + 0x12, 0x5a, 0x0a, 0x1c, 0x69, 0x6e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x64, 0x65, 0x76, + 0x69, 0x63, 0x65, 0x5f, 0x67, 0x72, 0x61, 0x63, 0x65, 0x5f, 0x70, 0x65, 0x72, 0x69, 0x6f, 0x64, + 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x52, 0x19, 0x69, 0x6e, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x44, 0x65, 0x76, 0x69, 0x63, + 0x65, 0x47, 0x72, 0x61, 0x63, 0x65, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x12, 0x39, 0x0a, 0x19, + 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x64, 0x6e, + 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x16, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x44, 0x6e, 0x73, + 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x12, 0x44, 0x0a, 0x1f, 0x63, 0x6c, 0x69, 0x65, 0x6e, + 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x64, 0x6e, 0x73, 0x5f, 0x73, 0x65, 0x61, + 0x72, 0x63, 0x68, 0x5f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x1b, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x44, 0x6e, + 0x73, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x2a, 0x0a, + 0x11, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x6d, + 0x74, 0x75, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4d, 0x74, 0x75, 0x12, 0x2f, 0x0a, 0x0a, 0x62, 0x75, 0x69, + 0x6c, 0x64, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x52, + 0x09, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x32, 0x32, 0x0a, 0x06, 0x53, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x12, 0x28, 0x0a, 0x04, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x1a, 0x0e, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x22, 0x00, 0x42, 0x35, + 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x72, 0x65, + 0x69, 0x66, 0x75, 0x6e, 0x6b, 0x4d, 0x55, 0x43, 0x2f, 0x77, 0x67, 0x2d, 0x61, 0x63, 0x63, 0x65, + 0x73, 0x73, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -298,17 +310,19 @@ var file_server_proto_goTypes = []interface{}{ (*InfoRes)(nil), // 1: proto.InfoRes (*wrapperspb.StringValue)(nil), // 2: google.protobuf.StringValue (*durationpb.Duration)(nil), // 3: google.protobuf.Duration + (*BuildInfo)(nil), // 4: proto.BuildInfo } var file_server_proto_depIdxs = []int32{ 2, // 0: proto.InfoRes.host:type_name -> google.protobuf.StringValue 3, // 1: proto.InfoRes.inactive_device_grace_period:type_name -> google.protobuf.Duration - 0, // 2: proto.Server.Info:input_type -> proto.InfoReq - 1, // 3: proto.Server.Info:output_type -> proto.InfoRes - 3, // [3:4] is the sub-list for method output_type - 2, // [2:3] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 4, // 2: proto.InfoRes.build_info:type_name -> proto.BuildInfo + 0, // 3: proto.Server.Info:input_type -> proto.InfoReq + 1, // 4: proto.Server.Info:output_type -> proto.InfoRes + 4, // [4:5] is the sub-list for method output_type + 3, // [3:4] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name } func init() { file_server_proto_init() } @@ -316,6 +330,7 @@ func file_server_proto_init() { if File_server_proto != nil { return } + file_buildinfo_proto_init() if !protoimpl.UnsafeEnabled { file_server_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*InfoReq); i { diff --git a/proto/server.proto b/proto/server.proto index 45ba2ad3..d56480be 100644 --- a/proto/server.proto +++ b/proto/server.proto @@ -6,6 +6,7 @@ option go_package = "github.com/freifunkMUC/wg-access-server/proto/proto"; import "google/protobuf/wrappers.proto"; import "google/protobuf/duration.proto"; +import "buildinfo.proto"; service Server { rpc Info(InfoReq) returns (InfoRes) {} @@ -31,4 +32,5 @@ message InfoRes { string client_config_dns_servers = 13; string client_config_dns_search_domain = 14; int32 client_config_mtu = 15; + proto.BuildInfo build_info = 16; } diff --git a/website/src/sdk/buildinfo_pb.ts b/website/src/sdk/buildinfo_pb.ts new file mode 100644 index 00000000..9adbf45e --- /dev/null +++ b/website/src/sdk/buildinfo_pb.ts @@ -0,0 +1,112 @@ +// Generated by protoc-gen-grpc-ts-web. DO NOT EDIT! +/* eslint-disable */ +/* tslint:disable */ + +import * as jspb from 'google-protobuf'; +import * as grpcWeb from 'grpc-web'; + + + + + + +export declare namespace BuildInfo { + export type AsObject = { + version: string, + commit: string, + } +} + +export class BuildInfo extends jspb.Message { + + private static repeatedFields_ = [ + + ]; + + constructor(data?: jspb.Message.MessageArray) { + super(); + jspb.Message.initialize(this, data || [], 0, -1, BuildInfo.repeatedFields_, null); + } + + + getVersion(): string {return jspb.Message.getFieldWithDefault(this, 1, ""); + } + + setVersion(value: string): void { + (jspb.Message as any).setProto3StringField(this, 1, value); + } + + getCommit(): string {return jspb.Message.getFieldWithDefault(this, 2, ""); + } + + setCommit(value: string): void { + (jspb.Message as any).setProto3StringField(this, 2, value); + } + + serializeBinary(): Uint8Array { + const writer = new jspb.BinaryWriter(); + BuildInfo.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + } + + toObject(): BuildInfo.AsObject { + let f: any; + return { + version: this.getVersion(), + commit: this.getCommit(), + }; + } + + static serializeBinaryToWriter(message: BuildInfo, writer: jspb.BinaryWriter): void { + const field1 = message.getVersion(); + if (field1.length > 0) { + writer.writeString(1, field1); + } + const field2 = message.getCommit(); + if (field2.length > 0) { + writer.writeString(2, field2); + } + } + + static deserializeBinary(bytes: Uint8Array): BuildInfo { + var reader = new jspb.BinaryReader(bytes); + var message = new BuildInfo(); + return BuildInfo.deserializeBinaryFromReader(message, reader); + } + + static deserializeBinaryFromReader(message: BuildInfo, reader: jspb.BinaryReader): BuildInfo { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + const field = reader.getFieldNumber(); + switch (field) { + case 1: + const field1 = reader.readString() + message.setVersion(field1); + break; + case 2: + const field2 = reader.readString() + message.setCommit(field2); + break; + default: + reader.skipField(); + break; + } + } + return message; + } + +} + + +function BuildInfoFromObject(obj: BuildInfo.AsObject | undefined): BuildInfo | undefined { + if (obj === undefined) { + return undefined; + } + const message = new BuildInfo(); + message.setVersion(obj.version); + message.setCommit(obj.commit); + return message; +} + diff --git a/website/src/sdk/server_pb.ts b/website/src/sdk/server_pb.ts index d6d7fe78..b28dc4ea 100644 --- a/website/src/sdk/server_pb.ts +++ b/website/src/sdk/server_pb.ts @@ -7,6 +7,7 @@ import * as grpcWeb from 'grpc-web'; import * as googleProtobufWrappers from 'google-protobuf/google/protobuf/wrappers_pb'; import * as googleProtobufDuration from 'google-protobuf/google/protobuf/duration_pb'; +import * as buildinfo from './buildinfo_pb'; export class Server { @@ -123,6 +124,7 @@ export declare namespace InfoRes { clientConfigDnsServers: string, clientConfigDnsSearchDomain: string, clientConfigMtu: number, + buildInfo?: buildinfo.BuildInfo.AsObject, } } @@ -245,6 +247,14 @@ export class InfoRes extends jspb.Message { (jspb.Message as any).setProto3IntField(this, 15, value); } + getBuildInfo(): buildinfo.BuildInfo { + return jspb.Message.getWrapperField(this, buildinfo.BuildInfo, 16); + } + + setBuildInfo(value?: buildinfo.BuildInfo): void { + (jspb.Message as any).setWrapperField(this, 16, value); + } + serializeBinary(): Uint8Array { const writer = new jspb.BinaryWriter(); InfoRes.serializeBinaryToWriter(this, writer); @@ -269,6 +279,7 @@ export class InfoRes extends jspb.Message { clientConfigDnsServers: this.getClientConfigDnsServers(), clientConfigDnsSearchDomain: this.getClientConfigDnsSearchDomain(), clientConfigMtu: this.getClientConfigMtu(), + buildInfo: (f = this.getBuildInfo()) && f.toObject(), }; } @@ -333,6 +344,10 @@ export class InfoRes extends jspb.Message { if (field15 != 0) { writer.writeInt32(15, field15); } + const field16 = message.getBuildInfo(); + if (field16 != null) { + writer.writeMessage(16, field16, buildinfo.BuildInfo.serializeBinaryToWriter); + } } static deserializeBinary(bytes: Uint8Array): InfoRes { @@ -410,6 +425,11 @@ export class InfoRes extends jspb.Message { const field15 = reader.readInt32() message.setClientConfigMtu(field15); break; + case 16: + const field16 = new buildinfo.BuildInfo(); + reader.readMessage(field16, buildinfo.BuildInfo.deserializeBinaryFromReader); + message.setBuildInfo(field16); + break; default: reader.skipField(); break; @@ -449,6 +469,7 @@ function InfoResFromObject(obj: InfoRes.AsObject | undefined): InfoRes | undefin message.setClientConfigDnsServers(obj.clientConfigDnsServers); message.setClientConfigDnsSearchDomain(obj.clientConfigDnsSearchDomain); message.setClientConfigMtu(obj.clientConfigMtu); + message.setBuildInfo(BuildInfoFromObject(obj.buildInfo)); return message; } @@ -471,3 +492,13 @@ function DurationFromObject(obj: googleProtobufDuration.Duration.AsObject | unde return message; } +function BuildInfoFromObject(obj: buildinfo.BuildInfo.AsObject | undefined): buildinfo.BuildInfo | undefined { + if (obj === undefined) { + return undefined; + } + const message = new buildinfo.BuildInfo(); + message.setVersion(obj.version); + message.setCommit(obj.commit); + return message; +} +