mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-26 03:25:35 +00:00
16bc9350e3
Currently just serving a "Hello world" page when running the web cli in --dev mode. Updates tailscale/corp#13775 Co-authored-by: Will Norris <will@tailscale.com> Signed-off-by: Sonia Appasamy <sonia@tailscale.com>
46 lines
777 B
Go
46 lines
777 B
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
// The web-client command demonstrates serving the Tailscale web client over tsnet.
|
|
package main
|
|
|
|
import (
|
|
"flag"
|
|
"log"
|
|
"net/http"
|
|
|
|
"tailscale.com/client/web"
|
|
"tailscale.com/tsnet"
|
|
)
|
|
|
|
var (
|
|
devMode = flag.Bool("dev", false, "run web client in dev mode")
|
|
)
|
|
|
|
func main() {
|
|
flag.Parse()
|
|
|
|
s := new(tsnet.Server)
|
|
defer s.Close()
|
|
|
|
ln, err := s.Listen("tcp", ":80")
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
defer ln.Close()
|
|
|
|
lc, err := s.LocalClient()
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
// Serve the Tailscale web client.
|
|
ws, cleanup := web.NewServer(*devMode, lc)
|
|
defer cleanup()
|
|
if err := http.Serve(ln, ws); err != nil {
|
|
if err != http.ErrServerClosed {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
}
|