ashe

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: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Conf = struct {
	// The time error allowed by the server in seconds.
	LifeExpired int
}{
	LifeExpired: 120,
}

Conf is acting as package level configuration.

Functions

This section is empty.

Types

type Client

type Client struct {
	Server string
	// Cipher is a pre-shared key.
	Cipher []byte
}

Client implemented the ashe protocol.

func NewClient

func NewClient(server, cipher string) *Client

NewClient returns a new Client. A secret data needs to be passed in Cipher, as a sign to interface with the Server.

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) Estab added in v1.18.1

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

Establish an existing connection. It is the caller's responsibility to close the con.

func (*Client) Hello added in v1.18.1

func (c *Client) Hello(con io.ReadWriteCloser) (io.ReadWriteCloser, error)

Hello creates an encrypted channel.

type Server

type Server struct {
	Listen string
	// Cipher is a pre-shared key.
	Cipher []byte
	Closer io.Closer
}

Server implemented the ashe protocol. The ASHE server will typically evaluate the request based on source and destination addresses, and return one or more reply messages, as appropriate for the request type.

func NewServer

func NewServer(listen string, cipher string) *Server

NewServer returns a new Server.

func (*Server) Close added in v1.15.8

func (s *Server) Close() error

Close listener. Established connections will not be closed.

func (*Server) Hello added in v1.18.1

func (s *Server) Hello(con io.ReadWriteCloser) (io.ReadWriteCloser, error)

Hello creates an encrypted channel.

func (*Server) Run

func (s *Server) Run() error

Run it.

func (*Server) Serve

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

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

type TCPConn

type TCPConn struct {
	io.ReadWriteCloser
}

TCPConn is an implementation of the Conn interface for TCP network connections.

func NewTCPConn added in v1.15.8

func NewTCPConn(c io.ReadWriteCloser) *TCPConn

NewTCPConn returns a new TCPConn.

type UDPConn

type UDPConn struct {
	io.ReadWriteCloser
	// contains filtered or unexported fields
}

UDPConn is an implementation of the Conn interface for UDP network connections.

func NewUDPConn added in v1.15.8

func NewUDPConn(c io.ReadWriteCloser) *UDPConn

NewUDPConn returns a new UDPConn.

func (*UDPConn) Read

func (c *UDPConn) Read(p []byte) (int, error)

Read implements the Conn Read method.

func (*UDPConn) Write

func (c *UDPConn) Write(p []byte) (int, error)

Write implements the Conn Write method.

Jump to

Keyboard shortcuts

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