Documentation
¶
Overview ¶
Package carrier provides a WebSocket proxy to carry or proxy a connection from the local client to the edge. See it as a wrapper around any protocol that it packages up in a WebSocket connection to the edge.
Index ¶
- Constants
- func BuildAccessRequest(options *StartOptions, log *zerolog.Logger) (*http.Request, error)
- func IsAccessResponse(resp *http.Response) bool
- func ResolveBastionDest(r *http.Request) (string, error)
- func Serve(remoteConn Connection, listener net.Listener, shutdownC <-chan struct{}, ...) error
- func SetBastionDest(header http.Header, destination string)
- func StartClient(conn Connection, stream io.ReadWriter, options *StartOptions) error
- func StartForwarder(conn Connection, address string, shutdownC <-chan struct{}, ...) error
- type Connection
- type StartOptions
- type StdinoutStream
- type Websocket
Constants ¶
const ( LogFieldOriginURL = "originURL" CFAccessTokenHeader = "Cf-Access-Token" )
Variables ¶
This section is empty.
Functions ¶
func BuildAccessRequest ¶
BuildAccessRequest builds an HTTP request with the Access token set
func IsAccessResponse ¶
IsAccessResponse checks the http Response to see if the url location contains the Access structure.
func Serve ¶
func Serve(remoteConn Connection, listener net.Listener, shutdownC <-chan struct{}, options *StartOptions) error
Serve accepts incoming connections on the specified net.Listener. Each connection is handled in a new goroutine: its data is copied over a WebSocket connection to the edge (originURL). `Serve` always closes `listener`.
func SetBastionDest ¶
func StartClient ¶
func StartClient(conn Connection, stream io.ReadWriter, options *StartOptions) error
StartClient will copy the data from stdin/stdout over a WebSocket connection to the edge (originURL)
func StartForwarder ¶
func StartForwarder(conn Connection, address string, shutdownC <-chan struct{}, options *StartOptions) error
StartForwarder will setup a listener on a specified address/port and then forward connections to the origin by calling `Serve()`.
Types ¶
type Connection ¶
type Connection interface { // ServeStream is used to forward data from the client to the edge ServeStream(*StartOptions, io.ReadWriter) error }
Connection wraps up all the needed functions to forward over the tunnel
func NewWSConnection ¶
func NewWSConnection(log *zerolog.Logger) Connection
NewWSConnection returns a new connection object
type StartOptions ¶
type StdinoutStream ¶
type StdinoutStream struct{}
StdinoutStream is empty struct for wrapping stdin/stdout into a single ReadWriter
type Websocket ¶
type Websocket struct {
// contains filtered or unexported fields
}
Websocket is used to carry data via WS binary frames over the tunnel from client to the origin This implements the functions for glider proxy (sock5) and the carrier interface
func (*Websocket) ServeStream ¶
func (ws *Websocket) ServeStream(options *StartOptions, conn io.ReadWriter) error
ServeStream will create a Websocket client stream connection to the edge it blocks and writes the raw data from conn over the tunnel