session

package
v1.8.25 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2024 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package session provides functions for sessions of incoming requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowedNetworkFromContext

func AllowedNetworkFromContext(ctx context.Context) net.Network

func ContextCloneOutbounds added in v1.8.24

func ContextCloneOutbounds(ctx context.Context) context.Context

func ContextWithAllowedNetwork

func ContextWithAllowedNetwork(ctx context.Context, network net.Network) context.Context

func ContextWithContent

func ContextWithContent(ctx context.Context, content *Content) context.Context

func ContextWithDispatcher

func ContextWithDispatcher(ctx context.Context, dispatcher routing.Dispatcher) context.Context

func ContextWithInbound

func ContextWithInbound(ctx context.Context, inbound *Inbound) context.Context

func ContextWithMuxPreferred added in v1.8.24

func ContextWithMuxPreferred(ctx context.Context, forced bool) context.Context

ContextWithMuxPreferred returns a new context with the given bool

func ContextWithOutbounds added in v1.8.24

func ContextWithOutbounds(ctx context.Context, outbounds []*Outbound) context.Context

func ContextWithSockopt

func ContextWithSockopt(ctx context.Context, s *Sockopt) context.Context

ContextWithSockopt returns a new context with Socket configs included

func ContextWithTimeoutOnly

func ContextWithTimeoutOnly(ctx context.Context, only bool) context.Context

func DispatcherFromContext

func DispatcherFromContext(ctx context.Context) routing.Dispatcher

func ExportIDToError

func ExportIDToError(ctx context.Context) errors.ExportOption

ExportIDToError transfers session.ID into an error object, for logging purpose. This can be used with error.WriteToLog().

func GetForcedOutboundTagFromContext

func GetForcedOutboundTagFromContext(ctx context.Context) string

func IndependentCancelCtx

func IndependentCancelCtx(parent context.Context) context.Context

func MuxPreferredFromContext added in v1.8.24

func MuxPreferredFromContext(ctx context.Context) bool

MuxPreferredFromContext returns value in this context, or false if not contained.

func NewID

func NewID() c.ID

NewID generates a new ID. The generated ID is high likely to be unique, but not cryptographically secure. The generated ID will never be 0.

func SetForcedOutboundTagToContext

func SetForcedOutboundTagToContext(ctx context.Context, tag string) context.Context

func SubmitOutboundErrorToOriginator

func SubmitOutboundErrorToOriginator(ctx context.Context, err error)

func TimeoutOnlyFromContext

func TimeoutOnlyFromContext(ctx context.Context) bool

func TrackedConnectionError

func TrackedConnectionError(ctx context.Context, tracker TrackedRequestErrorFeedback) context.Context

Types

type Content

type Content struct {
	// Protocol of current content.
	Protocol string

	SniffingRequest SniffingRequest

	Attributes map[string]string

	SkipDNSResolve bool
}

Content is the metadata of the connection content.

func ContentFromContext

func ContentFromContext(ctx context.Context) *Content

func (*Content) Attribute

func (c *Content) Attribute(name string) string

Attribute retrieves additional string attributes from content.

func (*Content) SetAttribute

func (c *Content) SetAttribute(name string, value string)

SetAttribute attaches additional string attributes to content.

type Inbound

type Inbound struct {
	// Source address of the inbound connection.
	Source net.Destination
	// Gateway address.
	Gateway net.Destination
	// Tag of the inbound proxy that handles the connection.
	Tag string
	// Name of the inbound proxy that handles the connection.
	Name string
	// User is the user that authenticates for the inbound. May be nil if the protocol allows anonymous traffic.
	User *protocol.MemoryUser
	// Conn is actually internet.Connection. May be nil.
	Conn net.Conn
	// Timer of the inbound buf copier. May be nil.
	Timer *signal.ActivityTimer
	// CanSpliceCopy is a property for this connection
	// 1 = can, 2 = after processing protocol info should be able to, 3 = cannot
	CanSpliceCopy int
}

Inbound is the metadata of an inbound connection.

func InboundFromContext

func InboundFromContext(ctx context.Context) *Inbound

type Outbound

type Outbound struct {
	// Target address of the outbound connection.
	OriginalTarget net.Destination
	Target         net.Destination
	RouteTarget    net.Destination
	// Gateway address
	Gateway net.Address
	// Tag of the outbound proxy that handles the connection.
	Tag string
	// Name of the outbound proxy that handles the connection.
	Name string
	// Conn is actually internet.Connection. May be nil. It is currently nil for outbound with proxySettings
	Conn net.Conn
	// CanSpliceCopy is a property for this connection
	// 1 = can, 2 = after processing protocol info should be able to, 3 = cannot
	CanSpliceCopy int
}

Outbound is the metadata of an outbound connection.

func OutboundsFromContext added in v1.8.24

func OutboundsFromContext(ctx context.Context) []*Outbound

type SniffingRequest

type SniffingRequest struct {
	ExcludeForDomain               []string
	OverrideDestinationForProtocol []string
	Enabled                        bool
	MetadataOnly                   bool
	RouteOnly                      bool
}

SniffingRequest controls the behavior of content sniffing.

type Sockopt

type Sockopt struct {
	// Mark of the socket connection.
	Mark int32
}

Sockopt is the settings for socket connection.

func SockoptFromContext

func SockoptFromContext(ctx context.Context) *Sockopt

SockoptFromContext returns Socket configs in this context, or nil if not contained.

type TrackedRequestErrorFeedback

type TrackedRequestErrorFeedback interface {
	SubmitError(err error)
}

Jump to

Keyboard shortcuts

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