// Copyright (c) Tailscale Inc & AUTHORS // SPDX-License-Identifier: BSD-3-Clause // The tsnet-funnel server demonstrates how to use tsnet with Funnel. // // To use it, generate an auth key from the Tailscale admin panel and // run the demo with the key: // // TS_AUTHKEY= go run tsnet-funnel.go package main import ( "flag" "fmt" "log" "net/http" "tailscale.com/tsnet" "tailscale.com/types/logger" ) func main() { flag.Parse() s := &tsnet.Server{ Dir: "./funnel-demo-config", Logf: logger.Discard, Hostname: "fun", } defer s.Close() ln, err := s.ListenFunnel("tcp", ":443") if err != nil { log.Fatal(err) } defer ln.Close() err = http.Serve(ln, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "

Hello, internet!

") })) log.Fatal(err) }