hysteria

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: GPL-2.0 Imports: 31 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 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
	SendBPS       uint64
	ReceiveBPS    uint64
	XPlusPassword string
	Password      string
	TLSConfig     aTLS.Config
	UDPDisabled   bool
	Protocol      string

	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 ServerHandler

type ServerHandler interface {
	N.TCPConnectionHandler
	N.UDPConnectionHandler
}

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(listenAddr string) 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
	Protocol      string

	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