cmd/natc: add --wg-port flag

Updates tailscale/corp#20503

Signed-off-by: Fran Bull <fran@tailscale.com>
pull/12377/head
Fran Bull 6 months ago committed by franbull
parent 4a8cb1d9f3
commit 573c8bd8c7

@ -55,6 +55,7 @@ func main() {
verboseTSNet = fs.Bool("verbose-tsnet", false, "enable verbose logging in tsnet") verboseTSNet = fs.Bool("verbose-tsnet", false, "enable verbose logging in tsnet")
printULA = fs.Bool("print-ula", false, "print the ULA prefix and exit") printULA = fs.Bool("print-ula", false, "print the ULA prefix and exit")
ignoreDstPfxStr = fs.String("ignore-destinations", "", "comma-separated list of prefixes to ignore") ignoreDstPfxStr = fs.String("ignore-destinations", "", "comma-separated list of prefixes to ignore")
wgPort = fs.Uint("wg-port", 0, "udp port for wireguard and peer to peer traffic")
) )
ff.Parse(fs, os.Args[1:], ff.WithEnvVarPrefix("TS_NATC")) ff.Parse(fs, os.Args[1:], ff.WithEnvVarPrefix("TS_NATC"))
@ -104,6 +105,12 @@ func main() {
ts := &tsnet.Server{ ts := &tsnet.Server{
Hostname: *hostname, Hostname: *hostname,
} }
if *wgPort != 0 {
if *wgPort >= 1<<16 {
log.Fatalf("wg-port must be in the range [0, 65535]")
}
ts.Port = uint16(*wgPort)
}
defer ts.Close() defer ts.Close()
if *verboseTSNet { if *verboseTSNet {
ts.Logf = log.Printf ts.Logf = log.Printf

Loading…
Cancel
Save