defaultPort returns the default UDP port to listen on for disco+wireguard. By default it returns 0, to pick one randomly from the kernel. If the environment variable PORT is set, that's used instead. The PORT environment variable is chosen to match what the Linux systemd unit uses, to make documenta
()
| 107 | // The PORT environment variable is chosen to match what the Linux systemd |
| 108 | // unit uses, to make documentation more consistent. |
| 109 | func defaultPort() uint16 { |
| 110 | if s := envknob.String("PORT"); s != "" { |
| 111 | if p, err := strconv.ParseUint(s, 10, 16); err == nil { |
| 112 | return uint16(p) |
| 113 | } |
| 114 | } |
| 115 | if envknob.GOOS() == "windows" { |
| 116 | return 41641 |
| 117 | } |
| 118 | return 0 |
| 119 | } |
| 120 | |
| 121 | var args struct { |
| 122 | // tunname is a /dev/net/tun tunnel name ("tailscale0"), the |