Documentation
¶
Overview ¶
Package ctx provides typed context keys and helpers for passing per-request data (session ID, addresses, client ID, hash source) through the handler chain.
Index ¶
- func ContextWithClientID(ctx context.Context, clientID ClientID) context.Context
- func ContextWithDstAddr(ctx context.Context, addr net.Addr) context.Context
- func ContextWithHash(ctx context.Context, h *Hash) context.Context
- func ContextWithLabels(ctx context.Context, labels map[string]string) context.Context
- func ContextWithPeerCert(ctx context.Context, cert *PeerCert) context.Context
- func ContextWithSid(ctx context.Context, sid Sid) context.Context
- func ContextWithSocks5Cmd(ctx context.Context, cmd uint8) context.Context
- func ContextWithSrcAddr(ctx context.Context, addr net.Addr) context.Context
- func DstAddrFromContext(ctx context.Context) net.Addr
- func LabelsFromContext(ctx context.Context) map[string]string
- func Socks5CmdFromContext(ctx context.Context) (uint8, bool)
- func SrcAddrFromContext(ctx context.Context) net.Addr
- type ClientID
- type Context
- type Hash
- type PeerCert
- type Sid
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithClientID ¶
ContextWithClientID returns a copy of ctx that carries the client ID clientID.
func ContextWithDstAddr ¶ added in v0.0.3
ContextWithDstAddr returns a copy of ctx that carries the destination address addr.
func ContextWithHash ¶
ContextWithHash returns a copy of ctx that carries the hash source h.
func ContextWithLabels ¶ added in v0.28.1
ContextWithLabels returns a new context carrying the given service labels.
func ContextWithPeerCert ¶ added in v0.28.1
ContextWithPeerCert returns a copy of ctx that carries the peer cert.
func ContextWithSid ¶
ContextWithSid returns a copy of ctx that carries the session ID sid.
func ContextWithSocks5Cmd ¶ added in v0.28.1
ContextWithSocks5Cmd returns a copy of ctx that carries a SOCKS5 command override. Connectors use this to send a non-CONNECT command (e.g. Tor RESOLVE/RESOLVE_PTR) to the upstream proxy.
func ContextWithSrcAddr ¶ added in v0.0.3
ContextWithSrcAddr returns a copy of ctx that carries the source address addr.
func DstAddrFromContext ¶ added in v0.0.3
DstAddrFromContext returns the destination address stored in ctx, or nil if none is set.
func LabelsFromContext ¶ added in v0.28.1
LabelsFromContext returns the service labels stored in the context, or nil.
func Socks5CmdFromContext ¶ added in v0.28.1
Socks5CmdFromContext returns the SOCKS5 command override stored in ctx. The bool is false if no override is present.
Types ¶
type ClientID ¶
type ClientID string
ClientID is a client identifier used for hash-based load balancing.
func ClientIDFromContext ¶
ClientIDFromContext returns the client ID stored in ctx, or the zero value if none is set.
type Context ¶ added in v0.0.3
Context is implemented by connections that carry a context.Context.
type Hash ¶
type Hash struct {
Source string
}
Hash carries the hash source used by selectors for sticky load balancing.
func HashFromContext ¶
HashFromContext returns the hash source stored in ctx, or nil if none is set.
type PeerCert ¶ added in v0.28.1
PeerCert carries the verified mTLS client certificate identity.
func PeerCertFromContext ¶ added in v0.28.1
PeerCertFromContext returns the peer cert stored in ctx, or nil.
type Sid ¶
type Sid string
Sid is a session identifier carried in the context.
func SidFromContext ¶
SidFromContext returns the session ID stored in ctx, or the zero value if none is set.