hop

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 5 Imported by: 2 modules, 16 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package hop defines the Hop interface for selecting a node from a group of equivalent proxy nodes using load-balancing strategies.

Index

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

type NodeList interface {
	Nodes() []*chain.Node
}

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.

Jump to

Keyboard shortcuts

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