transport

package
v0.0.0-...-7851fa2 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConnectTimeout     = time.Second * 10
	RTTMeasureInterval = time.Second * 3
)

Variables

View Source
var (
	ErrClosed        = fmt.Errorf("transport is already closed")
	ErrNoDirect      = fmt.Errorf("cannot open direct quic connection without address")
	ErrNoCertificate = fmt.Errorf("no verified certificate was provided")
)

Functions

This section is empty.

Types

type ClientTransport

type ClientTransport interface {
	Transport
	WithClientCertificate(cert tls.Certificate) error
}

type ConnectedPeer

type ConnectedPeer struct {
	Identity *protocol.Node
	Addr     net.Addr
}

type DatagramDelegate

type DatagramDelegate struct {
	Identity *protocol.Node
	Buffer   []byte
}

type StreamDelegate

type StreamDelegate struct {
	net.Conn                         // The backing bytes stream of the delegation
	Certificate *x509.Certificate    // The verified peer certificate, if any
	Identity    *protocol.Node       // The identity that the peer claims to be. Implementation may use mTLS to verify
	Kind        protocol.Stream_Type // Type of the bytes stream of the delegation
}

type StreamHandler

type StreamHandler func(delegate *StreamDelegate)

type StreamRouter

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

func NewStreamRouter

func NewStreamRouter(logger *zap.Logger, chordTransport, tunnelTransport Transport) *StreamRouter

func (*StreamRouter) Accept

func (s *StreamRouter) Accept(ctx context.Context)

func (*StreamRouter) HandleChord

func (s *StreamRouter) HandleChord(kind protocol.Stream_Type, target *protocol.Node, handler StreamHandler)

func (*StreamRouter) HandleTunnel

func (s *StreamRouter) HandleTunnel(kind protocol.Stream_Type, handler StreamHandler)

type Transport

type Transport interface {
	Identity() *protocol.Node

	DialStream(ctx context.Context, peer *protocol.Node, kind protocol.Stream_Type) (net.Conn, error)
	AcceptStream() <-chan *StreamDelegate

	ListConnected() []ConnectedPeer

	SupportDatagram() bool
	ReceiveDatagram() <-chan *DatagramDelegate
	SendDatagram(*protocol.Node, []byte) error
}

Directories

Path Synopsis
q

Jump to

Keyboard shortcuts

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