transport

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const STREAMS = 30

Variables

View Source
var REASON_STRING = map[CLOSE_REASON]string{
	CLOSE:   "graceful shutdown",
	CONTROL: "control stream can't be openned",
}

Functions

func CloseConn

func CloseConn(conn quic.Connection, reason CLOSE_REASON) error

func DefaultConfig

func DefaultConfig() *quic.Config

func Ping

func Ping(writer io.Writer) error

func Pong

func Pong(reader io.Reader) error

func ReadCommand

func ReadCommand(r io.Reader) (message.Command, error)

func WriteCommand

func WriteCommand(w io.Writer, command message.Command) (int, error)

Types

type Buffer

type Buffer struct {
	Slice []byte
	Start int
	End   int
}

func WrapBuffer

func WrapBuffer(slice []byte, start, end int) Buffer

type CLOSE_REASON

type CLOSE_REASON int
const CLOSE CLOSE_REASON = 0
const CONTROL CLOSE_REASON = 1

type QuicClientTransport

type QuicClientTransport struct {
	Conn          quic.Connection
	Streams       []quic.Stream
	ControlStream quic.Stream
	BufferChannel chan Buffer
	BufferPool    *pool.Pool[[]byte]
}

func (*QuicClientTransport) Close

func (v *QuicClientTransport) Close() error

func (*QuicClientTransport) GetStats

func (v *QuicClientTransport) GetStats() string

func (*QuicClientTransport) Read

func (v *QuicClientTransport) Read(buffer []byte) (int, error)

Read may read from a random channel by order of insertion

func (*QuicClientTransport) ReadControlCommand

func (v *QuicClientTransport) ReadControlCommand() (message.Command, error)

func (*QuicClientTransport) RunReaders

func (v *QuicClientTransport) RunReaders() error

func (*QuicClientTransport) Write

func (v *QuicClientTransport) Write(buffer []byte) (int, error)

Write write to a random channel

func (*QuicClientTransport) WriteControlCommand

func (v *QuicClientTransport) WriteControlCommand(command message.Command) (int, error)

type QuicConfig

type QuicConfig struct {
	KeyFile  string
	CertFile string
	CAFile   string
}

func (QuicConfig) GenerateTLSConfig

func (v QuicConfig) GenerateTLSConfig(is_server bool) *tls.Config

type QuicServerTransport

type QuicServerTransport struct {
	Listener      quic.Listener
	Conn          quic.Connection
	Streams       []quic.Stream
	ControlStream quic.Stream
	BufferChannel chan Buffer
	BufferPool    *pool.Pool[[]byte]
}

func (*QuicServerTransport) Close

func (v *QuicServerTransport) Close() error

func (*QuicServerTransport) GetStats

func (v *QuicServerTransport) GetStats() string

func (*QuicServerTransport) Read

func (v *QuicServerTransport) Read(buffer []byte) (int, error)

Read may read from a random channel by order of insertion

func (*QuicServerTransport) ReadControlCommand

func (v *QuicServerTransport) ReadControlCommand() (message.Command, error)

func (*QuicServerTransport) RunReaders

func (v *QuicServerTransport) RunReaders() error

Sync functino to perform all reading. When it returns, all streams are closed

func (*QuicServerTransport) Write

func (v *QuicServerTransport) Write(buffer []byte) (int, error)

Write write to a random channel

func (*QuicServerTransport) WriteControlCommand

func (v *QuicServerTransport) WriteControlCommand(command message.Command) (int, error)

type Transport

type Transport interface {
	io.ReadWriteCloser
	ReadControlCommand() (message.Command, error)
	WriteControlCommand(command message.Command) (int, error)
	GetStats() string
}

func NewQuicClientTransport

func NewQuicClientTransport(config QuicConfig, server_addr string, ctx context.Context, certName string) (result Transport, cause error)

func NewQuicServerTransport

func NewQuicServerTransport(config QuicConfig, bind_string string, ctx context.Context, certName string) (result Transport, cause error)

Jump to

Keyboard shortcuts

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