11// Copyright (c) Tailscale Inc & AUTHORS
22// SPDX-License-Identifier: BSD-3-Clause
33
4+ //go:build !ts_omit_webclient
5+
46package cli
57
68import (
@@ -22,31 +24,38 @@ import (
2224 "github.com/peterbourgon/ff/v3/ffcli"
2325 "tailscale.com/client/web"
2426 "tailscale.com/ipn"
27+ "tailscale.com/tsconst"
2528)
2629
27- var webCmd = & ffcli.Command {
28- Name : "web" ,
29- ShortUsage : "tailscale web [flags]" ,
30- ShortHelp : "Run a web server for controlling Tailscale" ,
30+ func init () {
31+ maybeWebCmd = webCmd
32+ }
33+
34+ func webCmd () * ffcli.Command {
35+ return & ffcli.Command {
36+ Name : "web" ,
37+ ShortUsage : "tailscale web [flags]" ,
38+ ShortHelp : "Run a web server for controlling Tailscale" ,
3139
32- LongHelp : strings .TrimSpace (`
40+ LongHelp : strings .TrimSpace (`
3341"tailscale web" runs a webserver for controlling the Tailscale daemon.
3442
3543It's primarily intended for use on Synology, QNAP, and other
3644NAS devices where a web interface is the natural place to control
3745Tailscale, as opposed to a CLI or a native app.
3846` ),
3947
40- FlagSet : (func () * flag.FlagSet {
41- webf := newFlagSet ("web" )
42- webf .StringVar (& webArgs .listen , "listen" , "localhost:8088" , "listen address; use port 0 for automatic" )
43- webf .BoolVar (& webArgs .cgi , "cgi" , false , "run as CGI script" )
44- webf .StringVar (& webArgs .prefix , "prefix" , "" , "URL prefix added to requests (for cgi or reverse proxies)" )
45- webf .BoolVar (& webArgs .readonly , "readonly" , false , "run web UI in read-only mode" )
46- webf .StringVar (& webArgs .origin , "origin" , "" , "origin at which the web UI is served (if behind a reverse proxy or used with cgi)" )
47- return webf
48- })(),
49- Exec : runWeb ,
48+ FlagSet : (func () * flag.FlagSet {
49+ webf := newFlagSet ("web" )
50+ webf .StringVar (& webArgs .listen , "listen" , "localhost:8088" , "listen address; use port 0 for automatic" )
51+ webf .BoolVar (& webArgs .cgi , "cgi" , false , "run as CGI script" )
52+ webf .StringVar (& webArgs .prefix , "prefix" , "" , "URL prefix added to requests (for cgi or reverse proxies)" )
53+ webf .BoolVar (& webArgs .readonly , "readonly" , false , "run web UI in read-only mode" )
54+ webf .StringVar (& webArgs .origin , "origin" , "" , "origin at which the web UI is served (if behind a reverse proxy or used with cgi)" )
55+ return webf
56+ })(),
57+ Exec : runWeb ,
58+ }
5059}
5160
5261var webArgs struct {
@@ -101,7 +110,7 @@ func runWeb(ctx context.Context, args []string) error {
101110 var startedManagementClient bool // we started the management client
102111 if ! existingWebClient && ! webArgs .readonly {
103112 // Also start full client in tailscaled.
104- log .Printf ("starting tailscaled web client at http://%s\n " , netip .AddrPortFrom (selfIP , web . ListenPort ))
113+ log .Printf ("starting tailscaled web client at http://%s\n " , netip .AddrPortFrom (selfIP , tsconst . WebListenPort ))
105114 if err := setRunWebClient (ctx , true ); err != nil {
106115 return fmt .Errorf ("starting web client in tailscaled: %w" , err )
107116 }
0 commit comments