Documentation
¶
Overview ¶
Package hop defines the Hop interface for selecting a node from a group of equivalent proxy nodes using load-balancing strategies.
Index ¶
- type Hop
- type NodeList
- type SelectOption
- func AddrSelectOption(addr string) SelectOption
- func BodySelectOption(body []byte) SelectOption
- func ClientIPSelectOption(clientIP net.IP) SelectOption
- func HeaderSelectOption(header http.Header) SelectOption
- func HostSelectOption(host string) SelectOption
- func MethodSelectOption(method string) SelectOption
- func NetworkSelectOption(network string) SelectOption
- func PathSelectOption(path string) SelectOption
- func ProtocolSelectOption(protocol string) SelectOption
- func QuerySelectOption(query url.Values) SelectOption
- type SelectOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hop ¶
type Hop interface {
// Select picks a Node from the group based on the selection options.
// It returns nil if no node is available.
Select(ctx context.Context, opts ...SelectOption) *chain.Node
}
Hop represents a group of functionally equivalent proxy nodes. It uses a selector.Strategy to pick one node from the group, enabling load balancing (round-robin, random, weighted, etc.) across redundant proxy servers.
type NodeList ¶
NodeList provides access to all nodes in a group. Implemented by hops that expose their full node list for introspection or custom routing.
type SelectOption ¶
type SelectOption func(*SelectOptions)
SelectOption is a functional option for configuring SelectOptions.
func AddrSelectOption ¶
func AddrSelectOption(addr string) SelectOption
AddrSelectOption sets the destination address.
func BodySelectOption ¶ added in v0.6.1
func BodySelectOption(body []byte) SelectOption
BodySelectOption sets the size-capped HTTP request body prefix used for body matching.
func ClientIPSelectOption ¶ added in v0.3.2
func ClientIPSelectOption(clientIP net.IP) SelectOption
ClientIPSelectOption sets the client IP.
func HeaderSelectOption ¶ added in v0.3.2
func HeaderSelectOption(header http.Header) SelectOption
HeaderSelectOption sets the HTTP headers.
func HostSelectOption ¶
func HostSelectOption(host string) SelectOption
HostSelectOption sets the target hostname.
func MethodSelectOption ¶ added in v0.3.2
func MethodSelectOption(method string) SelectOption
MethodSelectOption sets the HTTP method.
func NetworkSelectOption ¶
func NetworkSelectOption(network string) SelectOption
NetworkSelectOption sets the network type.
func PathSelectOption ¶
func PathSelectOption(path string) SelectOption
PathSelectOption sets the HTTP request path.
func ProtocolSelectOption ¶
func ProtocolSelectOption(protocol string) SelectOption
ProtocolSelectOption sets the proxy protocol.
func QuerySelectOption ¶ added in v0.3.2
func QuerySelectOption(query url.Values) SelectOption
QuerySelectOption sets the HTTP query parameters.
type SelectOptions ¶
type SelectOptions struct {
// ClientIP is the client's IP address.
ClientIP net.IP
// Network is the connection network type ("tcp", "udp").
Network string
// Addr is the destination address.
Addr string
// Protocol is the proxy protocol in use.
Protocol string
// Host is the target hostname (from HTTP Host header or TLS SNI).
Host string
// Method is the HTTP request method.
Method string
// Path is the HTTP request path.
Path string
// Query is the HTTP request query parameters.
Query url.Values
// Header is the HTTP request headers.
Header http.Header
// Body is a size-capped prefix of the HTTP request body, populated by
// the caller when at least one node opts in to body matching via a
// non-zero chain.MatcherBodySize. Nil/empty when body matching is not
// in use.
Body []byte
}
SelectOptions holds the runtime context used to select a node. These provide HTTP-level visibility into the request, allowing routing decisions based on hostname, path, headers, etc.