controlbase
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
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¶
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) HandshakeHash() [blake2s.Size]byte
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) Peer() key.MachinePublic
- func (c *Conn) ProtocolVersion() int
- func (c *Conn) Read(bs []byte) (int, error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) SetDeadline(t time.Time) error
- func (c *Conn) SetReadDeadline(t time.Time) error
- func (c *Conn) SetWriteDeadline(t time.Time) error
- func (c *Conn) Write(bs []byte) (n int, err error)
- type HandshakeContinuation
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)HandshakeHash¶
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)Peer¶
func (c *Conn) Peer()key.MachinePublic
Peer returns the peer's long-term public key.
func (*Conn)ProtocolVersion¶
ProtocolVersion returns the protocol version that was used toestablish this Conn.
func (*Conn)RemoteAddr¶
typeHandshakeContinuation¶
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.