Movatterモバイル変換


[0]ホーム

URL:


controlbase

package
v1.92.3Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License:BSD-3-ClauseImports:18Imported by:10

Details

Repository

github.com/tailscale/tailscale

Links

Documentation

Overview

Package controlbase implements the base transport of the Tailscale2021 control protocol.

The base transport implements Noise IK, instantiated withCurve25519, ChaCha20Poly1305 and BLAKE2s.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

typeConn

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

A Conn is a secured Noise connection. It implements the net.Conninterface, with the unusual trait that any write error (including aSetWriteDeadline induced i/o timeout) causes all future writes tofail.

funcClient

func Client(ctxcontext.Context, connnet.Conn, machineKeykey.MachinePrivate, controlKeykey.MachinePublic, protocolVersionuint16) (*Conn,error)

Client wraps ClientDeferred and immediately invokes the returnedcontinuation with conn.

This is a helper for when you don't need the fancycontinuation-style handshake, and just want to synchronouslyupgrade a net.Conn to a secure transport.

funcServer

func Server(ctxcontext.Context, connnet.Conn, controlKeykey.MachinePrivate, optionalInit []byte) (*Conn,error)

Server initiates a control server handshake, returning the resultingcontrol connection.

optionalInit can be the client's initial handshake message asreturned by ClientDeferred, or nil in which case the initialmessage is read from conn.

The context deadline, if any, covers the entire handshakingprocess.

func (*Conn)Close

func (c *Conn) Close()error

Close implements io.Closer.

func (*Conn)HandshakeHash

func (c *Conn) HandshakeHash() [blake2s.Size]byte

HandshakeHash returns the Noise handshake hash for the connection,which can be used to bind other messages to this connection(i.e. to ensure that the message wasn't replayed from a differentconnection).

func (*Conn)LocalAddr

func (c *Conn) LocalAddr()net.Addr

func (*Conn)Peer

func (c *Conn) Peer()key.MachinePublic

Peer returns the peer's long-term public key.

func (*Conn)ProtocolVersion

func (c *Conn) ProtocolVersion()int

ProtocolVersion returns the protocol version that was used toestablish this Conn.

func (*Conn)Read

func (c *Conn) Read(bs []byte) (int,error)

Read implements io.Reader.

func (*Conn)RemoteAddr

func (c *Conn) RemoteAddr()net.Addr

func (*Conn)SetDeadline

func (c *Conn) SetDeadline(ttime.Time)error

func (*Conn)SetReadDeadline

func (c *Conn) SetReadDeadline(ttime.Time)error

func (*Conn)SetWriteDeadline

func (c *Conn) SetWriteDeadline(ttime.Time)error

func (*Conn)Write

func (c *Conn) Write(bs []byte) (nint, errerror)

Write implements io.Writer.

typeHandshakeContinuation

type HandshakeContinuation func(context.Context,net.Conn) (*Conn,error)

HandshakeContinuation upgrades a net.Conn to a Conn. The net.Connis assumed to have already sent the client>server handshakeinitiation message.

funcClientDeferred

func ClientDeferred(machineKeykey.MachinePrivate, controlKeykey.MachinePublic, protocolVersionuint16) (initialHandshake []byte, continueHandshakeHandshakeContinuation, errerror)

ClientDeferred initiates a control client handshake, returning theinitial message to send to the server and a continuation tofinalize the handshake.

ClientDeferred is split in this way for RTT reduction: we run thisprotocol after negotiating a protocol switch from HTTP/HTTPS. If wecompletely serialized the negotiation followed by the handshake,we'd pay an extra RTT to transmit the handshake initiation afterprotocol switching. By splitting the handshake into an initialmessage and a continuation, we can embed the handshake initiationinto the HTTP protocol switching request and avoid a bit of delay.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp