hysteria

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2025 License: GPL-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MbpsToBps                  = 125000
	MinSpeedBPS                = 16384
	DefaultALPN                = "hysteria"
	DefaultStreamReceiveWindow = 8388608                            // 8MB
	DefaultConnReceiveWindow   = DefaultStreamReceiveWindow * 5 / 2 // 20MB
	DefaultMaxIdleTimeout      = 30 * time.Second
	DefaultKeepAlivePeriod     = 10 * time.Second
)
View Source
const (
	ProtocolVersion        = 3
	ProtocolTimeout        = 10 * time.Second
	ErrorCodeGeneric       = 0
	ErrorCodeProtocolError = 1
	ErrorCodeAuthError     = 2
)

Variables

This section is empty.

Functions

func NewXPlusPacketConn

func NewXPlusPacketConn(conn net.PacketConn, key []byte) net.PacketConn

func ParsePorts

func ParsePorts(serverPorts []string) ([]uint16, error)

func WriteClientHello

func WriteClientHello(stream io.Writer, hello ClientHello) error

func WriteClientRequest

func WriteClientRequest(request ClientRequest, payload []byte) *buf.Buffer

func WriteServerHello

func WriteServerHello(stream io.Writer, hello ServerHello) error

func WriteServerResponse

func WriteServerResponse(stream quic.Stream, response ServerResponse) error

Types

type Client

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

func NewClient

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

func (*Client) CloseWithError

func (c *Client) CloseWithError(err error) error

func (*Client) DialConn

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

func (*Client) ListenPacket

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

type ClientHello

type ClientHello struct {
	SendBPS uint64
	RecvBPS uint64
	Auth    string
}

func ReadClientHello

func ReadClientHello(reader io.Reader) (*ClientHello, error)

type ClientOptions

type ClientOptions struct {
	Context       context.Context
	Dialer        N.Dialer
	Logger        logger.Logger
	BrutalDebug   bool
	ServerAddress M.Socksaddr
	ServerPorts   []string
	HopInterval   time.Duration
	SendBPS       uint64
	ReceiveBPS    uint64
	XPlusPassword string
	Password      string
	TLSConfig     aTLS.Config
	UDPDisabled   bool

	ConnReceiveWindow   uint64
	StreamReceiveWindow uint64
	DisableMTUDiscovery bool
}

type ClientRequest

type ClientRequest struct {
	UDP  bool
	Host string
	Port uint16
}

func ReadClientRequest

func ReadClientRequest(stream io.Reader) (*ClientRequest, error)

type HopPacketConn

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

func NewHopPacketConn

func NewHopPacketConn(
	dialFunc func(M.Socksaddr) (net.PacketConn, error),
	destination M.Socksaddr,
	ports []uint16,
	interval time.Duration,
) (*HopPacketConn, error)

func (*HopPacketConn) Close

func (c *HopPacketConn) Close() error

func (*HopPacketConn) LocalAddr

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

func (*HopPacketConn) ReadFrom

func (c *HopPacketConn) ReadFrom(b []byte) (n int, addr net.Addr, err error)

func (*HopPacketConn) SetDeadline

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

func (*HopPacketConn) SetReadBuffer

func (c *HopPacketConn) SetReadBuffer(bytes int) error

func (*HopPacketConn) SetReadDeadline

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

func (*HopPacketConn) SetWriteBuffer

func (c *HopPacketConn) SetWriteBuffer(bytes int) error

func (*HopPacketConn) SetWriteDeadline

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

func (*HopPacketConn) SyscallConn

func (c *HopPacketConn) SyscallConn() (syscall.RawConn, error)

func (*HopPacketConn) WriteTo

func (c *HopPacketConn) WriteTo(b []byte, _ net.Addr) (n int, err error)

type ServerHandler

type ServerHandler interface {
	N.TCPConnectionHandlerEx
	N.UDPConnectionHandlerEx
}

type ServerHello

type ServerHello struct {
	OK      bool
	SendBPS uint64
	RecvBPS uint64
	Message string
}

func ReadServerHello

func ReadServerHello(stream io.Reader) (*ServerHello, error)

type ServerResponse

type ServerResponse struct {
	OK           bool
	UDPSessionID uint32
	Message      string
}

func ReadServerResponse

func ReadServerResponse(stream io.Reader) (*ServerResponse, error)

type Service

type Service[U comparable] struct {
	// contains filtered or unexported fields
}

func NewService

func NewService[U comparable](options ServiceOptions) (*Service[U], error)

func (*Service[U]) Close

func (s *Service[U]) Close() error

func (*Service[U]) Start

func (s *Service[U]) Start(conn net.PacketConn) error

func (*Service[U]) UpdateUsers

func (s *Service[U]) UpdateUsers(userList []U, passwordList []string)

type ServiceOptions

type ServiceOptions struct {
	Context       context.Context
	Logger        logger.Logger
	BrutalDebug   bool
	SendBPS       uint64
	ReceiveBPS    uint64
	XPlusPassword string
	TLSConfig     aTLS.ServerConfig
	UDPDisabled   bool
	UDPTimeout    time.Duration
	Handler       ServerHandler

	ConnReceiveWindow   uint64
	StreamReceiveWindow uint64
	MaxIncomingStreams  int64
	DisableMTUDiscovery bool
}

type VectorisedXPlusConn

type VectorisedXPlusConn struct {
	XPlusPacketConn
	// contains filtered or unexported fields
}

func (*VectorisedXPlusConn) WriteTo

func (c *VectorisedXPlusConn) WriteTo(p []byte, addr net.Addr) (n int, err error)

func (*VectorisedXPlusConn) WriteVectorisedPacket

func (c *VectorisedXPlusConn) WriteVectorisedPacket(buffers []*buf.Buffer, destination M.Socksaddr) error

type XPlusPacketConn

type XPlusPacketConn struct {
	net.PacketConn
	// contains filtered or unexported fields
}

func (*XPlusPacketConn) ReadFrom

func (c *XPlusPacketConn) ReadFrom(p []byte) (n int, addr net.Addr, err error)

func (*XPlusPacketConn) Upstream

func (c *XPlusPacketConn) Upstream() any

func (*XPlusPacketConn) WriteTo

func (c *XPlusPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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