sandwich

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: AGPL-3.0 Imports: 8 Imported by: 1

Documentation

Overview

Error defines all errors that may happen when using the Sandwich Go library. It uses the error codes defined in the protobuf.

io describes the Sandwich I/O interface. The I/O interface is used by the implementation to perform all i/o operation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ALPNError

type ALPNError struct {
	BaseError
}

ALPNError defines an error that may occur when ALPN Protocol is provided.

type APIError

type APIError struct {
	BaseError
}

APIError defines the first-class API errors, such as Context errors, Socket errors and Tunnel errors.

type ASN1Error

type ASN1Error struct {
	BaseError
}

ASN1Error defines an error that may occur when a malformed ASN.1 document is provided.

type BaseError

type BaseError struct {
	// contains filtered or unexported fields
}

BaseError represents the base structure for all Sandwich errors.

func (*BaseError) Code

func (err *BaseError) Code() int32

Code implements the Error interface.

func (*BaseError) Error

func (err *BaseError) Error() string

Error implements the error interface.

func (*BaseError) Unwrap

func (err *BaseError) Unwrap() error

Unwrap implements the Error interface.

type CertificateError

type CertificateError struct {
	BaseError
}

CertificateError defines an error that may occur when a configuration supplies a certificate that is malformed.

type ConfigurationError

type ConfigurationError struct {
	BaseError
}

ConfigurationError defines an error that may occur when a protobuf configuration is malformed.

type DataSourceError

type DataSourceError struct {
	BaseError
}

DataSourceError defines an error that may occur when a configuration provided a malformed DataSource.

type Error

type Error interface {
	// Error extends the builtin `error` interface.
	error
	// `Code` returns the error code, defined in the protobuf.
	Code() int32

	// `Unwrap` unwraps the next error. It is meant to be used with the `errors`
	// package.
	Unwrap() error
	// contains filtered or unexported methods
}

Error represents the interface for all Sandwich errors.

type HandshakeError

type HandshakeError struct {
	BaseError
}

HandshakeError defines errors that can happen during the handshake stage. These errors are defined by the enum `HandshakeError` in `errors.proto`. They are used by `Tunnel.Handshake`.

type HandshakeStateError

type HandshakeStateError struct {
	BaseError
}

HandshakeStateError defines errors that take place during the handshake stage. These states are defined by the enum `HandshakeState` in `tunnel.proto`. They are used by `Tunnel.Handshake`.

type IO

type IO interface {
	// Read reads data from the connection.
	Read(b []byte, tunnel_state pb.State) (n int, err *IOError)

	// Write writes data from the connection.
	Write(b []byte, tunnel_state pb.State) (n int, err *IOError)
}

IO represents the I/O interface used by Sandwich.

type IOError

type IOError struct {
	BaseError
}

IOError defines the error that can happens during the i/o operations done by an I/O interface. These errors are defined by the enum `IOError` in `io.proto`.

func IOTCPClient

func IOTCPClient(hostname string, port uint16, is_blocking bool) (*swOwnedIOWrapper, *IOError)

Creates a Sandwich owned TCP based IO Object.

func NewIOError

func NewIOError(code int32, msg string) *IOError

NewIOError creates an error from an error code. The error code is supposed to match a key in `ioErrorMap`, defined above. This function is publicly exposed, as it is meant to be used by the user to implement their own I/O interface.

func NewIOErrorFromEnum

func NewIOErrorFromEnum(err pb.IOError) *IOError

NewIOErrorFromEnum creates an error from the enum pb.IOError.

type IORWWrapper

type IORWWrapper struct {
	// contains filtered or unexported fields
}

--8<-- [start:go_io_rw] Wraps an io.ReadWriter object WARNING: errors are hard to map as they are just strings. So far, every error returns a generic IOError_IOERROR_UNKNOWN error code.

func IOWrapRW

func IOWrapRW(conn io.ReadWriter) IORWWrapper

func (*IORWWrapper) Read

func (c *IORWWrapper) Read(b []byte, tunnel_state pb.State) (int, *IOError)

func (*IORWWrapper) Write

func (c *IORWWrapper) Write(b []byte, tunnel_state pb.State) (int, *IOError)

type KEMError

type KEMError struct {
	BaseError
}

KEMError defines an error that may occur when a KEM is invalid or unsupported.

type PrivateKeyError

type PrivateKeyError struct {
	BaseError
}

PrivateKeyError defines an error that may occur when a configuration supplies a private key that is malformed.

type ProtobufError

type ProtobufError struct {
	BaseError
}

ProtobufError defines an error that may occur when the protobuf message is malformed.

type RecordPlaneError

type RecordPlaneError struct {
	BaseError
}

RecordPlaneError defines the error that can happens during the record plane. These errors are defined by the enum `RecordError` in `tunnel.proto`. They are used by `Tunnel.Write` and `Tunnel.Read`.

type SocketError

type SocketError struct {
	BaseError
}

SocketError defines an error that may occur in the I/O socket interface.

type SystemError

type SystemError struct {
	BaseError
}

SystemError defines an error that may occur when a system error is encountered, such as a memory allocation failure.

type TLSConfigurationError

type TLSConfigurationError struct {
	BaseError
}

TLSConfigurationError defines an error that may occur when a protobuf configuration using the TLS protocol is malformed.

type Tunnel

type Tunnel struct {
	// contains filtered or unexported fields
}

Tunnel wraps a `struct SandwichTunnel *` and exposes its methods.

func NewTunnel

func NewTunnel(ctx *TunnelContext, io IO, configuration *api.TunnelConfiguration) (*Tunnel, error)

NewTunnel creates a Sandwich tunnel from a context, an io and a configuration.

func (*Tunnel) Close

func (tun *Tunnel) Close() error

Close closes the tunnel.

func (*Tunnel) Handshake

func (tun *Tunnel) Handshake() error

Handshakes performs or resumes the handshake stage. If nil is returned, it means the handshake is done.

func (*Tunnel) IO

func (tun *Tunnel) IO() *IO

IO returns the IO interface used by a tunnel. The interface is borrowed to the user. Its ownership remains to the Tunnel.

func (*Tunnel) Read

func (tun *Tunnel) Read(b []byte) (int, error)

Read implements the io.Reader interface.

func (*Tunnel) State

func (tun *Tunnel) State() pb.State

State returns the state of the tunnel.

func (*Tunnel) Write

func (tun *Tunnel) Write(b []byte) (int, error)

Write implements the io.Reader interface.

type TunnelContext

type TunnelContext struct {
	// contains filtered or unexported fields
}

TunnelContext wraps a `struct Context *` and exposes few methods for convenience.

func NewTunnelContext

func NewTunnelContext(configuration *api.Configuration) (*TunnelContext, error)

NewTunnelContext fills a Sandwich context from a protobuf configuration.

Directories

Path Synopsis
c module
errors module
io module
proto
tunnel module

Jump to

Keyboard shortcuts

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