Package tsnet embeds a Tailscale node directly into a Go program, allowing it to join a tailnet and accept or dial connections without running a separate tailscaled daemon or requiring any system-level configuration.
Overview ¶
Normally, Tailscale runs as a background system service (tailscaled) that manages a virtual network interface for the whole machine. tsnet takes a different approach: it runs a fully self-contained Tailscale node inside your process using a userspace TCP/IP stack (gVisor). This means:
- No root privileges required.
- No system daemons to install or manage.
- Multiple independent Tailscale nodes can run within a single binary.
- The node's Tailscale identity and state are stored in a directory you control.
The core type is Server, which represents one embedded Tailscale node. Calling Server.Listen or Server.Dial routes traffic exclusively over the tailnet. The standard library's net.Listener and net.Conn interfaces are returned, so any existing Go HTTP server, gRPC server, or other net-based code works without modification.
Usage ¶
import "tailscale.com/tsnet"
s := &tsnet.Server{
Hostname: "my-service",
AuthKey: os.Getenv("TS_AUTHKEY"),
}
defer s.Close()
ln, err := s.Listen("tcp", ":80")
if err != nil {
log.Fatal(err)
}
log.Fatal(http.Serve(ln, myHandler))
On first run, if no Server.AuthKey is provided and the node is not already enrolled, the server logs an authentication URL. Open it in a browser to add the node to your tailnet.
Authentication ¶
A Server authenticates using, in order of precedence:
The TS_AUTHKEY environment variable.
The TS_AUTH_KEY environment variable.
An OAuth client secret (Server.ClientSecret or TS_CLIENT_SECRET), used to mint an auth key.
Workload identity federation (Server.ClientID plus Server.IDToken or Server.Audience). Available only if the program imports the feature:
import _ "tailscale.com/feature/identityfederation"
The feature is not linked by default to keep the AWS SDK and other cloud-provider dependencies out of programs that don't use workload identity federation.
An interactive login URL printed to Server.UserLogf.
If the node is already enrolled (state found in Server.Store), the auth key is ignored unless TSNET_FORCE_LOGIN=1 is set.
Identifying callers ¶
Use the WhoIs method on the client returned by Server.LocalClient to identify who is making a request:
lc, _ := srv.LocalClient()
http.Serve(ln, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
who, err := lc.WhoIs(r.Context(), r.RemoteAddr)
if err != nil {
http.Error(w, err.Error(), 500)
return
}
fmt.Fprintf(w, "Hello, %s!", who.UserProfile.LoginName)
}))
Tailscale Funnel ¶
Server.ListenFunnel exposes your service on the public internet. Tailscale Funnel currently supports TCP on ports 443, 8443, and 10000. HTTPS must be enabled in the Tailscale admin console.
ln, err := srv.ListenFunnel("tcp", ":443")
// ln is a TLS listener; connections can come from anywhere on the
// internet as well as from your tailnet.
// To restrict to public traffic only:
ln, err = srv.ListenFunnel("tcp", ":443", tsnet.FunnelOnly())
Tailscale Services ¶
Server.ListenService advertises the node as a host for a named Tailscale Service. The node must use a tag-based identity. To advertise multiple ports, call ListenService once per port.
srv.AdvertiseTags = []string{"tag:myservice"}
ln, err := srv.ListenService("svc:my-service", tsnet.ServiceModeHTTP{
HTTPS: true,
Port: 443,
})
log.Printf("Listening on https://%s", ln.FQDN)
Running multiple nodes in one process ¶
Each Server instance is an independent node. Give each a unique Server.Dir and Server.Hostname:
for _, name := range []string{"frontend", "backend"} {
srv := &tsnet.Server{
Hostname: name,
Dir: filepath.Join(baseDir, name),
AuthKey: os.Getenv("TS_AUTHKEY"),
Ephemeral: true,
}
srv.Start()
}
Example_tshello is a full example on using tsnet. When you run this program it will print an authentication link. Open it in your favorite web browser and add it to your tailnet like any other machine. Open another terminal window and try to ping it:
$ ping tshello -c 2 PING tshello (100.105.183.159) 56(84) bytes of data. 64 bytes from tshello.your-tailnet.ts.net (100.105.183.159): icmp_seq=1 ttl=64 time=25.0 ms 64 bytes from tshello.your-tailnet.ts.net (100.105.183.159): icmp_seq=2 ttl=64 time=1.12 ms
Then connect to it using curl:
$ curl http://tshello <html><body><h1>Hello, world!</h1> <p>You are <b>Xe</b> from <b>pneuma</b> (100.78.40.86:49214)</p>
From here you can do anything you want with the Go standard library HTTP stack, or anything that is compatible with it (Gin/Gonic, Gorilla/mux, etc.).
package main
import (
"flag"
"fmt"
"html"
"log"
"net/http"
"strings"
"tailscale.com/tsnet"
)
func firstLabel(s string) string {
s, _, _ = strings.Cut(s, ".")
return s
}
// Example_tshello is a full example on using tsnet. When you run this program it will print
// an authentication link. Open it in your favorite web browser and add it to your tailnet
// like any other machine. Open another terminal window and try to ping it:
//
// $ ping tshello -c 2
// PING tshello (100.105.183.159) 56(84) bytes of data.
// 64 bytes from tshello.your-tailnet.ts.net (100.105.183.159): icmp_seq=1 ttl=64 time=25.0 ms
// 64 bytes from tshello.your-tailnet.ts.net (100.105.183.159): icmp_seq=2 ttl=64 time=1.12 ms
//
// Then connect to it using curl:
//
// $ curl http://tshello
// <html><body><h1>Hello, world!</h1>
// <p>You are <b>Xe</b> from <b>pneuma</b> (100.78.40.86:49214)</p>
//
// From here you can do anything you want with the Go standard library HTTP stack, or anything
// that is compatible with it (Gin/Gonic, Gorilla/mux, etc.).
func main() {
var (
addr = flag.String("addr", ":80", "address to listen on")
hostname = flag.String("hostname", "tshello", "hostname to use on the tailnet")
)
flag.Parse()
s := new(tsnet.Server)
s.Hostname = *hostname
defer s.Close()
ln, err := s.Listen("tcp", *addr)
if err != nil {
log.Fatal(err)
}
defer ln.Close()
lc, err := s.LocalClient()
if err != nil {
log.Fatal(err)
}
log.Fatal(http.Serve(ln, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
who, err := lc.WhoIs(r.Context(), r.RemoteAddr)
if err != nil {
http.Error(w, err.Error(), 500)
return
}
fmt.Fprintf(w, "<html><body><h1>Hello, tailnet!</h1>\n")
fmt.Fprintf(w, "<p>You are <b>%s</b> from <b>%s</b> (%s)</p>",
html.EscapeString(who.UserProfile.LoginName),
html.EscapeString(firstLabel(who.Node.ComputedName)),
r.RemoteAddr)
})))
}
- Variables
- type FallbackTCPHandler
- type FunnelOption
- type Server
- func (s *Server) CapturePcap(ctx context.Context, pcapFile string) error
- func (s *Server) CertDomains() []string
- func (s *Server) Close() error
- func (s *Server) Dial(ctx context.Context, network, address string) (net.Conn, error)
- func (s *Server) GetRootPath() string
- func (s *Server) HTTPClient() *http.Client
- func (s *Server) Listen(network, addr string) (net.Listener, error)
- func (s *Server) ListenFunnel(network, addr string, opts ...FunnelOption) (net.Listener, error)
- func (s *Server) ListenPacket(network, addr string) (net.PacketConn, error)
- func (s *Server) ListenSSH(addr string) (net.Listener, error)
- func (s *Server) ListenService(name string, mode ServiceMode) (*ServiceListener, error)
- func (s *Server) ListenTLS(network, addr string) (net.Listener, error)
- func (s *Server) LocalClient() (*local.Client, error)
- func (s *Server) LogtailWriter() io.Writer
- func (s *Server) Loopback() (addr string, proxyCred, localAPICred string, err error)
- func (s *Server) RegisterFallbackTCPHandler(cb FallbackTCPHandler) func()
- func (s *Server) Start() error
- func (s *Server) Sys() *tsd.System
- func (s *Server) TailscaleIPs() (ip4, ip6 netip.Addr)
- func (s *Server) Up(ctx context.Context) (*ipnstate.Status, error)
- type ServiceListener
- type ServiceMode
- type ServiceModeHTTP
- type ServiceModeTCP
- Package (Tshello)
- Server
- Server (Dir)
- Server (Hostname)
- Server (IgnoreLogsSometimes)
- Server (MultipleInstances)
- Server.HTTPClient
- Server.Listen
- Server.ListenFunnel
- Server.ListenFunnel (FunnelOnly)
- Server.ListenService
- Server.ListenService (MultiplePorts)
- Server.ListenService (ReverseProxy)
- Server.ListenTLS
- Server.Start
This section is empty.
ErrUntaggedServiceHost is returned by ListenService when run on a node without any ACL tags. A node must use a tag-based identity to act as a Service host. For more information, see: https://tailscale.com/kb/1552/tailscale-services#prerequisites
TestHooks are hooks meant for internal-testing only; they're not stable or documented, intentionally.
This section is empty.
type FallbackTCPHandler ¶ added in v1.52.0
FallbackTCPHandler describes the callback which conditionally handles an incoming TCP flow for the provided (src/port, dst/port) 4-tuple. These are registered as handlers of last resort, and are called only if no listener could handle the incoming flow.
If the callback returns intercept=false, the flow is rejected.
When intercept=true, the behavior depends on whether the returned handler is non-nil: if nil, the connection is rejected. If non-nil, handler takes over the TCP conn.
type FunnelOption interface {
}
FunnelOption is an option passed to ListenFunnel to configure the listener.
func FunnelOnly() FunnelOption
FunnelOnly configures the listener to only respond to connections from Tailscale Funnel. The local tailnet will not be able to connect to the listener.
FunnelTLSConfig configures the TLS configuration for Server.ListenFunnel
This is rarely needed but can permit requiring client certificates, specific ciphers suites, etc.
The provided conf should at least be able to get a certificate, setting GetCertificate, Certificates or GetConfigForClient appropriately. The most common configuration is to set GetCertificate to Server.LocalClient's GetCertificate method.
Unless FunnelOnly is also used, the configuration is also used for in-tailnet connections that don't arrive over Funnel.
Server is an embedded Tailscale server.
Its exported fields may be changed until the first method call.
ExampleServer shows you how to construct a ready-to-use tsnet instance.
package main
import (
"log"
"tailscale.com/tsnet"
)
func main() {
srv := new(tsnet.Server)
if err := srv.Start(); err != nil {
log.Fatalf("can't start tsnet server: %v", err)
}
defer srv.Close()
}
ExampleServer_dir shows you how to configure the persistent directory for a tsnet application. This is where the Tailscale node information is stored so that your application can reconnect to your tailnet when the application is restarted.
By default, tsnet will store data in your user configuration directory based on the name of the binary. Note that this folder must already exist or tsnet calls will fail.
package main
import (
"log"
"os"
"path/filepath"
"tailscale.com/tsnet"
)
func main() {
dir := filepath.Join("/data", "tsnet")
if err := os.MkdirAll(dir, 0700); err != nil {
log.Fatal(err)
}
srv := &tsnet.Server{
Dir: dir,
}
// do something with srv
_ = srv
}
ExampleServer_hostname shows you how to set a tsnet server's hostname.
This setting lets you control the host name of your program on your tailnet. By default this will be the name of your program (such as foo for a program stored at /usr/local/bin/foo). You can also override this by setting the Hostname field.
package main
import (
"tailscale.com/tsnet"
)
func main() {
srv := &tsnet.Server{
Hostname: "kirito",
}
// do something with srv
_ = srv
}
ExampleServer_ignoreLogsSometimes shows you how to ignore all of the log messages written by a tsnet instance, but allows you to opt-into them if a command-line flag is set.
package main
import (
"flag"
"fmt"
"log"
"os"
"tailscale.com/tsnet"
)
func main() {
tsnetVerbose := flag.Bool("tsnet-verbose", false, "if set, verbosely log tsnet information")
hostname := flag.String("tsnet-hostname", "hikari", "hostname to use on the tailnet")
srv := &tsnet.Server{
Hostname: *hostname,
}
if *tsnetVerbose {
srv.Logf = log.New(os.Stderr, fmt.Sprintf("[tsnet:%s] ", *hostname), log.LstdFlags).Printf
}
}
ExampleServer_multipleInstances shows you how to configure multiple instances of tsnet per program. This allows you to have multiple Tailscale nodes in the same process/container.
package main
import (
"log"
"os"
"path/filepath"
"tailscale.com/tsnet"
)
func main() {
baseDir := "/data"
var servers []*tsnet.Server
for _, hostname := range []string{"ichika", "nino", "miku", "yotsuba", "itsuki"} {
os.MkdirAll(filepath.Join(baseDir, hostname), 0700)
srv := &tsnet.Server{
Hostname: hostname,
AuthKey: os.Getenv("TS_AUTHKEY"),
Ephemeral: true,
Dir: filepath.Join(baseDir, hostname),
}
if err := srv.Start(); err != nil {
log.Fatalf("can't start tsnet server: %v", err)
}
servers = append(servers, srv)
}
// When you're done, close the instances
defer func() {
for _, srv := range servers {
srv.Close()
}
}()
}
CapturePcap can be called by the application code compiled with tsnet to save a pcap of packets which the netstack within tsnet sees. This is expected to be useful during debugging, probably not useful for production.
Packets will be written to the pcap until the process exits. The pcap needs a Lua dissector to be installed in Wireshark in order to decode properly: wgengine/capture/ts-dissector.lua in this repository. https://tailscale.com/docs/reference/troubleshooting/network-configuration/inspect-unencrypted-packets
func (*Server) CertDomains ¶ added in v1.38.0
CertDomains returns the list of domains for which the server can provide TLS certificates. These are also the DNS names for the Server. If the server is not running, it returns nil.
Close stops the server.
It must not be called before or concurrently with Start.
Dial connects to the address on the tailnet. It will start the server if it has not been started yet.
GetRootPath returns the root path of the tsnet server. This is where the state file and other data is stored.
HTTPClient returns an HTTP client that is configured to connect over Tailscale.
This is useful if you need to have your tsnet services connect to other devices on your tailnet.
ExampleServer_HTTPClient shows you how to make HTTP requests over your tailnet.
If you want to make outgoing HTTP connections to resources on your tailnet, use the HTTP client that the tsnet.Server exposes.
package main
import (
"log"
"tailscale.com/tsnet"
)
func main() {
srv := &tsnet.Server{}
cli := srv.HTTPClient()
resp, err := cli.Get("https://hello.ts.net")
if resp == nil {
log.Fatal(err)
}
// do something with resp
_ = resp
}
Listen announces only on the Tailscale network. It will start the server if it has not been started yet.
Listeners which do not specify an IP address will match for traffic for the local node (that is, a destination address of the IPv4 or IPv6 address of this node) only. To listen for traffic on other addresses such as those routed inbound via subnet routes, explicitly specify the listening address or use RegisterFallbackTCPHandler.
ExampleServer_Listen shows you how to create a TCP listener on your tailnet and then makes an HTTP server on top of that.
package main
import (
"fmt"
"log"
"net/http"
"tailscale.com/tsnet"
)
func main() {
srv := &tsnet.Server{
Hostname: "tadaima",
}
ln, err := srv.Listen("tcp", ":80")
if err != nil {
log.Fatal(err)
}
log.Fatal(http.Serve(ln, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hi there! Welcome to the tailnet!")
})))
}
ListenFunnel announces on the public internet using Tailscale Funnel.
It also by default listens on your local tailnet, so connections can come from either inside or outside your network. To restrict connections to be just from the internet, use the FunnelOnly option.
Currently (2023-03-10), Funnel only supports TCP on ports 443, 8443, and 10000. The supported host name is limited to that configured for the tsnet.Server. As such, the standard way to create funnel is:
s.ListenFunnel("tcp", ":443")
and the only other supported addrs currently are ":8443" and ":10000".
It will start the server if it has not been started yet.
ExampleServer_ListenFunnel shows you how to create an HTTPS service on both your tailnet and the public internet via Funnel.
package main
import (
"fmt"
"log"
"net/http"
"tailscale.com/tsnet"
)
func main() {
srv := &tsnet.Server{
Hostname: "ophion",
}
ln, err := srv.ListenFunnel("tcp", ":443")
if err != nil {
log.Fatal(err)
}
log.Fatal(http.Serve(ln, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hi there! Welcome to the tailnet!")
})))
}
ExampleServer_ListenFunnel_funnelOnly shows you how to create a funnel-only HTTPS service.
package main
import (
"fmt"
"log"
"net/http"
"tailscale.com/tsnet"
)
func main() {
srv := new(tsnet.Server)
srv.Hostname = "ophion"
ln, err := srv.ListenFunnel("tcp", ":443", tsnet.FunnelOnly())
if err != nil {
log.Fatal(err)
}
log.Fatal(http.Serve(ln, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hi there! Welcome to the tailnet!")
})))
}
ListenPacket announces on the Tailscale network.
The network must be "udp", "udp4" or "udp6". The addr must be of the form "ip:port" (or "[ip]:port") where ip is a valid IPv4 or IPv6 address corresponding to "udp4" or "udp6" respectively. IP must be specified.
If s has not been started yet, it will be started.
ListenSSH listens on the Tailscale network for SSH connections at the given addr (e.g. ":2222"). The returned listener's Accept method yields net.Conn values that are actually *tailssh.Session, providing access to the connecting peer's Tailscale identity, PTY information, signals, and more.
Basic applications can use the returned connections as plain net.Conn (Read/Write/Close). Applications that need richer SSH semantics should type-assert to *tailssh.Session.
SSH support must be linked into the binary by importing _ "tailscale.com/feature/ssh". Without that import, ListenSSH returns an error.
If s has not been started yet, it will be started.
ListenService creates a network listener for a Tailscale Service. This will advertise this node as hosting the Service. Note that:
- Approval must still be granted by an admin or by ACL auto-approval rules.
- Service hosts must be tagged nodes.
- A valid Service host must advertise all ports defined for the Service.
To advertise a Service with multiple ports, run ListenService multiple times. For more information about Services, see https://tailscale.com/kb/1552/tailscale-services
This function will start the server if it is not already started.
ExampleServer_ListenService demonstrates how to advertise an HTTPS Service.
package main
import (
"fmt"
"log"
"net/http"
"tailscale.com/tsnet"
)
func main() {
srv := &tsnet.Server{
Hostname: "atum",
}
ln, err := srv.ListenService("svc:my-service", tsnet.ServiceModeHTTP{
HTTPS: true,
Port: 443,
})
if err != nil {
log.Fatal(err)
}
log.Printf("Listening on https://%v\n", ln.FQDN)
log.Fatal(http.Serve(ln, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "<html><body><h1>Hello, tailnet!</h1>")
})))
}
ExampleServer_ListenService_multiplePorts demonstrates how to advertise a Service on multiple ports. In this example, we run an HTTPS server on 443 and an HTTP server handling pprof requests to the same runtime on 6060.
package main
import (
"fmt"
"log"
"net/http"
"strings"
_ "net/http/pprof"
"tailscale.com/tsnet"
)
func main() {
srv := &tsnet.Server{
Hostname: "shu",
}
ln, err := srv.ListenService("svc:my-service", tsnet.ServiceModeHTTP{
HTTPS: true,
Port: 443,
})
if err != nil {
log.Fatal(err)
}
pprofLn, err := srv.ListenService("svc:my-service", tsnet.ServiceModeTCP{
Port: 6060,
})
if err != nil {
log.Fatal(err)
}
defer pprofLn.Close()
go func() {
log.Printf("Listening for pprof requests on http://%v:%d\n", pprofLn.FQDN, 6060)
handler := func(w http.ResponseWriter, r *http.Request) {
// The pprof listener is separate from our main server, so we can
// allow users to leave off the /debug/pprof prefix. We'll just
// attach it here, then pass along to the pprof handlers, which have
// been added implicitly due to our import of net/http/pprof.
if !strings.HasPrefix("/debug/pprof", r.URL.Path) {
r.URL.Path = "/debug/pprof" + r.URL.Path
}
http.DefaultServeMux.ServeHTTP(w, r)
}
if err := http.Serve(pprofLn, http.HandlerFunc(handler)); err != nil {
log.Fatal("error serving pprof:", err)
}
}()
log.Printf("Listening on https://%v\n", ln.FQDN)
// Specifying a handler here means pprof endpoints will not be served by
// this server (since we are not using http.DefaultServeMux).
log.Fatal(http.Serve(ln, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "<html><body><h1>Hello, tailnet!</h1>")
})))
}
ExampleServer_ListenService_reverseProxy demonstrates how to advertise a Service targeting a reverse proxy. This is useful when the backing server is external to the tsnet application.
package main
import (
"log"
"net/http"
"net/http/httputil"
"net/url"
"tailscale.com/tsnet"
)
func main() {
// targetAddress represents the address of the backing server.
const targetAddress = "1.2.3.4:80"
// We will use a reverse proxy to direct traffic to the backing server.
reverseProxy := httputil.NewSingleHostReverseProxy(&url.URL{
Scheme: "http",
Host: targetAddress,
})
srv := &tsnet.Server{
Hostname: "tefnut",
}
ln, err := srv.ListenService("svc:my-service", tsnet.ServiceModeHTTP{
HTTPS: true,
Port: 443,
})
if err != nil {
log.Fatal(err)
}
log.Printf("Listening on https://%v\n", ln.FQDN)
log.Fatal(http.Serve(ln, reverseProxy))
}
ListenTLS announces only on the Tailscale network. It returns a TLS listener wrapping the tsnet listener. It will start the server if it has not been started yet.
ExampleServer_ListenTLS shows you how to create a TCP listener on your tailnet and then makes an HTTPS server on top of that.
package main
import (
"fmt"
"log"
"net/http"
"tailscale.com/tsnet"
)
func main() {
srv := &tsnet.Server{
Hostname: "aegis",
}
ln, err := srv.ListenTLS("tcp", ":443")
if err != nil {
log.Fatal(err)
}
log.Fatal(http.Serve(ln, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hi there! Welcome to the tailnet!")
})))
}
LocalClient returns a LocalClient that speaks to s.
It will start the server if it has not been started yet. If the server's already been started successfully, it doesn't return an error.
LogtailWriter returns an io.Writer that writes to Tailscale's logging service and will be only visible to Tailscale's support team. Logs written there cannot be retrieved by the user. This method always returns a non-nil value.
Loopback starts a routing server on a loopback address.
The server has multiple functions.
It can be used as a SOCKS5 proxy onto the tailnet. Authentication is required with the username "tsnet" and the value of proxyCred used as the password.
The HTTP server also serves out the "LocalAPI" on /localapi. As the LocalAPI is powerful, access to endpoints requires BOTH passing a "Sec-Tailscale: localapi" HTTP header and passing localAPICred as basic auth.
If you only need to use the LocalAPI from Go, then prefer LocalClient as it does not require communication via TCP.
func (*Server) RegisterFallbackTCPHandler ¶ added in v1.52.0
func (s *Server) RegisterFallbackTCPHandler(cb FallbackTCPHandler) func()
RegisterFallbackTCPHandler registers a callback which will be called to handle a TCP flow to this tsnet node, for which no listeners will handle.
If multiple fallback handlers are registered, they will be called in an undefined order. See FallbackTCPHandler for details on handling a flow.
The returned function can be used to deregister this callback.
Start connects the server to the tailnet. Optional: any calls to Dial/Listen will also call Start.
ExampleServer_Start demonstrates the Start method, which should be called if you need to explicitly start it. Note that the Start method is implicitly called if needed.
package main
import (
"log"
"tailscale.com/tsnet"
)
func main() {
srv := new(tsnet.Server)
if err := srv.Start(); err != nil {
log.Fatal(err)
}
// Be sure to close the server instance at some point. It will stay open until
// either the OS process ends or the server is explicitly closed.
defer srv.Close()
}
Sys returns a handle to the Tailscale subsystems of this node.
This is not a stable API, nor are the APIs of the returned subsystems.
TailscaleIPs returns IPv4 and IPv6 addresses for this node. If the node has not yet joined a tailnet or is otherwise unaware of its own IP addresses, the returned ip4, ip6 will be !netip.IsValid().
Up connects the server to the tailnet and waits until it is running. On success it returns the current status, including a Tailscale IP address.
A ServiceListener is a network listener for a Tailscale Service. For more information about Services, see https://tailscale.com/kb/1552/tailscale-services
Addr returns the listener's network address. This will be the Service's fully-qualified domain name (FQDN) and the port.
A hostname is not truly a network address, but Services listen on multiple addresses (the IPv4 and IPv6 virtual IPs).
Close closes the listener and clears state related to hosting the Service. Behavior is undefined after the Server has been closed.
type ServiceMode interface {
}
ServiceMode defines how a Service is run. Currently supported modes are:
For more information, see Server.ListenService.
ServiceModeHTTP is used to configure an HTTP Service via Server.ListenService.
ServiceModeTCP is used to configure a TCP Service via Server.ListenService.