pool

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPoolClosed    = errors.New("connection pool is closed")
	ErrNoConnections = errors.New("no available connections")
)

Functions

This section is empty.

Types

type Conn

type Conn struct {
	Host       string
	RemoteAddr net.Addr
	TLSConn    *utls.UConn
	HTTP2Conn  *http2.ClientConn
	CreatedAt  time.Time
	LastUsedAt time.Time
	UseCount   int64
	// contains filtered or unexported fields
}

Conn represents a persistent connection

func (*Conn) Age

func (c *Conn) Age() time.Duration

Age returns how long the connection has been open

func (*Conn) Close

func (c *Conn) Close() error

Close closes the connection

func (*Conn) IdleTime

func (c *Conn) IdleTime() time.Duration

IdleTime returns how long since the connection was last used

func (*Conn) IsHealthy

func (c *Conn) IsHealthy() bool

IsHealthy checks if the connection is still usable

func (*Conn) MarkUsed

func (c *Conn) MarkUsed()

MarkUsed updates the last used timestamp

type HostPool

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

HostPool manages connections to a single host

func NewHostPool

func NewHostPool(host, port string, preset *fingerprint.Preset, dnsCache *dns.Cache) *HostPool

NewHostPool creates a new pool for a specific host Note: This generates its own shuffled specs. For consistent session fingerprinting, use Manager.GetPool() instead which shares cached specs across all hosts.

func NewHostPoolWithConfig

func NewHostPoolWithConfig(host, port string, preset *fingerprint.Preset, dnsCache *dns.Cache, insecureSkipVerify bool, proxyURL string, cachedSpec, cachedPSKSpec *utls.ClientHelloSpec) *HostPool

NewHostPoolWithConfig creates a pool with TLS and proxy configuration

func (*HostPool) Close

func (p *HostPool) Close()

Close closes all connections in the pool

func (*HostPool) CloseIdle

func (p *HostPool) CloseIdle()

CloseIdle closes connections that have been idle too long

func (*HostPool) GetConn

func (p *HostPool) GetConn(ctx context.Context) (*Conn, error)

GetConn returns an available connection or creates a new one

func (*HostPool) SetMaxConns

func (p *HostPool) SetMaxConns(max int)

SetMaxConns sets the maximum connections for this pool (0 = unlimited)

func (*HostPool) Stats

func (p *HostPool) Stats() (total int, healthy int, totalRequests int64)

Stats returns pool statistics

type Manager

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

Manager manages connection pools for multiple hosts

func NewManager

func NewManager(preset *fingerprint.Preset) *Manager

NewManager creates a new connection pool manager

func NewManagerWithProxy

func NewManagerWithProxy(preset *fingerprint.Preset, proxyURL string, insecureSkipVerify bool) *Manager

NewManagerWithProxy creates a manager with proxy support

func NewManagerWithTLSConfig

func NewManagerWithTLSConfig(preset *fingerprint.Preset, insecureSkipVerify bool) *Manager

NewManagerWithTLSConfig creates a manager with TLS configuration

func (*Manager) Close

func (m *Manager) Close()

Close shuts down the manager and all pools

func (*Manager) GetConn

func (m *Manager) GetConn(ctx context.Context, host, port string) (*Conn, error)

GetConn gets a connection to the specified host

func (*Manager) GetDNSCache

func (m *Manager) GetDNSCache() *dns.Cache

GetDNSCache returns the DNS cache

func (*Manager) GetPool

func (m *Manager) GetPool(host, port string) (*HostPool, error)

GetPool returns a pool for the given host, creating one if needed

func (*Manager) SetMaxConnsPerHost

func (m *Manager) SetMaxConnsPerHost(max int)

SetMaxConnsPerHost sets the max connections per host for new pools (0 = unlimited)

func (*Manager) SetPreset

func (m *Manager) SetPreset(preset *fingerprint.Preset)

SetPreset changes the fingerprint preset for new connections

func (*Manager) Stats

func (m *Manager) Stats() map[string]struct {
	Total    int
	Healthy  int
	Requests int64
}

Stats returns overall manager statistics

type QUICConn

type QUICConn struct {
	Host       string
	RemoteAddr net.Addr
	QUICConn   *quic.Conn
	HTTP3RT    *http3.Transport
	CreatedAt  time.Time
	LastUsedAt time.Time
	UseCount   int64
	// contains filtered or unexported fields
}

QUICConn represents a persistent QUIC connection

func (*QUICConn) Age

func (c *QUICConn) Age() time.Duration

Age returns how long the connection has been open

func (*QUICConn) Close

func (c *QUICConn) Close() error

Close closes the QUIC connection

func (*QUICConn) IdleTime

func (c *QUICConn) IdleTime() time.Duration

IdleTime returns how long since the connection was last used

func (*QUICConn) IsHealthy

func (c *QUICConn) IsHealthy() bool

IsHealthy checks if the QUIC connection is still usable

func (*QUICConn) MarkUsed

func (c *QUICConn) MarkUsed()

MarkUsed updates the last used timestamp

type QUICHostPool

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

QUICHostPool manages QUIC connections to a single host

func NewQUICHostPool

func NewQUICHostPool(host, port string, preset *fingerprint.Preset, dnsCache *dns.Cache) *QUICHostPool

NewQUICHostPool creates a new QUIC pool for a specific host

func NewQUICHostPoolWithCachedSpec added in v1.1.4

func NewQUICHostPoolWithCachedSpec(host, port string, preset *fingerprint.Preset, dnsCache *dns.Cache, cachedSpec *utls.ClientHelloSpec, shuffleSeed int64) *QUICHostPool

NewQUICHostPoolWithCachedSpec creates a QUIC pool with a pre-cached ClientHelloSpec and shuffle seed This ensures consistent TLS extension order and transport parameter order across all hosts in a session

func (*QUICHostPool) Close

func (p *QUICHostPool) Close()

Close closes all connections in the pool

func (*QUICHostPool) CloseIdle

func (p *QUICHostPool) CloseIdle()

CloseIdle closes connections that have been idle too long

func (*QUICHostPool) GetConn

func (p *QUICHostPool) GetConn(ctx context.Context) (*QUICConn, error)

GetConn returns an available QUIC connection or creates a new one

func (*QUICHostPool) SetMaxConns

func (p *QUICHostPool) SetMaxConns(max int)

SetMaxConns sets the maximum connections for this pool (0 = unlimited)

func (*QUICHostPool) Stats

func (p *QUICHostPool) Stats() (total int, healthy int, totalRequests int64)

Stats returns pool statistics

type QUICManager

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

QUICManager manages QUIC connection pools for multiple hosts

func NewQUICManager

func NewQUICManager(preset *fingerprint.Preset, dnsCache *dns.Cache) *QUICManager

NewQUICManager creates a new QUIC connection pool manager

func (*QUICManager) Close

func (m *QUICManager) Close()

Close shuts down the manager and all pools

func (*QUICManager) GetConn

func (m *QUICManager) GetConn(ctx context.Context, host, port string) (*QUICConn, error)

GetConn gets a QUIC connection to the specified host

func (*QUICManager) GetPool

func (m *QUICManager) GetPool(host, port string) (*QUICHostPool, error)

GetPool returns a pool for the given host, creating one if needed

func (*QUICManager) SetMaxConnsPerHost

func (m *QUICManager) SetMaxConnsPerHost(max int)

SetMaxConnsPerHost sets the max connections per host for new pools (0 = unlimited)

func (*QUICManager) Stats

func (m *QUICManager) Stats() map[string]struct {
	Total    int
	Healthy  int
	Requests int64
}

Stats returns overall manager statistics

Jump to

Keyboard shortcuts

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