Documentation
¶
Overview ¶
Package session provides functions for sessions of incoming requests.
Index ¶
- func ContextWithID(ctx context.Context, id uint32) context.Context
- func ContextWithInfo(ctx context.Context, info *Info) context.Context
- func GetCtx(ctx context.Context) context.Context
- func IDFromContext(ctx context.Context) (uint32, bool)
- type DownCounter
- type DownCounters
- type ID
- type Info
- func (c *Info) GetAppId() string
- func (c *Info) GetFakeIP() net.IP
- func (c *Info) GetInboundTag() string
- func (c *Info) GetNetwork() net.Network
- func (c *Info) GetSourceAddr() net.Destination
- func (c *Info) GetSourceIPs() net.IP
- func (c *Info) GetSourcePort() net.Port
- func (c *Info) GetTargetAddr() net.Destination
- func (c *Info) GetTargetDomain() string
- func (c *Info) GetTargetIP() net.IP
- func (c *Info) GetTargetPort() net.Port
- func (c *Info) GetUser() string
- type Option
- func WithAppId(appId string) Option
- func WithGateway(gtw net.Destination) Option
- func WithInboundProtocol(s string) Option
- func WithInboundTag(tag string) Option
- func WithSource(src net.Destination) Option
- func WithTarget(tgt net.Destination) Option
- func WithUdpUuid(uuid uuid.UUID) Option
- func WithUser(user string) Option
- type SessionCtxKey
- type Sockopt
- type UpCounter
- type UpCounters
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithID ¶ added in v1.0.2
Types ¶
type DownCounter ¶
type DownCounter interface {
DownTraffic(uint64)
}
type DownCounters ¶
type DownCounters []DownCounter
func (DownCounters) DownTraffic ¶
func (c DownCounters) DownTraffic(n uint64)
type ID ¶
type ID uint32
ID of a session. For debugging purpose.
type Info ¶
type Info struct {
ID ID
Source net.Destination
Gateway net.Destination
// if not nil, this is the original target address and it is an ip in fake dns pool
FakeIP net.IP
Target net.Destination
InboundTag string
InboundProtocol string
UdpUuid uuid.UUID
Sockopt *Sockopt
User string
Sniffed bool
Protocol string
SniffedDomain string
AppId string
MatchedRule string
ActivityChecker *signal.ActivityChecker
// all up traffic should be added to the counter. It typically contains user traffic meter,
// session traffic meter, and outbound link traffic meter.
UpCounter UpCounters
DownCounter DownCounters
// for debug purpose
SessionUpCounter atomic.Uint64
SessionDownCounter atomic.Uint64
// the selector being used initially
UsedSelector string
}
func InfoFromContext ¶
func NewInfoInbound ¶
func (*Info) GetInboundTag ¶
func (*Info) GetNetwork ¶
func (*Info) GetSourceAddr ¶
func (c *Info) GetSourceAddr() net.Destination
func (*Info) GetSourceIPs ¶
func (*Info) GetSourcePort ¶
func (*Info) GetTargetAddr ¶
func (c *Info) GetTargetAddr() net.Destination
func (*Info) GetTargetDomain ¶
func (*Info) GetTargetIP ¶
func (*Info) GetTargetPort ¶
type Option ¶
type Option func(*Info)
func WithGateway ¶
func WithGateway(gtw net.Destination) Option
func WithInboundProtocol ¶
func WithInboundTag ¶
func WithSource ¶
func WithSource(src net.Destination) Option
func WithTarget ¶
func WithTarget(tgt net.Destination) Option
func WithUdpUuid ¶
type Sockopt ¶
type Sockopt struct {
// Mark of the socket connection.
Mark uint32
InterfaceName4 string
InterfaceName6 string
}
Sockopt is the settings for socket connection.
func SockoptFromContext ¶
// SockoptFromContext returns Socket configs in this context, or nil if not contained.
type UpCounters ¶
type UpCounters []UpCounter
func (UpCounters) UpTraffic ¶
func (c UpCounters) UpTraffic(n uint64)
Click to show internal directories.
Click to hide internal directories.