Documentation
¶
Overview ¶
Package session provides functions for sessions of incoming requests.
Index ¶
- func AllowedNetworkFromContext(ctx context.Context) net.Network
- func ContextWithAllowedNetwork(ctx context.Context, network net.Network) context.Context
- func ContextWithContent(ctx context.Context, content *Content) context.Context
- func ContextWithDispatcher(ctx context.Context, dispatcher routing.Dispatcher) context.Context
- func ContextWithFullHandler(ctx context.Context, handler outbound.Handler) context.Context
- func ContextWithInbound(ctx context.Context, inbound *Inbound) context.Context
- func ContextWithIsReverseMux(ctx context.Context, isReverseMux bool) context.Context
- func ContextWithMitmAlpn11(ctx context.Context, alpn11 bool) context.Context
- func ContextWithMitmServerName(ctx context.Context, serverName string) context.Context
- func ContextWithOutbounds(ctx context.Context, outbounds []*Outbound) context.Context
- func ContextWithSockopt(ctx context.Context, s *Sockopt) context.Context
- func ContextWithTimeoutOnly(ctx context.Context, only bool) context.Context
- func DispatcherFromContext(ctx context.Context) routing.Dispatcher
- func ExportIDToError(ctx context.Context) errors.ExportOption
- func FullHandlerFromContext(ctx context.Context) outbound.Handler
- func GetForcedOutboundTagFromContext(ctx context.Context) string
- func IndependentCancelCtx(parent context.Context) context.Context
- func IsReverseMuxFromContext(ctx context.Context) bool
- func MitmAlpn11FromContext(ctx context.Context) bool
- func MitmServerNameFromContext(ctx context.Context) string
- func NewID() c.ID
- func SetForcedOutboundTagToContext(ctx context.Context, tag string) context.Context
- func SubContextFromMuxInbound(ctx context.Context) context.Context
- func SubmitOutboundErrorToOriginator(ctx context.Context, err error)
- func TimeoutOnlyFromContext(ctx context.Context) bool
- func TrackedConnectionError(ctx context.Context, tracker TrackedRequestErrorFeedback) context.Context
- type Content
- type Inbound
- type Outbound
- type SniffingRequest
- type Sockopt
- type TrackedRequestErrorFeedback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllowedNetworkFromContext ¶ added in v1.8.1
func ContextWithAllowedNetwork ¶ added in v1.8.1
func ContextWithContent ¶
func ContextWithDispatcher ¶ added in v1.5.6
func ContextWithFullHandler ¶ added in v1.251015.0
func ContextWithInbound ¶
func ContextWithIsReverseMux ¶ added in v1.251015.0
func ContextWithMitmAlpn11 ¶ added in v1.250306.0
func ContextWithMitmServerName ¶ added in v1.250306.0
func ContextWithOutbounds ¶ added in v1.8.12
func ContextWithTimeoutOnly ¶ added in v1.8.1
func DispatcherFromContext ¶ added in v1.5.6
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 FullHandlerFromContext ¶ added in v1.251015.0
func GetForcedOutboundTagFromContext ¶ added in v1.5.1
func IndependentCancelCtx ¶ added in v1.8.1
func IsReverseMuxFromContext ¶ added in v1.251015.0
func MitmAlpn11FromContext ¶ added in v1.250306.0
func MitmServerNameFromContext ¶ added in v1.250306.0
func NewID ¶
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 ¶ added in v1.5.1
func SubContextFromMuxInbound ¶ added in v1.250831.0
func SubmitOutboundErrorToOriginator ¶ added in v1.5.1
func TimeoutOnlyFromContext ¶ added in v1.8.1
func TrackedConnectionError ¶ added in v1.5.1
func TrackedConnectionError(ctx context.Context, tracker TrackedRequestErrorFeedback) context.Context
Types ¶
type Content ¶
type Content struct {
// Protocol of current content.
Protocol string
SniffingRequest SniffingRequest
// HTTP traffic sniffed headers
Attributes map[string]string
// SkipDNSResolve is set from DNS module. the DOH remote server maybe a domain name, this prevents cycle resolving dead loop
SkipDNSResolve bool
}
Content is the metadata of the connection content. Mainly used for routing.
func ContentFromContext ¶
func (*Content) SetAttribute ¶
SetAttribute attaches additional string attributes to content.
type Inbound ¶
type Inbound struct {
// Source address of the inbound connection.
Source net.Destination
// Local address of the inbound connection.
Local 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
// VlessRoute is the user-sent VLESS UUID's 7th<<8 | 8th bytes.
VlessRoute net.Port
// Used by splice copy. Conn is actually internet.Connection. May be nil.
Conn net.Conn
// Used by splice copy. 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 ¶
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
// Unused. 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.12
type SniffingRequest ¶
type SniffingRequest struct {
ExcludeForDomain []string
OverrideDestinationForProtocol []string
Enabled bool
MetadataOnly bool
RouteOnly bool
}
SniffingRequest controls the behavior of content sniffing. They are from inbound config. Read-only
type Sockopt ¶
type Sockopt struct {
// Mark of the socket connection.
Mark int32
}
Sockopt is the settings for socket connection.
func SockoptFromContext ¶
type TrackedRequestErrorFeedback ¶ added in v1.5.1
type TrackedRequestErrorFeedback interface {
SubmitError(err error)
}