l1

package
v0.0.0-...-05bc493 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const MaxUDPSize = 2048

const MinUdpSize = 1300

Variables

This section is empty.

Functions

func DialTCPWithReuse

func DialTCPWithReuse(network string, laddr, raddr *net.TCPAddr) (*net.TCPConn, error)

func DialerTCPWithReuse

func DialerTCPWithReuse(laddr *net.TCPAddr) *net.Dialer

func ListenTCPWithReuse

func ListenTCPWithReuse(network string, laddr *net.TCPAddr) (*net.TCPListener, error)

Types

type BasicOutTransport

type BasicOutTransport interface {
	Send(payload io.WriterTo) error
	SendBytes(b []byte) error
}

type FuncMapOneWayTransport

type FuncMapOneWayTransport func(OneWayTransport) OneWayTransport

type FuncMapOutputFactory

type FuncMapOutputFactory func(OutTransportFactory) OutTransportFactory

type MappedOutputTransportFactory

type MappedOutputTransportFactory struct {
	OutTransportFactory
	// contains filtered or unexported fields
}

func (*MappedOutputTransportFactory) ConnectTo

type MappedSessionfullTransportProvider

type MappedSessionfullTransportProvider struct {
	SessionfulTransportProvider
	// contains filtered or unexported fields
}

func (*MappedSessionfullTransportProvider) CreateListeningFactory

func (*MappedSessionfullTransportProvider) CreateOutgoingOnlyFactory

type MappedSessionlessTransportProvider

type MappedSessionlessTransportProvider struct {
	SessionlessTransportProvider
	// contains filtered or unexported fields
}

func (*MappedSessionlessTransportProvider) CreateListeningFactory

func (*MappedSessionlessTransportProvider) CreateListeningFactoryWithAddress

func (m *MappedSessionlessTransportProvider) CreateListeningFactoryWithAddress(fun SessionlessReceiveFunc, addr nwapi.Address) (OutTransportFactory, error)

func (*MappedSessionlessTransportProvider) CreateOutgoingOnlyFactory

func (m *MappedSessionlessTransportProvider) CreateOutgoingOnlyFactory() (OutTransportFactory, error)

type OneWayTransport

type OneWayTransport interface {
	BasicOutTransport
	io.Closer
	GetTag() int
	SetTag(int)

	WithQuota(ratelimiter.RateQuota) OneWayTransport
}

type OutNetTransport

type OutNetTransport interface {
	io.ReaderFrom
	io.Writer
	OneWayTransport
	NetConn() net.Conn
}

type OutTransportFactory

type OutTransportFactory interface {
	// ConnectTo resolves provided address and makes a connection
	// Can return (nil, nil) when the given address is of unsupported type.
	ConnectTo(nwapi.Address) (OneWayTransport, error)
	Close() error
}

OutTransportFactory represents a generic factory to create/open an outgoing connection.

func MapOutputFactory

func MapOutputFactory(factory OutTransportFactory, mappingFunc FuncMapOneWayTransport) OutTransportFactory

type SemiTransport

type SemiTransport interface {
	TwoWayTransport

	// ConnectReceiver can be used to connect receive side of this transport. It can only be called once.
	// When param is (nil) it will use a receiver func of its factory.
	// Returns result of the applied SessionfulConnectFunc and a relevant transport.
	// Will return (false, nil) when operation is not available, e.g. on repeated call.
	ConnectReceiver(SessionfulConnectFunc) (bool, TwoWayTransport)
}

SemiTransport represents a bi-directional transport without a receiving logic attached yet.

type SessionfulConnectFunc

type SessionfulConnectFunc func(local, remote nwapi.Address, conn io.ReadWriteCloser, w OneWayTransport, err error) (ok bool)

SessionfulConnectFunc receives either inbound connection(s) from listen or inbound direction of an outgoing connection. Param (w) is not nil for an inbound connection (for an outbound connection it is returned by ConnectTo). Param (conn) is a raw bi-directional connection.

type SessionfulTransportProvider

type SessionfulTransportProvider interface {
	// CreateListeningFactory starts listening and provides OutTransportFactory that has same local address as the listening socket.
	// Param (SessionfulConnectFunc) is to handle either inbound connection(s) from listen or inbound direction of an outgoing connection.
	CreateListeningFactory(SessionfulConnectFunc) (OutTransportFactory, nwapi.Address, error)
	// CreateOutgoingOnlyFactory creates a factory to open outgoing connections.
	// Param (SessionfulConnectFunc) is to handle inbound flow of an outgoing connection.
	CreateOutgoingOnlyFactory(SessionfulConnectFunc) (OutTransportFactory, error)
	Close() error
}

SessionfulTransportProvider is a meta-factory for session-full, bi-directional connections like TCP and TLS.

func NewTCP

func NewTCP(binding nwapi.Address, preference nwapi.Preference) SessionfulTransportProvider

func NewTLS

func NewTLS(binding nwapi.Address, preference nwapi.Preference, config *tls.Config) SessionfulTransportProvider

type SessionlessReceiveFunc

type SessionlessReceiveFunc func(local, remote nwapi.Address, b []byte, err error) (ok bool)

SessionlessReceiveFunc MUST NOT reuse (b) after return

type SessionlessTransportProvider

type SessionlessTransportProvider interface {
	// CreateListeningFactory starts listening and provides OutTransportFactory that has same local address as the listening socket.
	// Param (SessionlessReceiveFunc) is to handle inbound datagrams.
	CreateListeningFactory(SessionlessReceiveFunc) (OutTransportFactory, nwapi.Address, error)
	// CreateListeningFactoryWithAddress is similar to CreateListeningFactory but uses the given address. Provided address must have port.
	CreateListeningFactoryWithAddress(SessionlessReceiveFunc, nwapi.Address) (OutTransportFactory, error)
	// CreateOutgoingOnlyFactory creates a factory to open outgoing connections.
	CreateOutgoingOnlyFactory() (OutTransportFactory, error)
	// MaxByteSize returns a maximum size of a supported/deliverable datagram.
	MaxByteSize() uint16
	Close() error
}

SessionlessTransportProvider is a meta-factory for session-less, one-way connections like UDP

func NewUDP

func NewUDP(binding nwapi.Address, preference nwapi.Preference, maxByteSize uint16) SessionlessTransportProvider

type TwoWayTransport

type TwoWayTransport interface {
	OneWayTransport

	// TwoWayConn returns an underlying two-way connection. Only applies to a sessionful transport.
	TwoWayConn() io.ReadWriteCloser
}

type VerifyPeerCertificateFunc

type VerifyPeerCertificateFunc func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error

VerifyPeerCertificateFunc verifies raw and pre-verified certs from a connection. Errors should be returned when credentials aren't allowed to connect.

Jump to

Keyboard shortcuts

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