Help us shape the future of Go! Take the 2026 Go Developer Survey

mux

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2023 License: GPL-2.0 Imports: 26 Imported by: 49

README

sing-mux

Simple multiplex library.

Documentation

Index

Constants

View Source
const (
	ProtocolSmux = iota
	ProtocolYAMux
	ProtocolH2Mux
)
View Source
const (
	Version0 = iota
	Version1
)
View Source
const (
	TCPTimeout = 5 * time.Second
)

Variables

View Source
var Destination = M.Socksaddr{
	Fqdn: "sp.mux.sing-box.arpa",
	Port: 444,
}

Functions

func EncodeRequest

func EncodeRequest(request Request, payload []byte) *buf.Buffer

func EncodeStreamRequest

func EncodeStreamRequest(request StreamRequest, buffer *buf.Buffer)

func HandleConnection

func HandleConnection(ctx context.Context, handler ServerHandler, logger logger.ContextLogger, conn net.Conn, metadata M.Metadata) error

func HandleConnectionDefault

func HandleConnectionDefault(ctx context.Context, conn net.Conn) error

Types

type Client

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

func NewClient

func NewClient(options Options) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) DialContext

func (c *Client) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error)

func (*Client) ListenPacket

func (c *Client) ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error)

func (*Client) Reset

func (c *Client) Reset()

type Options

type Options struct {
	Dialer         N.Dialer
	Protocol       string
	MaxConnections int
	MinStreams     int
	MaxStreams     int
	Padding        bool
}

type Request

type Request struct {
	Version  byte
	Protocol byte
	Padding  bool
}

func ReadRequest

func ReadRequest(reader io.Reader) (*Request, error)

type ServerHandler

type ServerHandler interface {
	N.TCPConnectionHandler
	N.UDPConnectionHandler
	E.Handler
}

type StreamRequest

type StreamRequest struct {
	Network     string
	Destination M.Socksaddr
	PacketAddr  bool
}

func ReadStreamRequest

func ReadStreamRequest(reader io.Reader) (*StreamRequest, error)

type StreamResponse

type StreamResponse struct {
	Status  uint8
	Message string
}

func ReadStreamResponse

func ReadStreamResponse(reader io.Reader) (*StreamResponse, error)

Jump to

Keyboard shortcuts

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