Documentation
¶
Overview ¶
Package tsp provides a client for speaking the Tailscale protocol to a coordination server over Noise.
Index ¶
- Constants
- func DiscoverServerKey(ctx context.Context, serverURL string) (key.MachinePublic, error)
- type Client
- func (c *Client) AnswerC2NPing(ctx context.Context, pr *tailcfg.PingRequest, ...) (handled bool)
- func (c *Client) Close() error
- func (c *Client) DiscoverServerKey(ctx context.Context) (key.MachinePublic, error)
- func (c *Client) Map(ctx context.Context, opts MapOpts) (*MapSession, error)
- func (c *Client) Register(ctx context.Context, opts RegisterOpts) (*tailcfg.RegisterResponse, error)
- func (c *Client) SetControlPublicKey(k key.MachinePublic)
- type ClientOpts
- type MapOpts
- type MapSession
- type RegisterOpts
Constants ¶
const DefaultServerURL = ipn.DefaultControlURL
DefaultServerURL is the default coordination server base URL, used when ClientOpts.ServerURL is empty.
Variables ¶
This section is empty.
Functions ¶
func DiscoverServerKey ¶
DiscoverServerKey fetches the coordination server's public key from the given server URL. It is a standalone function that requires no client state.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a Tailscale protocol client that speaks to a coordination server over Noise.
func NewClient ¶
func NewClient(opts ClientOpts) (*Client, error)
NewClient creates a new Client configured to talk to the coordination server specified in opts. It performs no I/O; the server's public key is discovered lazily on first use or can be set explicitly via SetControlPublicKey.
func (*Client) AnswerC2NPing ¶
func (c *Client) AnswerC2NPing(ctx context.Context, pr *tailcfg.PingRequest, doNoiseRequest func(*http.Request) (*http.Response, error)) (handled bool)
AnswerC2NPing handles a c2n PingRequest from the control plane by parsing the embedded HTTP request in the payload, routing it locally, and POSTing the HTTP response back to pr.URL using doNoiseRequest. The POST is done in a new goroutine so this method does not block.
It reports whether the ping was handled. Unhandled pings (nil pr, non-c2n types, or unrecognized c2n paths) return false.
func (*Client) DiscoverServerKey ¶
DiscoverServerKey fetches the server's public key from the coordination server and stores it for subsequent use. Any existing noise client is invalidated.
func (*Client) Map ¶
Map sends a map request to the coordination server and returns a MapSession for reading the framed, zstd-compressed response(s).
func (*Client) Register ¶
func (c *Client) Register(ctx context.Context, opts RegisterOpts) (*tailcfg.RegisterResponse, error)
Register sends a registration request to the coordination server and returns the response.
func (*Client) SetControlPublicKey ¶
func (c *Client) SetControlPublicKey(k key.MachinePublic)
SetControlPublicKey sets the server's public key, bypassing lazy discovery. Any existing noise client is invalidated and will be re-created on next use.
type ClientOpts ¶
type ClientOpts struct {
// ServerURL is the base URL of the coordination server
// (e.g. "https://controlplane.tailscale.com").
// If empty, DefaultServerURL is used.
ServerURL string
// MachineKey is this node's machine private key. Required.
MachineKey key.MachinePrivate
// Logf is the log function. If nil, logger.Discard is used.
Logf logger.Logf
}
ClientOpts contains options for creating a new Client.
type MapOpts ¶
type MapOpts struct {
// NodeKey is the node's private key. Required.
NodeKey key.NodePrivate
// Hostinfo is the host information to send. Optional;
// if nil, a minimal default is used.
Hostinfo *tailcfg.Hostinfo
// Stream is whether to receive multiple MapResponses over
// the same HTTP connection.
Stream bool
// OmitPeers is whether the client is okay with the Peers list
// being omitted in the response.
OmitPeers bool
}
MapOpts contains options for sending a map request.
type MapSession ¶
type MapSession struct {
// contains filtered or unexported fields
}
MapSession wraps an in-progress map response stream. Call Next to read each framed, zstd-compressed MapResponse. Call Close when done.
func (*MapSession) Close ¶
func (s *MapSession) Close() error
Close closes the underlying HTTP response body.
func (*MapSession) Next ¶
func (s *MapSession) Next() (*tailcfg.MapResponse, error)
Next reads and returns the next MapResponse from the stream. For non-streaming sessions, the first call returns the single response and subsequent calls return io.EOF. For streaming sessions, Next blocks until the next response arrives or the server closes the connection.
func (*MapSession) NoiseRoundTrip ¶
NoiseRoundTrip sends an HTTP request over the Noise channel used by this map session.
type RegisterOpts ¶
type RegisterOpts struct {
// NodeKey is the node's private key. Required.
NodeKey key.NodePrivate
// Hostinfo is the host information to send. Optional;
// if nil, a minimal default is used.
Hostinfo *tailcfg.Hostinfo
// Ephemeral marks the node as ephemeral.
Ephemeral bool
// AuthKey is a pre-authorized auth key.
AuthKey string
// Tags is a list of ACL tags to request.
Tags []string
}
RegisterOpts contains options for registering a node.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
tsp
command
Program tsp is a low-level Tailscale protocol tool for performing composable building block operations like generating keys and registering nodes.
|
Program tsp is a low-level Tailscale protocol tool for performing composable building block operations like generating keys and registering nodes. |