diff --git a/Dockerfile b/Dockerfile index f8df973..ceeac14 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM golang:1.18-bullseye COPY . /src/orbeat +COPY .git/ /src/orbeat/.git/ WORKDIR /src/orbeat RUN GOAMD64=v2 go build -v -o orbeat . && mv orbeat /usr/bin && rm -rf /src/orbeat diff --git a/OrbitalBeat.go b/OrbitalBeat.go index e15614b..5238c9c 100644 --- a/OrbitalBeat.go +++ b/OrbitalBeat.go @@ -23,6 +23,7 @@ import ( "os" "path" "runtime" + "runtime/debug" "strings" "sync" "sync/atomic" @@ -47,6 +48,8 @@ var trustedPublicKeys []ed25519.PublicKey var debugOutput = false +var programVersion = "unknown" + type statistics struct { Served servedStatistics `json:"served"` ContentCache contentCacheStatistics `json:"content_cache"` @@ -550,12 +553,14 @@ func handle(ctx httputils.RequestContext) { ctx.SetResponseCode(http.StatusOK) statsStruct := struct { + Version string `json:"version"` Statistics *statistics `json:"statistics"` Database struct { TotalEntries uint64 `json:"entries"` TotalSize uint64 `json:"size"` } `json:"database"` }{ + Version: programVersion, Statistics: &globalStatistics, } @@ -717,6 +722,16 @@ func main() { var err error + if dInfo, ok := debug.ReadBuildInfo(); ok { + for _, s := range dInfo.Settings { + if s.Key == "vcs.revision" { + programVersion = s.Value + } else if s.Key == "vcs.modified" { + programVersion += "-dev" + } + } + } + for _, k := range strings.Split(*trustedKeys, ",") { var publicKey ed25519.PublicKey publicKey, err = MakyuuIchaival.Bech32Encoding.DecodeString(strings.Trim(k, " "))