mux

package module
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: GPL-2.0 Imports: 32 Imported by: 2

README

sing-mux

Simple multiplex library.

Documentation

Index

Constants

View Source
const (
	BrutalExchangeDomain = "_BrutalBwExchange"
	BrutalMinSpeedBPS    = 65536
)
View Source
const (
	BrutalAvailable   = true
	TCP_BRUTAL_PARAMS = 23301
)
View Source
const (
	ProtocolSmux = iota
	ProtocolYAMux
	ProtocolH2Mux
)
View Source
const (
	Version0 = iota
	Version1
)

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) error

func ReadBrutalRequest

func ReadBrutalRequest(reader io.Reader) (uint64, error)

func ReadBrutalResponse

func ReadBrutalResponse(reader io.Reader) (uint64, error)

func SetBrutalOptions

func SetBrutalOptions(conn net.Conn, sendBPS uint64) error

func WriteBrutalRequest

func WriteBrutalRequest(writer io.Writer, receiveBPS uint64) error

func WriteBrutalResponse

func WriteBrutalResponse(writer io.Writer, receiveBPS uint64, ok bool, message string) error

Types

type BrutalOptions

type BrutalOptions struct {
	Enabled    bool
	SendBPS    uint64
	ReceiveBPS uint64
}

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
	Logger         logger.Logger
	Protocol       string
	MaxConnections int
	MinStreams     int
	MaxStreams     int
	Padding        bool
	TCPTimeout     time.Duration
	Brutal         BrutalOptions
}

type Request

type Request struct {
	Version  byte
	Protocol byte
	Padding  bool
}

func ReadRequest

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

type Service

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

func NewService

func NewService(options ServiceOptions) (*Service, error)

func (*Service) NewConnection

func (s *Service) NewConnection(ctx context.Context, conn net.Conn, metadata M.Metadata) error

type ServiceHandler

type ServiceHandler interface {
	N.TCPConnectionHandler
	N.UDPConnectionHandler
}

type ServiceOptions

type ServiceOptions struct {
	NewStreamContext func(context.Context, net.Conn) context.Context
	Logger           logger.ContextLogger
	Handler          ServiceHandler
	Padding          bool
	Brutal           BrutalOptions
}

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)

type TCPBrutalParams

type TCPBrutalParams struct {
	Rate     uint64
	CwndGain uint32
}

Jump to

Keyboard shortcuts

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