Scaffolds the server module and everything Phase 0 of PLAN.md calls for: a binary that boots, serves its discovery endpoints and nothing else yet. - config: one YAML file plus per-field WARP_* environment overrides, unknown fields rejected, validation that reports every problem at once - logging and metrics: slog, a Prometheus registry, per-route HTTP instrumentation labelled by pattern rather than path - httputil: the Matrix error envelope, error-returning handlers, CORS, request logging, panic recovery, and a router over http.ServeMux - endpoints: /_matrix/client/versions, /.well-known/matrix/client, /.well-known/matrix/server (gated), /healthz, /metrics, and M_UNRECOGNIZED for everything else - storage: driver registry, shared database/sql base, checksummed migration runner, sqlite and postgres drivers, pocketbase stub - settings: server_settings table behind a cached service, so the federation and registration switches change without a restart - federation: the gate that makes federation a runtime mode - cmd/warp: serve, migrate, generate-keys, version - Makefile, golangci-lint v2, GitHub Actions CI (Linux and Windows tests, race on Linux, storage tests against PostgreSQL, lint, boot smoke test), Dockerfile, example config and docs Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
52 lines
968 B
Go
52 lines
968 B
Go
// Package buildinfo carries version information stamped in at link time.
|
|
package buildinfo
|
|
|
|
import (
|
|
"fmt"
|
|
"runtime"
|
|
"runtime/debug"
|
|
)
|
|
|
|
// Set with -ldflags "-X github.com/dariuszjaniak/warp/server/internal/buildinfo.Version=..."
|
|
var (
|
|
Version = "0.0.0-dev"
|
|
Commit = ""
|
|
BuildDate = ""
|
|
)
|
|
|
|
func init() {
|
|
if Commit != "" {
|
|
return
|
|
}
|
|
info, ok := debug.ReadBuildInfo()
|
|
if !ok {
|
|
return
|
|
}
|
|
for _, s := range info.Settings {
|
|
switch s.Key {
|
|
case "vcs.revision":
|
|
Commit = s.Value
|
|
case "vcs.time":
|
|
BuildDate = s.Value
|
|
}
|
|
}
|
|
}
|
|
|
|
// UserAgent is the value sent on outbound federation requests.
|
|
func UserAgent() string {
|
|
return fmt.Sprintf("Warp/%s (%s %s)", Version, runtime.GOOS, runtime.GOARCH)
|
|
}
|
|
|
|
// String renders the full version line for `warp version` and startup logs.
|
|
func String() string {
|
|
s := Version
|
|
if Commit != "" {
|
|
if len(Commit) > 12 {
|
|
s += " (" + Commit[:12] + ")"
|
|
} else {
|
|
s += " (" + Commit + ")"
|
|
}
|
|
}
|
|
return s
|
|
}
|