feat(types): embed config.toml as build manifest source of truth

Move ReleaseVersion, SDKVersion, DiscoveryVersion, and OfficialReleaseBaseURL from string constants to vars populated by parsing an embedded config.toml, so version and protocol values have a single owner in the build manifest. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

oesni committed May 7, 2026 at 21:10 UTC d3d016500687b05cf9e1969b49027c44a9e32193
3 files changed +61 -4
config.toml new
+20
@@ -0,0 +1,20 @@
1 +# Build-time manifest, embedded into the binary via go:embed.
2 +# Bump protocol versions only when wire-level behavior changes.
3 +
4 +[release]
5 +version = "v2.1.10"
6 +base_url = "https://github.com/gosuda/portal-tunnel/releases"
7 +
8 +[protocol]
9 +tunnel = "6"
10 +discovery = "7"
11 +
12 +[bootstrap]
13 +relays = [
14 + "https://portal.thumbgo.kr/",
15 + "https://portal.rabbitson87.dev/",
16 + "https://s-h.day/",
17 + "https://portal.dawnfullstack.com/",
18 + "https://portal.damn.it.com/",
19 + "https://kakashit.org",
20 +]
manifest.go new
+6
@@ -0,0 +1,6 @@
1 +package portaltunnel
2 +
3 +import _ "embed"
4 +
5 +//go:embed config.toml
6 +var ConfigTOML []byte
types/types.go
+35 -4
@@ -1,14 +1,45 @@
1 package types
2
3 +import (
4 + "fmt"
5 +
6 + "github.com/pelletier/go-toml/v2"
7 +
8 + portaltunnel "github.com/gosuda/portal-tunnel/v2"
9 +)
10 +
11 const (
4 - ReleaseVersion = "v2.1.9"
5 - SDKVersion = "7"
6 - DiscoveryVersion = "7"
12 PortalRelayRegistryURL = "https://raw.githubusercontent.com/gosuda/portal-tunnel/main/registry.json"
8 - OfficialReleaseBaseURL = "https://github.com/gosuda/portal-tunnel/releases"
13
14 HeaderAccessToken = "X-Portal-Access-Token"
15 MarkerKeepalive = byte(0x00)
16 MarkerRawStart = byte(0x01)
17 MarkerTLSStart = byte(0x02)
18 )
19 +
20 +var (
21 + ReleaseVersion string
22 + SDKVersion string
23 + DiscoveryVersion string
24 + OfficialReleaseBaseURL string
25 +)
26 +
27 +func init() {
28 + var m struct {
29 + Release struct {
30 + Version string `toml:"version"`
31 + BaseURL string `toml:"base_url"`
32 + } `toml:"release"`
33 + Protocol struct {
34 + Tunnel string `toml:"tunnel"`
35 + Discovery string `toml:"discovery"`
36 + } `toml:"protocol"`
37 + }
38 + if err := toml.Unmarshal(portaltunnel.ConfigTOML, &m); err != nil {
39 + panic(fmt.Errorf("unmarshal config TOML: %w", err))
40 + }
41 + ReleaseVersion = m.Release.Version
42 + OfficialReleaseBaseURL = m.Release.BaseURL
43 + SDKVersion = m.Protocol.Tunnel
44 + DiscoveryVersion = m.Protocol.Discovery
45 +}