xconn

package
v0.2.17 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2024 License: MIT Imports: 23 Imported by: 2

Documentation

Index

Constants

View Source
const (
	PacketByteLimit = 1 << 25
)

Variables

This section is empty.

Functions

func Listen

func Listen(ctx context.Context, network, address string, config *Config) (net.Listener, error)

func ListenURL

func ListenURL(ctx context.Context, listenURL *url.URL, config *Config) (net.Listener, error)

func MayPerformXConnHandshake

func MayPerformXConnHandshake(Raw net.Conn) error

func NewXDialerProtocol

func NewXDialerProtocol(UnderlyingDialer client.DialerContext, XConfig *Config) client.Protocol

XConfig can be null.

func ValidateCryptoConnURL

func ValidateCryptoConnURL(Raw net.Conn, URL *url.URL) bool

Types

type Config

type Config struct {
	AuthFunc  func(string, ed25519.PublicKey) bool
	TraceFunc util.TracerFunc

	AuthPrivateKey ed25519.PrivateKey

	KeepaliveInterval          time.Duration
	HandshakeTimeout           time.Duration
	HandshakeServerAllowPublic bool
	// FECParityNum specifies the number of parity shards in every 16 packets. 0 means disabled.
	FECParityNum int

	// If enabled, a separate routine will do the actual IO.
	// This only affects the behavior of UDP connection.
	EnableAIO bool
}

func Default

func Default() *Config

func (*Config) Clone

func (x *Config) Clone() *Config

type Conn

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

func Client

func Client(raw net.Conn, xConfig *Config) *Conn

func ClientWithKnownPeer

func ClientWithKnownPeer(raw net.Conn, xConfig *Config, remotePub []byte) *Conn

func Server

func Server(raw net.Conn, xConfig *Config) *Conn

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) ConsumeBuffer

func (c *Conn) ConsumeBuffer(ba *bufferio.BufferArray) error

func (*Conn) GetExtensionProperty

func (c *Conn) GetExtensionProperty() map[string]uint64

func (*Conn) Handshake

func (c *Conn) Handshake() error

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

func (*Conn) ProduceBuffer

func (c *Conn) ProduceBuffer(bs *bufferio.BufferArray, startOffset int) error

func (*Conn) Read

func (c *Conn) Read(b []byte) (int, error)

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

func (*Conn) SetDeadline

func (c *Conn) SetDeadline(t time.Time) error

func (*Conn) SetReadDeadline

func (c *Conn) SetReadDeadline(t time.Time) error

func (*Conn) SetWriteDeadline

func (c *Conn) SetWriteDeadline(t time.Time) error

func (*Conn) SupportBufferIO

func (*Conn) SupportBufferIO() bool

func (*Conn) SupportKeepAlive

func (c *Conn) SupportKeepAlive() bool

func (*Conn) Write

func (c *Conn) Write(b []byte) (int, error)

func (*Conn) WriteTo

func (c *Conn) WriteTo(writer io.Writer) (int64, error)

Jump to

Keyboard shortcuts

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