base

package
v0.0.0-...-b59c172 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: BSD-2-Clause, BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package base provides the common interface that each supported transport protocol must implement.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientFactory

type ClientFactory interface {
	// Transport returns the Transport instance that this ClientFactory belongs
	// to.
	Transport() Transport

	// ParseArgs parses the supplied arguments into an internal representation
	// for use with WrapConn.  This routine is called before the outgoing
	// TCP/IP connection is created to allow doing things (like keypair
	// generation) to be hidden from third parties.
	ParseArgs(args *pt.Args) (interface{}, error)

	// Dial creates an outbound net.Conn, and does whatever is required
	// (eg: handshaking) to get the connection to the point where it is
	// ready to relay data.
	Dial(network, address string, dialFn DialFunc, args interface{}) (net.Conn, error)
}

ClientFactory is the interface that defines the factory for creating pluggable transport protocol client instances.

type DialFunc

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

type ServerFactory

type ServerFactory interface {
	// Transport returns the Transport instance that this ServerFactory belongs
	// to.
	Transport() Transport

	// Args returns the Args required on the client side to handshake with
	// server connections created by this factory.
	Args() *pt.Args

	// WrapConn wraps the provided net.Conn with a transport protocol
	// implementation, and does whatever is required (eg: handshaking) to get
	// the connection to a point where it is ready to relay data.
	WrapConn(conn net.Conn) (net.Conn, error)
}

ServerFactory is the interface that defines the factory for creating plugable transport protocol server instances. As the arguments are the property of the factory, validation is done at factory creation time.

type Transport

type Transport interface {
	// Name returns the name of the transport protocol.  It MUST be a valid C
	// identifier.
	Name() string

	// ClientFactory returns a ClientFactory instance for this transport
	// protocol.
	ClientFactory(stateDir string) (ClientFactory, error)

	// ServerFactory returns a ServerFactory instance for this transport
	// protocol.  This can fail if the provided arguments are invalid.
	ServerFactory(stateDir string, args *pt.Args) (ServerFactory, error)
}

Transport is an interface that defines a pluggable transport protocol.

Jump to

Keyboard shortcuts

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