core

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2022 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
const DEFAULT_BUFFER_SIZE = 32 << 10
View Source
const DEFAULT_TIMEOUT = 600
View Source
const UNUSUAL_BUFFER_LENGTH_THRESHOLD = DEFAULT_BUFFER_SIZE * 2

Variables

This section is empty.

Functions

func CreateBarebonesTLSConfig

func CreateBarebonesTLSConfig(proto string) (*tls.Config, error)

func MakePipe

func MakePipe() (pipe [2]net.Conn)

func NewOnceCloser

func NewOnceCloser(c io.Closer) io.Closer

func RunSimpleProtocolSwitch

func RunSimpleProtocolSwitch(red, blue net.Conn, redProtocol, blueProtocol Protocol)

Types

type EventRecorder

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

func NewEventRecorder added in v1.4.3

func NewEventRecorder() *EventRecorder

func (*EventRecorder) AddRecord

func (this *EventRecorder) AddRecord(e string) uint64

func (*EventRecorder) AssertHappenedBefore

func (this *EventRecorder) AssertHappenedBefore(a, b string)

func (*EventRecorder) HappenedBefore

func (this *EventRecorder) HappenedBefore(a, b string) bool

type HTTPProtocol

type HTTPProtocol struct{}

func (*HTTPProtocol) Pack

func (this *HTTPProtocol) Pack(buf []byte, out *bufio.Writer) error

func (*HTTPProtocol) Unpack

func (this *HTTPProtocol) Unpack(in *bufio.Reader) ([]byte, error)

type JsonRPC

type JsonRPC struct {
	P Protocol
	R *bufio.Reader
	W *bufio.Writer
}

func NewJsonRPC

func NewJsonRPC(p Protocol, c io.ReadWriter) *JsonRPC

func (*JsonRPC) ReadRequest

func (this *JsonRPC) ReadRequest(req interface{}) (err error)

func (*JsonRPC) Request

func (this *JsonRPC) Request(req interface{}, resp interface{}) error

func (*JsonRPC) SendResponse

func (this *JsonRPC) SendResponse(resp interface{}) (err error)

type LVProtocol

type LVProtocol struct{}

func (*LVProtocol) Pack

func (this *LVProtocol) Pack(buf []byte, out *bufio.Writer) error

func (*LVProtocol) Unpack

func (this *LVProtocol) Unpack(in *bufio.Reader) ([]byte, error)

type OnceCloser

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

func (*OnceCloser) Close

func (this *OnceCloser) Close() error

type PackUnpackPassManagerBuilder

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

func NewPackUnpackPassManagerBuilder

func NewPackUnpackPassManagerBuilder() *PackUnpackPassManagerBuilder

func (*PackUnpackPassManagerBuilder) AddPairedPasses

func (this *PackUnpackPassManagerBuilder) AddPairedPasses(pack Pass, unpack Pass)

func (*PackUnpackPassManagerBuilder) BuildPackPassManager

func (this *PackUnpackPassManagerBuilder) BuildPackPassManager() *PassManager

func (*PackUnpackPassManagerBuilder) BuildUnpackPassManager

func (this *PackUnpackPassManagerBuilder) BuildUnpackPassManager() *PassManager

type Pass

type Pass interface {
	RunOnBytes([]byte) ([]byte, error)
}

type PassManager

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

func NewPassManager

func NewPassManager() *PassManager

func NewPassManagerWithPasses

func NewPassManagerWithPasses(passes []Pass) *PassManager

func (*PassManager) AddPass

func (this *PassManager) AddPass(p Pass) *PassManager

func (*PassManager) RunOnBytes

func (this *PassManager) RunOnBytes(buf []byte) (result []byte, err error)

type Port

type Port struct {
	C      net.Conn
	P      Protocol
	Unpack func() ([]byte, error)
	Pack   func([]byte) error
}

func NewPort

func NewPort(c net.Conn, p Protocol) (port *Port)

type Protocol

type Protocol interface {
	Pack([]byte, *bufio.Writer) error
	Unpack(*bufio.Reader) ([]byte, error)
}

type ProtocolStack

type ProtocolStack struct{}

type ProtocolWithPass

type ProtocolWithPass struct {
	P  Protocol
	PP Pass
	UP Pass
}

func (*ProtocolWithPass) Pack

func (this *ProtocolWithPass) Pack(src []byte, out *bufio.Writer) (err error)

func (*ProtocolWithPass) Unpack

func (this *ProtocolWithPass) Unpack(in *bufio.Reader) (dst []byte, err error)

type ReadWriterWithTimeout

type ReadWriterWithTimeout struct {
	C            net.Conn
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
}

func (*ReadWriterWithTimeout) Read

func (this *ReadWriterWithTimeout) Read(b []byte) (int, error)

func (*ReadWriterWithTimeout) Write

func (this *ReadWriterWithTimeout) Write(b []byte) (int, error)

type Repeater

type Repeater struct{}

func (*Repeater) Pack

func (this *Repeater) Pack(buf []byte, out *bufio.Writer) error

func (*Repeater) Unpack

func (this *Repeater) Unpack(in *bufio.Reader) ([]byte, error)

type SimpleProtocolSwitch

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

SimpleProtocolSwitch is not responsible to close red and blue.

func NewSimpleProtocolSwitch

func NewSimpleProtocolSwitch(red, blue net.Conn, redProtocol, blueProtocol Protocol) *SimpleProtocolSwitch

func (*SimpleProtocolSwitch) Run

func (this *SimpleProtocolSwitch) Run()

type VariantProtocol

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

func NewVariantProtocol

func NewVariantProtocol() *VariantProtocol

func (*VariantProtocol) Add

func (*VariantProtocol) Len

func (this *VariantProtocol) Len() int

func (*VariantProtocol) Pack

func (this *VariantProtocol) Pack(buf []byte, out *bufio.Writer) error

func (*VariantProtocol) Unpack

func (this *VariantProtocol) Unpack(in *bufio.Reader) ([]byte, error)

Jump to

Keyboard shortcuts

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