tsnetserver

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FunnelClientIP

func FunnelClientIP(r *http.Request) string

FunnelClientIP returns the IP of the client invoking over Tailscale Funnel. If the request is not coming through a Tailscale Funnel, the result is empty.

func IsFunneledRequest

func IsFunneledRequest(r *http.Request) bool

IsFunneledRequest returns true if the HTTP request is coming over Tailscale Funnel, as opposed to a direct connection.

Types

type NewTSNetServerOpts

type NewTSNetServerOpts struct {
	// Hostname for the node
	Hostname string

	// Auth key
	// This is only used on first startup (or if the node key has expired and it needs to be re-authenticated)
	// If this is empty, the auth key can also be read from the TS_AUTH_KEY env var or users can use interactive login
	AuthKey string

	// If true, makes the node ephemeral
	Ephemeral bool

	// Directory where to store tsnet's state
	StateDir string

	// Optional store for the IPN state
	// Note that even when using a store, tsnet still needs to write data in StateDir
	Store ipn.StateStore

	// Tags that should be applied to this node in the tailnet, for purposes of ACL enforcement.
	// These can be referenced from the ACL policy document.
	// Tags are generally required when a node is authenticated using OAuth2.
	AdvertiseTags []string

	// Enables debug logging
	DebugLogging bool
}

NewTSNetServerOpts contains options for NewTSNetServer

type TSNetServer

type TSNetServer struct {
	// contains filtered or unexported fields
}

TSNetServer wraps a tsnet.Server for use in the application

func NewTSNetServer

func NewTSNetServer(ctx context.Context, opts NewTSNetServerOpts) (*TSNetServer, error)

NewTSNetServer creates a new TSNetServer instance

func (*TSNetServer) Close

func (t *TSNetServer) Close(_ context.Context) error

Close closes the tsnet server

func (*TSNetServer) ConnContextFn

func (t *TSNetServer) ConnContextFn() func(ctx context.Context, c net.Conn) context.Context

ConnContextFn returns a function that can be passed to http.Server.Conn

func (*TSNetServer) Hostname

func (t *TSNetServer) Hostname() string

func (*TSNetServer) Listen

func (t *TSNetServer) Listen(port int) (net.Listener, error)

func (*TSNetServer) ListenFunnel

func (t *TSNetServer) ListenFunnel(port int) (net.Listener, error)

func (*TSNetServer) LocalClient

func (t *TSNetServer) LocalClient() (*local.Client, error)

func (*TSNetServer) TailscaleIPs

func (t *TSNetServer) TailscaleIPs() (ip4 string, ip6 string)

func (*TSNetServer) WhoIs

func (t *TSNetServer) WhoIs(r *http.Request) (res TailscaleWhoIs, err error)

WhoIs performs a "whois" request with the LocalClient and returns information about the node WhoIs is only valid for direct tailnet connections For Funnel connections the remote address is the relay, not the real client (use FunnelClientIP instead)

type TailscaleWhoIs

type TailscaleWhoIs struct {
	NodeID        string             `json:"nodeId"`
	Name          string             `json:"name"`
	Hostname      string             `json:"hostname"`
	IP4           string             `json:"ip4"`
	IP6           string             `json:"ip6"`
	UserLoginName string             `json:"userLoginName,omitempty"`
	Tags          []string           `json:"tags,omitempty"`
	CapMap        tailcfg.PeerCapMap `json:"capMap,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL