protocol

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	URLHost = "xless"
	// You may ignore this fixed path for auth, since server recognizes dynamic API paths
	URLPath = "/auth"
	// ... unchanged ...
	RequestHeaderAuth        = "xless-Auth"
	ResponseHeaderUDPEnabled = "xless-UDP"
	CommonHeaderCCRX         = "xless-CC-RX"
	CommonHeaderPadding      = "xless-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) (bool, string, error)

func WriteTCPRequest

func WriteTCPRequest(w io.Writer, addr string) error

func WriteTCPResponse

func WriteTCPResponse(w io.Writer, ok bool, msg string) error

Types

type AuthRequest

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

func AuthRequestFromHeader

func AuthRequestFromHeader(h http.Header) AuthRequest

func AuthRequestFromObfuscated added in v0.1.0

func AuthRequestFromObfuscated(r *http.Request) AuthRequest

Parse authentication info from a heavily obfuscated HTTP request according to XLESS SPEC.

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