carrier

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

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

View Source
const (
	LogFieldOriginURL   = "originURL"
	CFAccessTokenHeader = "Cf-Access-Token"
)

Variables

This section is empty.

Functions

func BuildAccessRequest

func BuildAccessRequest(options *StartOptions, log *zerolog.Logger) (*http.Request, error)

BuildAccessRequest builds an HTTP request with the Access token set

func IsAccessResponse

func IsAccessResponse(resp *http.Response) bool

IsAccessResponse checks the http Response to see if the url location contains the Access structure.

func ResolveBastionDest

func ResolveBastionDest(r *http.Request) (string, error)

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 SetBastionDest(header http.Header, destination string)

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 StartOptions struct {
	AppInfo         *token.AppInfo
	OriginURL       string
	Headers         http.Header
	Host            string
	TLSClientConfig *tls.Config
}

type StdinoutStream

type StdinoutStream struct{}

StdinoutStream is empty struct for wrapping stdin/stdout into a single ReadWriter

func (*StdinoutStream) Read

func (c *StdinoutStream) Read(p []byte) (int, error)

Read will read from Stdin

func (*StdinoutStream) Write

func (c *StdinoutStream) Write(p []byte) (int, error)

Write will write to Stdout

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL