Skip to content

Commit 2f569a5

Browse files
committed
add -version flag and tsproxy_build_info metric
1 parent b79619a commit 2f569a5

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ go 1.24.0
55
toolchain go1.24.2
66

77
require (
8-
github.com/google/go-cmp v0.6.0
8+
github.com/google/go-cmp v0.7.0
99
github.com/oklog/run v1.1.0
10-
github.com/prometheus/client_golang v1.19.1
10+
github.com/prometheus/client_golang v1.21.1
1111
tailscale.com v1.82.0
1212
)
1313

@@ -33,7 +33,6 @@ require (
3333
github.com/cespare/xxhash/v2 v2.3.0 // indirect
3434
github.com/coder/websocket v1.8.12 // indirect
3535
github.com/coreos/go-iptables v0.7.1-0.20240112124308-65c67c9f46e6 // indirect
36-
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
3736
github.com/dblohm7/wingoes v0.0.0-20240119213807-a09d6be7affa // indirect
3837
github.com/digitalocean/go-smbios v0.0.0-20180907143718-390a4f403a8e // indirect
3938
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
@@ -54,6 +53,7 @@ require (
5453
github.com/jsimonetti/rtnetlink v1.4.0 // indirect
5554
github.com/klauspost/compress v1.17.11 // indirect
5655
github.com/kortschak/wol v0.0.0-20200729010619-da482cc4850a // indirect
56+
github.com/kylelemons/godebug v1.1.0 // indirect
5757
github.com/mdlayher/genetlink v1.3.2 // indirect
5858
github.com/mdlayher/netlink v1.7.3-0.20250113171957-fbb4dce95f42 // indirect
5959
github.com/mdlayher/sdnotify v1.0.0 // indirect
@@ -64,7 +64,7 @@ require (
6464
github.com/pierrec/lz4/v4 v4.1.21 // indirect
6565
github.com/prometheus-community/pro-bing v0.4.0 // indirect
6666
github.com/prometheus/client_model v0.6.1 // indirect
67-
github.com/prometheus/common v0.55.0 // indirect
67+
github.com/prometheus/common v0.63.0 // indirect
6868
github.com/prometheus/procfs v0.15.1 // indirect
6969
github.com/safchain/ethtool v0.3.0 // indirect
7070
github.com/tailscale/certstore v0.1.1-0.20231202035212-d3fa0460f47e // indirect
@@ -92,6 +92,6 @@ require (
9292
golang.org/x/tools v0.30.0 // indirect
9393
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
9494
golang.zx2c4.com/wireguard/windows v0.5.3 // indirect
95-
google.golang.org/protobuf v1.35.1 // indirect
95+
google.golang.org/protobuf v1.36.5 // indirect
9696
gvisor.dev/gvisor v0.0.0-20250205023644-9414b50a5633 // indirect
9797
)

go.sum

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l
7979
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
8080
github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU=
8181
github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
82-
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
83-
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
82+
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
83+
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
8484
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
8585
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
8686
github.com/google/nftables v0.2.1-0.20240414091927-5e242ec57806 h1:wG8RYIyctLhdFk6Vl1yPGtSRtwGpVkWyZww1OCil2MI=
@@ -115,6 +115,8 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
115115
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
116116
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
117117
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
118+
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
119+
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
118120
github.com/mdlayher/genetlink v1.3.2 h1:KdrNKe+CTu+IbZnm/GVUMXSqBBLqcGpRDa0xkQy56gw=
119121
github.com/mdlayher/genetlink v1.3.2/go.mod h1:tcC3pkCrPUGIKKsCsp0B3AdaaKuHtaxoJRz3cc+528o=
120122
github.com/mdlayher/netlink v1.7.3-0.20250113171957-fbb4dce95f42 h1:A1Cq6Ysb0GM0tpKMbdCXCIfBclan4oHk1Jb+Hrejirg=
@@ -142,12 +144,12 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI
142144
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
143145
github.com/prometheus-community/pro-bing v0.4.0 h1:YMbv+i08gQz97OZZBwLyvmmQEEzyfyrrjEaAchdy3R4=
144146
github.com/prometheus-community/pro-bing v0.4.0/go.mod h1:b7wRYZtCcPmt4Sz319BykUU241rWLe1VFXyiyWK/dH4=
145-
github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE=
146-
github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho=
147+
github.com/prometheus/client_golang v1.21.1 h1:DOvXXTqVzvkIewV/CDPFdejpMCGeMcbGCQ8YOmu+Ibk=
148+
github.com/prometheus/client_golang v1.21.1/go.mod h1:U9NM32ykUErtVBxdvD3zfi+EuFkkaBvMb09mIfe0Zgg=
147149
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
148150
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
149-
github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc=
150-
github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8=
151+
github.com/prometheus/common v0.63.0 h1:YR/EIY1o3mEFP/kZCD7iDMnLPlGyuU2Gb3HIcXnA98k=
152+
github.com/prometheus/common v0.63.0/go.mod h1:VVFF/fBIoToEnWRVkYoXEkq3R3paCoxG9PXP74SnV18=
151153
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
152154
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
153155
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
@@ -228,8 +230,8 @@ golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 h1:B82qJJgjvYKsXS9jeu
228230
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI=
229231
golang.zx2c4.com/wireguard/windows v0.5.3 h1:On6j2Rpn3OEMXqBq00QEDC7bWSZrPIHKIus8eIuExIE=
230232
golang.zx2c4.com/wireguard/windows v0.5.3/go.mod h1:9TEe8TJmtwyQebdFwAkEWOPr3prrtqm+REGFifP60hI=
231-
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
232-
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
233+
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
234+
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
233235
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
234236
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
235237
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=

main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ import (
2121

2222
"github.com/oklog/run"
2323
"github.com/prometheus/client_golang/prometheus"
24+
versioncollector "github.com/prometheus/client_golang/prometheus/collectors/version"
2425
"github.com/prometheus/client_golang/prometheus/promauto"
2526
"github.com/prometheus/client_golang/prometheus/promhttp"
27+
"github.com/prometheus/common/version"
2628
"tailscale.com/client/local"
2729
"tailscale.com/client/tailscale/apitype"
2830
"tailscale.com/tsnet"
@@ -125,11 +127,17 @@ func tsproxy(ctx context.Context) error {
125127
state = flag.String("state", "", "Optional directory for storing Tailscale state.")
126128
tslog = flag.Bool("tslog", false, "If true, log Tailscale output.")
127129
port = flag.Int("port", 32019, "HTTP port for metrics and service discovery.")
130+
ver = flag.Bool("version", false, "print the version and exit")
128131
)
129132
var upstreams upstreamFlag
130133
flag.Var(&upstreams, "upstream", "Repeated for each upstream. Format: name=http://backend:8000")
131134
flag.Parse()
132135

136+
if *ver {
137+
fmt.Fprintln(os.Stdout, version.Print("tsproxy"))
138+
os.Exit(0)
139+
}
140+
133141
if len(upstreams) == 0 {
134142
return fmt.Errorf("required flag missing: upstream")
135143
}
@@ -144,6 +152,7 @@ func tsproxy(ctx context.Context) error {
144152
}
145153
state = &dir
146154
}
155+
prometheus.MustRegister(versioncollector.NewCollector("tsproxy"))
147156

148157
logger := slog.New(slog.NewJSONHandler(os.Stderr, &slog.HandlerOptions{}))
149158
slog.SetDefault(logger)

0 commit comments

Comments
 (0)