protocol

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: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	URLHost = "hysteria"
	URLPath = "/auth"

	RequestHeaderAuth        = "Hysteria-Auth"
	ResponseHeaderUDPEnabled = "Hysteria-UDP"
	CommonHeaderCCRX         = "Hysteria-CC-RX"
	CommonHeaderPadding      = "Hysteria-Padding"

	StatusAuthOK = 233
)
View Source
const (
	FrameTypeTCPRequest = 0x401

	MaxAddressLength = 2048
	MaxMessageLength = 2048
	MaxPaddingLength = 4096

	MaxUDPSize = 4096
)

Variables

This section is empty.

Functions

func AuthRequestToHeader

func AuthRequestToHeader(h http.Header, req AuthRequest)

func AuthResponseToHeader

func AuthResponseToHeader(h http.Header, resp AuthResponse)

func ReadTCPRequest

func ReadTCPRequest(r io.Reader) (string, error)

func ReadTCPResponse

func ReadTCPResponse(r io.Reader) (ok bool, message string, err error)

func ReadVString

func ReadVString(reader io.Reader) (string, error)

func WriteTCPRequest

func WriteTCPRequest(addr string, payload []byte) *buf.Buffer

func WriteTCPResponse

func WriteTCPResponse(ok bool, msg string, payload []byte) *buf.Buffer

func WriteUVariant

func WriteUVariant(writer io.Writer, value uint64) error

func WriteVString

func WriteVString(writer io.Writer, value string) error

Types

type AuthRequest

type AuthRequest struct {
	Auth string
	Rx   uint64 // 0 = unknown, client asks server to use bandwidth detection
}

AuthRequest is what client sends to server for authentication.

func AuthRequestFromHeader

func AuthRequestFromHeader(h http.Header) AuthRequest

type AuthResponse

type AuthResponse struct {
	UDPEnabled bool
	Rx         uint64 // 0 = unlimited
	RxAuto     bool   // true = server asks client to use bandwidth detection
}

AuthResponse is what server sends to client when authentication is passed.

func AuthResponseFromHeader

func AuthResponseFromHeader(h http.Header) AuthResponse

type UDPMessage

type UDPMessage struct {
	SessionID uint32 // 4
	PacketID  uint16 // 2
	FragID    uint8  // 1
	FragCount uint8  // 1
	Addr      string // varint + bytes
	Data      []byte
}

func ParseUDPMessage

func ParseUDPMessage(msg []byte) (*UDPMessage, error)

func (*UDPMessage) HeaderSize

func (m *UDPMessage) HeaderSize() int

func (*UDPMessage) Serialize

func (m *UDPMessage) Serialize(buf []byte) int

func (*UDPMessage) Size

func (m *UDPMessage) Size() int

Jump to

Keyboard shortcuts

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