Skip to content

Commit 1c25910

Browse files
committed
cmd/{derper,derpprobe}: add --version flag
Fixes tailscale#11582 Change-Id: If99fc1ab6b89d624fbb07bd104dd882d2c7b50b4 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
1 parent 1535d0f commit 1c25910

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

cmd/derper/derper.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,21 @@ import (
3636
"tailscale.com/tsweb"
3737
"tailscale.com/types/key"
3838
"tailscale.com/types/logger"
39+
"tailscale.com/version"
3940
)
4041

4142
var (
42-
dev = flag.Bool("dev", false, "run in localhost development mode (overrides -a)")
43-
addr = flag.String("a", ":443", "server HTTP/HTTPS listen address, in form \":port\", \"ip:port\", or for IPv6 \"[ip]:port\". If the IP is omitted, it defaults to all interfaces. Serves HTTPS if the port is 443 and/or -certmode is manual, otherwise HTTP.")
44-
httpPort = flag.Int("http-port", 80, "The port on which to serve HTTP. Set to -1 to disable. The listener is bound to the same IP (if any) as specified in the -a flag.")
45-
stunPort = flag.Int("stun-port", 3478, "The UDP port on which to serve STUN. The listener is bound to the same IP (if any) as specified in the -a flag.")
46-
configPath = flag.String("c", "", "config file path")
47-
certMode = flag.String("certmode", "letsencrypt", "mode for getting a cert. possible options: manual, letsencrypt")
48-
certDir = flag.String("certdir", tsweb.DefaultCertDir("derper-certs"), "directory to store LetsEncrypt certs, if addr's port is :443")
49-
hostname = flag.String("hostname", "derp.tailscale.com", "LetsEncrypt host name, if addr's port is :443")
50-
runSTUN = flag.Bool("stun", true, "whether to run a STUN server. It will bind to the same IP (if any) as the --addr flag value.")
51-
runDERP = flag.Bool("derp", true, "whether to run a DERP server. The only reason to set this false is if you're decommissioning a server but want to keep its bootstrap DNS functionality still running.")
43+
dev = flag.Bool("dev", false, "run in localhost development mode (overrides -a)")
44+
versionFlag = flag.Bool("version", false, "print version and exit")
45+
addr = flag.String("a", ":443", "server HTTP/HTTPS listen address, in form \":port\", \"ip:port\", or for IPv6 \"[ip]:port\". If the IP is omitted, it defaults to all interfaces. Serves HTTPS if the port is 443 and/or -certmode is manual, otherwise HTTP.")
46+
httpPort = flag.Int("http-port", 80, "The port on which to serve HTTP. Set to -1 to disable. The listener is bound to the same IP (if any) as specified in the -a flag.")
47+
stunPort = flag.Int("stun-port", 3478, "The UDP port on which to serve STUN. The listener is bound to the same IP (if any) as specified in the -a flag.")
48+
configPath = flag.String("c", "", "config file path")
49+
certMode = flag.String("certmode", "letsencrypt", "mode for getting a cert. possible options: manual, letsencrypt")
50+
certDir = flag.String("certdir", tsweb.DefaultCertDir("derper-certs"), "directory to store LetsEncrypt certs, if addr's port is :443")
51+
hostname = flag.String("hostname", "derp.tailscale.com", "LetsEncrypt host name, if addr's port is :443")
52+
runSTUN = flag.Bool("stun", true, "whether to run a STUN server. It will bind to the same IP (if any) as the --addr flag value.")
53+
runDERP = flag.Bool("derp", true, "whether to run a DERP server. The only reason to set this false is if you're decommissioning a server but want to keep its bootstrap DNS functionality still running.")
5254

5355
meshPSKFile = flag.String("mesh-psk-file", defaultMeshPSKFile(), "if non-empty, path to file containing the mesh pre-shared key file. It should contain some hex string; whitespace is trimmed.")
5456
meshWith = flag.String("mesh-with", "", "optional comma-separated list of hostnames to mesh with; the server's own hostname can be in the list")
@@ -129,6 +131,10 @@ func writeNewConfig() config {
129131

130132
func main() {
131133
flag.Parse()
134+
if *versionFlag {
135+
fmt.Println(version.Long())
136+
return
137+
}
132138

133139
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
134140
defer cancel()

cmd/derpprobe/derpprobe.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ import (
1616

1717
"tailscale.com/prober"
1818
"tailscale.com/tsweb"
19+
"tailscale.com/version"
1920
)
2021

2122
var (
2223
derpMapURL = flag.String("derp-map", "https://login.tailscale.com/derpmap/default", "URL to DERP map (https:// or file://)")
24+
versionFlag = flag.Bool("version", false, "print version and exit")
2325
listen = flag.String("listen", ":8030", "HTTP listen address")
2426
probeOnce = flag.Bool("once", false, "probe once and print results, then exit; ignores the listen flag")
2527
spread = flag.Bool("spread", true, "whether to spread probing over time")
@@ -33,6 +35,10 @@ var (
3335

3436
func main() {
3537
flag.Parse()
38+
if *versionFlag {
39+
fmt.Println(version.Long())
40+
return
41+
}
3642

3743
p := prober.New().WithSpread(*spread).WithOnce(*probeOnce).WithMetricNamespace("derpprobe")
3844
opts := []prober.DERPOpt{

0 commit comments

Comments
 (0)