File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ import (
26
26
27
27
var (
28
28
ports = flag .String ("ports" , "443" , "comma-separated list of ports to proxy" )
29
+ wgPort = flag .Int ("wg-listen-port" , 0 , "UDP port to listen on for WireGuard and peer-to-peer traffic; 0 means automatically select" )
29
30
promoteHTTPS = flag .Bool ("promote-https" , true , "promote HTTP to HTTPS" )
30
31
)
31
32
@@ -40,6 +41,7 @@ func main() {
40
41
hostinfo .SetApp ("sniproxy" )
41
42
42
43
var s server
44
+ s .ts .Port = uint16 (* wgPort )
43
45
defer s .ts .Close ()
44
46
45
47
lc , err := s .ts .LocalClient ()
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ func inTest() bool { return flag.Lookup("test.v") != nil }
61
61
62
62
// Server is an embedded Tailscale server.
63
63
//
64
- // Its exported fields may be changed until the first call to Listen .
64
+ // Its exported fields may be changed until the first method call .
65
65
type Server struct {
66
66
// Dir specifies the name of the directory to use for
67
67
// state. If empty, a directory is selected automatically
@@ -108,6 +108,11 @@ type Server struct {
108
108
// If empty, the Tailscale default is used.
109
109
ControlURL string
110
110
111
+ // Port is the UDP port to listen on for WireGuard and peer-to-peer
112
+ // traffic. If zero, a port is automatically selected. Leave this
113
+ // field at zero unless you know what you are doing.
114
+ Port uint16
115
+
111
116
getCertForTesting func (* tls.ClientHelloInfo ) (* tls.Certificate , error )
112
117
113
118
initOnce sync.Once
@@ -502,7 +507,7 @@ func (s *Server) start() (reterr error) {
502
507
sys := new (tsd.System )
503
508
s .dialer = & tsdial.Dialer {Logf : logf } // mutated below (before used)
504
509
eng , err := wgengine .NewUserspaceEngine (logf , wgengine.Config {
505
- ListenPort : 0 ,
510
+ ListenPort : s . Port ,
506
511
NetMon : s .netMon ,
507
512
Dialer : s .dialer ,
508
513
SetSubsystem : sys .Set ,
You can’t perform that action at this time.
0 commit comments