mux

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: GPL-2.0 Imports: 32 Imported by: 23

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

func ReadBrutalRequest added in v0.1.5

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

func ReadBrutalResponse added in v0.1.5

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

func SetBrutalOptions added in v0.1.5

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

func WriteBrutalRequest added in v0.1.5

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

func WriteBrutalResponse added in v0.1.5

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

Types

type BrutalOptions added in v0.1.5

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
	Brutal         BrutalOptions
}

type Request

type Request struct {
	Version  byte
	Protocol byte
	Padding  bool
}

func ReadRequest

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

type Service added in v0.1.5

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

func NewService added in v0.1.5

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

func (*Service) NewConnection added in v0.1.5

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

type ServiceHandler added in v0.1.5

type ServiceHandler interface {
	N.TCPConnectionHandler
	N.UDPConnectionHandler
}

type ServiceOptions added in v0.1.5

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 added in v0.1.5

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