czar

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Cipher []byte
	Server string
	Mux    chan *Mux
}

Client implemented the czar protocol.

func NewClient

func NewClient(server, cipher string) *Client

NewClient returns a new Client.

func (*Client) Close

func (c *Client) Close() error

func (*Client) Dial

func (c *Client) Dial(ctx *daze.Context, network string, address string) (io.ReadWriteCloser, error)

Dial connects to the address on the named network.

func (*Client) Run added in v1.17.1

func (c *Client) Run()

Run creates an establish connection to czar server.

type Err added in v1.18.1

type Err struct {
	sync.Mutex // Guards following
	// contains filtered or unexported fields
}

Err is an object that will only store an error once.

func (*Err) Get added in v1.18.1

func (a *Err) Get() error

Get an error from Err.

func (*Err) Put added in v1.18.1

func (a *Err) Put(err error)

Put an error into Err.

type Mux added in v1.17.1

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

Mux is used to wrap a reliable ordered connection and to multiplex it into multiple streams.

func NewMux added in v1.17.1

func NewMux(conn net.Conn) *Mux

NewMux returns a new Mux.

func NewMuxClient added in v1.17.1

func NewMuxClient(conn net.Conn) *Mux

NewMuxClient returns a new MuxClient.

func NewMuxServer added in v1.17.1

func NewMuxServer(conn net.Conn) *Mux

NewMuxServer returns a new MuxServer.

func (*Mux) Accept added in v1.17.1

func (m *Mux) Accept() chan *Stream

Accept is used to block until the next available stream is ready to be accepted.

func (*Mux) Close added in v1.17.1

func (m *Mux) Close() error

Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.

func (*Mux) Open added in v1.17.1

func (m *Mux) Open() (*Stream, error)

Open is used to create a new stream as a net.Conn.

func (*Mux) Spawn added in v1.17.2

func (m *Mux) Spawn()

Spawn continues to receive data until a fatal error is encountered.

func (*Mux) Write added in v1.17.2

func (m *Mux) Write(priority int, b []byte) (int, error)

Write writes data to the connection. The code implements a simple priority write using two locks.

type Server

type Server struct {
	Listen string
	Cipher []byte
	Closer io.Closer
}

Server implemented the czar protocol.

func NewServer

func NewServer(listen string, cipher string) *Server

NewServer returns a new Server.

func (*Server) Close

func (s *Server) Close() error

Close listener.

func (*Server) Run

func (s *Server) Run() error

Run it.

func (*Server) Serve

func (s *Server) Serve(ctx *daze.Context, cli io.ReadWriteCloser) error

Serve incoming connections. Parameter cli will be closed automatically when the function exits.

type Stream added in v1.17.1

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

A Stream managed by the multiplexer.

func NewStream added in v1.17.1

func NewStream(idx uint8, mux *Mux) *Stream

NewStream returns a new Stream.

func (*Stream) Close added in v1.17.1

func (s *Stream) Close() error

Close implements io.Closer.

func (*Stream) Read added in v1.17.1

func (s *Stream) Read(p []byte) (int, error)

Read implements io.Reader.

func (*Stream) Write added in v1.17.1

func (s *Stream) Write(p []byte) (int, error)

Write implements io.Writer.

Jump to

Keyboard shortcuts

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