client

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(config *Config) (Client, *HandshakeInfo, error)

NewClient 创建并返回一个新的 Client 实例。

func SimulateWebBrowse added in v0.1.0

func SimulateWebBrowse(client *http.Client, decoyBaseURL string) ([]string, error)

SimulateWebBrowse requests /index.html from the decoy site, parses all linked resources (src/href), and returns a list of absolute URLs (in order). If a link is a relative path (starts with /), it will be joined with decoyBaseURL.

Types

type BandwidthConfig

type BandwidthConfig struct {
	MaxTx uint64
	MaxRx uint64
}

BandwidthConfig describes the maximum bandwidth that the server can use, in bytes per second.

type Client

type Client interface {
	TCP(addr string) (net.Conn, error)
	UDP() (HyUDPConn, error)
	Close() error
}

func NewReconnectableClient

func NewReconnectableClient(configFunc func() (*Config, error), connectedFunc func(Client, *HandshakeInfo, int), lazy bool) (Client, error)

NewReconnectableClient creates a reconnectable client. If lazy is true, the client will not connect until the first call to TCP() or UDP(). We use a function for config mainly to delay config evaluation (which involves DNS resolution) until the actual connection attempt.

type Config

type Config struct {
	ConnFactory     ConnFactory
	ServerAddr      net.Addr
	Auth            string
	TLSConfig       TLSConfig
	QUICConfig      QUICConfig
	BandwidthConfig BandwidthConfig
	FastOpen        bool
	DecoyURL        string
	Protocol        ProtocolType
	ProtocolParam   string
	EnableUQUIC     bool
	UQUICSpecID     quic.QUICID // 类型必须为 quic.QUICID

	// Add this new field to enable FakeTCP
	XLESSUseFakeTCP bool `json:"xless_use_faketcp,omitempty"`
	WebsimCount     int  // 新增:指定 Websim 请求的资源个数
	// contains filtered or unexported fields
}

type ConnFactory

type ConnFactory interface {
	New(net.Addr) (net.PacketConn, error)
}

type HandshakeInfo

type HandshakeInfo struct {
	UDPEnabled bool
	Tx         uint64
}

type HyUDPConn

type HyUDPConn interface {
	Receive() ([]byte, string, error)
	Send([]byte, string) error
	Close() error
}

type ProtocolType added in v0.3.2

type ProtocolType string

ProtocolType 定义了客户端支持的协议类型

const (
	ProtocolTypeDefault ProtocolType = "default" // 默认协议类型
	ProtocolTypeAuthA   ProtocolType = "auth_a"
)

type QUICConfig

type QUICConfig struct {
	InitialStreamReceiveWindow     uint64
	MaxStreamReceiveWindow         uint64
	InitialConnectionReceiveWindow uint64
	MaxConnectionReceiveWindow     uint64
	MaxIdleTimeout                 time.Duration
	KeepAlivePeriod                time.Duration
	DisablePathMTUDiscovery        bool
}

QUICConfig contains the QUIC configuration fields that we want to expose to the user.

type TLSConfig

type TLSConfig struct {
	ServerName            string
	InsecureSkipVerify    bool
	VerifyPeerCertificate func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error
	RootCAs               *x509.CertPool
}

TLSConfig contains the TLS configuration fields that we want to expose to the user.

Jump to

Keyboard shortcuts

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