tsnet: add option to run integrated web client

Updates #10261

Signed-off-by: Will Norris <will@tailscale.com>
pull/10293/head
Will Norris 6 months ago committed by Will Norris
parent 90eb5379f4
commit 5aa22ff3eb

@ -20,7 +20,7 @@ var (
func main() {
flag.Parse()
s := new(tsnet.Server)
s := &tsnet.Server{RunWebClient: true}
defer s.Close()
lc, err := s.LocalClient()

@ -108,6 +108,10 @@ type Server struct {
// If empty, the Tailscale default is used.
ControlURL string
// RunWebClient, if true, runs a client for managing this node over
// its Tailscale interface on port 5252.
RunWebClient bool
// Port is the UDP port to listen on for WireGuard and peer-to-peer
// traffic. If zero, a port is automatically selected. Leave this
// field at zero unless you know what you are doing.
@ -575,6 +579,7 @@ func (s *Server) start() (reterr error) {
prefs.Hostname = s.hostname
prefs.WantRunning = true
prefs.ControlURL = s.ControlURL
prefs.RunWebClient = s.RunWebClient
authKey := s.getAuthKey()
err = lb.Start(ipn.Options{
UpdatePrefs: prefs,
@ -603,6 +608,7 @@ func (s *Server) start() (reterr error) {
s.localAPIListener = lal
s.localClient = &tailscale.LocalClient{Dial: lal.Dial}
s.localAPIServer = &http.Server{Handler: lah}
s.lb.ConfigureWebClient(s.localClient)
go func() {
if err := s.localAPIServer.Serve(lal); err != nil {
logf("localapi serve error: %v", err)

Loading…
Cancel
Save