fan

package
v0.0.39 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RedirectFanIn

func RedirectFanIn(Context context.Context, ChannelPool *ActiveChannelPool, FanInReceiver Receiver, FanInSender Sender, TunnelInitialier TunnelInitialier) error

RedirectFanIn will keep calling `FanInReceiver` to get a packet including data and a sender ID. Bridge the connection initialized with `TunnelInitialier` and returns its response back through `FanInSender`.

Types

type ActiveChannelPool added in v0.0.27

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

ActiveChannelPool keeps tracks of active UDP connections.

func NewChannelPool added in v0.0.27

func NewChannelPool(Context context.Context, Config *RedirectionConfig) *ActiveChannelPool

NewChannelPool creates a shared pool to store active connections safely.

type Receiver

type Receiver func([]byte) (int, int, string, error)

Receiver takes an empty buffer as input, returns from which offset to start, the end offset, the identifier of the sender, or an error.

type RedirectionConfig

type RedirectionConfig struct {
	// The timeout of a connection in idle state.
	Timeout time.Duration
	// FanIn function will allocate buffer in `BufferSize` while listening. A too large size might cause OOMing.
	BufferSize int64
}

RedirectionConfig specifies the configuration of stateless fan-in forwarding.

type Sender

type Sender func([]byte, string) (int, error)

Sender takes a sender ID and bytes to be sent as input parameters, returns the number of bytes writen or an error.

type TunnelInitialier

type TunnelInitialier func(string) (net.Conn, error)

TunnelInitialier takes a sender ID as an input parameter, returns the bridged connection or an error.

Jump to

Keyboard shortcuts

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