Documentation ¶
Overview ¶
Package derphttp implements DERP-over-HTTP.
This makes DERP look exactly like WebSockets. A server can implement DERP over HTTPS and even if the TLS connection intercepted using a fake root CA, unless the interceptor knows how to detect DERP packets, it will look like a web socket.
Index ¶
- Variables
- func Handler(s *derp.Server) http.Handler
- type Client
- func (c *Client) Close() error
- func (c *Client) Connect(ctx context.Context) error
- func (c *Client) DialRegionTLS(ctx context.Context, reg *tailcfg.DERPRegion) (tlsConn *tls.Conn, connClose io.Closer, err error)
- func (c *Client) NotePreferred(v bool)
- func (c *Client) Recv(b []byte) (derp.ReceivedMessage, error)
- func (c *Client) Send(dstKey key.Public, b []byte) error
Constants ¶
This section is empty.
Variables ¶
var ErrClientClosed = errors.New("derphttp.Client closed")
Functions ¶
Types ¶
type Client ¶
type Client struct { TLSConfig *tls.Config // optional; nil means default DNSCache *dnscache.Resolver // optional; nil means no caching // contains filtered or unexported fields }
Client is a DERP-over-HTTP client.
It automatically reconnects on error retry. That is, a failed Send or Recv will report the error and not retry, but subsequent calls to Send/Recv will completely re-establish the connection (unless Close has been called).
func NewClient ¶
NewClient returns a new DERP-over-HTTP client. It connects lazily. To trigger a connection, use Connect.
func NewNetcheckClient ¶ added in v0.98.1
NewNetcheckClient returns a Client that's only able to have its DialRegion method called. It's used by the netcheck package.
func NewRegionClient ¶ added in v0.98.1
func NewRegionClient(privateKey key.Private, logf logger.Logf, getRegion func() *tailcfg.DERPRegion) *Client
NewRegionClient returns a new DERP-over-HTTP client. It connects lazily. To trigger a connection, use Connect.
func (*Client) Close ¶
Close closes the client. It will not automatically reconnect after being closed.
func (*Client) Connect ¶
Connect connects or reconnects to the server, unless already connected. It returns nil if there was already a good connection, or if one was made.
func (*Client) DialRegionTLS ¶ added in v0.98.1
func (*Client) NotePreferred ¶
NotePreferred notes whether this Client is the caller's preferred (home) DERP node. It's only used for stats.