Skip to content

Commit

Permalink
tsnet: add option to run integrated web client
Browse files Browse the repository at this point in the history
Updates #10261

Signed-off-by: Will Norris <will@tailscale.com>
  • Loading branch information
willnorris committed Nov 16, 2023
1 parent a3c11b8 commit 5dd589d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tsnet/example/web-client/web-client.go
Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions tsnet/tsnet.go
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5dd589d

Please sign in to comment.