proxyproto

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package proxyproto contains the core types for interactions between the kvdi API and desktop proxy instances. Subpackages contain client and server implementations.

The original implementation involved the proxies serving full HTTP/Websocket servers and the API simply proxying requests back to them. The purpose of proxyproto is to have more control over the interaction and reduce overhead as much as possible. For example, an audio proxy just involves one byte being transmitted back and forth (after TLS negotiation) before the stream can start, instead of the overhead of a second HTTP request and Websocket upgrade.

I'm obviously not going to write a full RFC for this protocol, but it should definitely at least have its capabilities documented further.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

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

Conn represents a single connection between the app and proxy. It embeds a net.Conn and exports additional methods for parsing and reading the purpose of the request as well as tracking connection metrics.

func Dial

func Dial(logger logr.Logger, addr string, rtype RequestType) (*Conn, error)

Dial dials the given server and initializes a new client connection for the given request type.

func NewConn

func NewConn(logger logr.Logger, c net.Conn) (*Conn, error)

NewConn takes a new client connection, reads the type of request off the wire, and wraps it in a Conn object for processing.

func (*Conn) BytesRecvdCount

func (c *Conn) BytesRecvdCount() int64

BytesRecvdCount returns the total number of bytes read on the connection so far.

func (*Conn) BytesSentCount

func (c *Conn) BytesSentCount() int64

BytesSentCount returns the total number of bytes written to the connection so far.

func (*Conn) Read

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

Read wraps the underlying Conn reader and tracks bytes read over the life of the connection.

func (*Conn) ReadStatus

func (c *Conn) ReadStatus() error

ReadStatus reads the status header off the wire, and if not equal to RequestOK, creates an error with the sent message.

func (*Conn) ReadStructure

func (c *Conn) ReadStructure(req interface{}) error

ReadStructure reads from the wire into the given request object. It must be a request object provided by this package containing a recv() method.

func (*Conn) RequestType

func (c *Conn) RequestType() RequestType

RequestType returns the type of the request for this connection.

func (*Conn) Write

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

Write wraps the underlying Conn writer and tracks bytes written over the life of the connection.

func (*Conn) WriteError

func (c *Conn) WriteError(err error)

WriteError writes the given error to the wire.

func (*Conn) WriteResponse

func (c *Conn) WriteResponse(res interface{})

WriteResponse is a convenience wrapper for writing a RequestOK followed by the given structure.

func (*Conn) WriteStatus

func (c *Conn) WriteStatus(st RequestStatus) error

WriteStatus attempts to write the given status byte to the connection.

func (*Conn) WriteStructure

func (c *Conn) WriteStructure(res interface{}) error

WriteStructure writes the given response object to the wire. It must be a response structure declared in this package with a send() method.

type FGetRequest

type FGetRequest struct {
	Path string
}

FGetRequest contains the parameters for sending a get file request to a proxy.

func (*FGetRequest) String

func (f *FGetRequest) String() string

type FGetResponse

type FGetResponse struct {
	Name string
	Type string
	Size int64
	Body io.ReadCloser
}

FGetResponse contains the response to a get file request.

type FPutRequest

type FPutRequest struct {
	Name string
	Size int64
	Body io.ReadCloser
}

FPutRequest contains the parameters for uploading a file to the desktop.

func (*FPutRequest) String

func (f *FPutRequest) String() string

type FStatRequest

type FStatRequest struct {
	Path string
}

FStatRequest contains the parameters for sending a stat request to a proxy.

func (*FStatRequest) String

func (f *FStatRequest) String() string

type RequestStatus

type RequestStatus byte

RequestStatus represents the non-wire related status of a request.

const (

	// RequestOK means the request succeeded and everything following on the wire is the response
	RequestOK RequestStatus
	// RequestFailed means the request failed and a string representing the error is next on the wire.
	RequestFailed
)

type RequestType

type RequestType byte

RequestType represents the type of request being made from a client to a proxy.

const (

	// RequestTypeDisplay is a request for an interactive display feed.
	RequestTypeDisplay RequestType
	// RequestTypeAudio is a request for a bidirectional audio feed.
	RequestTypeAudio
	// RequestTypeFStat is a request for stat information for a file in the system.
	RequestTypeFStat
	// RequestTypeFGet is a request to retrieve a file from the system.
	RequestTypeFGet
	// RequestTypeFPut is a request to put a file on the system.
	RequestTypeFPut
)

func (RequestType) String

func (r RequestType) String() string

Directories

Path Synopsis
Package client contains a client implementation for making requests against desktop proxy instances.
Package client contains a client implementation for making requests against desktop proxy instances.
Package server contains the server for handling requests against a desktop's proxy instance.
Package server contains the server for handling requests against a desktop's proxy instance.

Jump to

Keyboard shortcuts

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