mux

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OptionData  bitmask.Byte = 0x01
	OptionError bitmask.Byte = 0x02
)

Variables

View Source
var (
	MuxCoolAddressDst = nethelper.DomainAddress("v1.mux.cool")
	MuxCoolPortDst    = nethelper.Port(9527)
)
View Source
var DefaultClientStrategy = ClientStrategy{
	MaxConnection:  16,
	MaxConcurrency: 2,
}

Functions

func NewClient

func NewClient(ctx context.Context, link *pipe.Link, s ClientStrategy) (*client, error)

NewClient creates a new mux.Client.

func Serve

func Serve(ctx context.Context, rw buf.ReaderWriter, d i.FlowHandler) error

Types

type AddressType

type AddressType byte
const (
	AddressTypeIPv4   AddressType = 1
	AddressTypeDomain AddressType = 2
	AddressTypeIPv6   AddressType = 3
)

type ClientManager

type ClientManager struct {
	Strategy ClientStrategy
	// contains filtered or unexported fields
}

func NewClientManager

func NewClientManager(strategy ClientStrategy, oh i.FlowHandler) *ClientManager

func (*ClientManager) Close

func (m *ClientManager) Close() error

func (*ClientManager) Create

func (p *ClientManager) Create() (*client, error)

func (*ClientManager) HandleReaderWriter

func (m *ClientManager) HandleReaderWriter(ctx context.Context, dst net.Destination,
	rw buf.ReaderWriter) error

a worker is chosen to handle a link ctx is used to get outboundInfo and sessionID

func (*ClientManager) Start

func (m *ClientManager) Start() error

type ClientStrategy

type ClientStrategy struct {
	MaxConcurrency uint32
	MaxConnection  uint32
}

type FrameMetadata

type FrameMetadata struct {
	GlobalID [8]byte //only present when xudp
	// UdpUuid       uuid.UUID //only present when udp
	Target        nethelper.Destination
	SessionID     uint16
	Option        bitmask.Byte
	SessionStatus SessionStatus
}

func (*FrameMetadata) Unmarshal

func (f *FrameMetadata) Unmarshal(reader io.Reader) error

Unmarshal reads FrameMetadata from the given reader.

func (FrameMetadata) WriteTo

func (f FrameMetadata) WriteTo(b *buf.Buffer) error

type MuxWriter

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

func NewMuxWriter

func NewMuxWriter(id uint16, dest net.Destination, writer buf.Writer, transferType TransferType) *MuxWriter

build frames and write them to the writer. used by muxclient

func NewResponseMuxWriter

func NewResponseMuxWriter(id uint16, writer buf.Writer, transferType TransferType) *MuxWriter

used by the mux.server to write back responses.

func (*MuxWriter) CloseWrite

func (w *MuxWriter) CloseWrite() error

func (*MuxWriter) SendSessionStatusEnd

func (w *MuxWriter) SendSessionStatusEnd() error

this is when the end frame is sent

func (*MuxWriter) WriteMultiBuffer

func (w *MuxWriter) WriteMultiBuffer(mb buf.MultiBuffer) error

WriteMultiBuffer implements buf.Writer.

type SessionStatus

type SessionStatus byte
const (
	SessionStatusNew       SessionStatus = 0x01
	SessionStatusKeep      SessionStatus = 0x02
	SessionStatusEnd       SessionStatus = 0x03
	SessionStatusKeepAlive SessionStatus = 0x04
)

type TargetNetwork

type TargetNetwork byte
const (
	TargetNetworkTCP TargetNetwork = 0x01
	TargetNetworkUDP TargetNetwork = 0x02
)

type TransferType

type TransferType byte
const (
	TransferTypeStream TransferType = 0
	TransferTypePacket TransferType = 1
)

Jump to

Keyboard shortcuts

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