session

package
v0.0.0-...-3e21e58 Latest Latest
Warning

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

Go to latest
Published: May 31, 2020 License: MIT Imports: 5 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 ContextWithContent

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

func ContextWithID

func ContextWithID(ctx context.Context, id ID) context.Context

ContextWithID returns a new context with the given ID.

func ContextWithInbound

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

func ContextWithMuxPrefered

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

ContextWithMuxPrefered returns a new context with the given bool

func ContextWithOutbound

func ContextWithOutbound(ctx context.Context, outbound *Outbound) context.Context

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 MuxPreferedFromContext

func MuxPreferedFromContext(ctx context.Context) bool

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

Types

type Content

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

	SniffingRequest SniffingRequest

	Attributes map[string]interface{}

	SkipRoutePick 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) interface{}

func (*Content) SetAttribute

func (c *Content) SetAttribute(name string, value interface{})

type ID

type ID uint32

ID of a session.

func IDFromContext

func IDFromContext(ctx context.Context) ID

IDFromContext returns ID in this context, or 0 if not contained.

func NewID

func NewID() 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.

type Inbound

type Inbound struct {
	// Source address of the inbound connection.
	Source net.Destination
	// Getaway address
	Gateway net.Destination
	// Tag of the inbound proxy that handles the connection.
	Tag string
	// User is the user that authencates for the inbound. May be nil if the protocol allows anounymous traffic.
	User *protocol.MemoryUser
}

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.
	Target net.Destination
	// Gateway address
	Gateway net.Address
	// ResolvedIPs is the resolved IP addresses, if the Targe is a domain address.
	ResolvedIPs []net.IP
}

Outbound is the metadata of an outbound connection.

func OutboundFromContext

func OutboundFromContext(ctx context.Context) *Outbound

type SniffingRequest

type SniffingRequest struct {
	OverrideDestinationForProtocol []string
	Enabled                        bool
}

Jump to

Keyboard shortcuts

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