Documentation ¶
Overview ¶
Package session provides functions for sessions of incoming requests.
Index ¶
- func ContextWithContent(ctx context.Context, content *Content) context.Context
- func ContextWithID(ctx context.Context, id ID) context.Context
- func ContextWithInbound(ctx context.Context, inbound *Inbound) context.Context
- func ContextWithOutbound(ctx context.Context, outbound *Outbound) context.Context
- func ContextWithProxyRecord(ctx context.Context, record *ProxyRecord) context.Context
- func ContextWithProxySession(ctx context.Context, sess *stats.Session) context.Context
- func ExportIDToError(ctx context.Context) errors.ExportOption
- func InsertRecord(record *ProxyRecord)
- func ProxySessionFromContext(ctx context.Context) *stats.Session
- type Content
- type DBService
- type ID
- type Inbound
- type Outbound
- type ProxyRecord
- type SniffingRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithContent ¶
func ContextWithID ¶
ContextWithID returns a new context with the given ID.
func ContextWithInbound ¶
func ContextWithOutbound ¶
func ContextWithProxyRecord ¶
func ContextWithProxyRecord(ctx context.Context, record *ProxyRecord) context.Context
func ContextWithProxySession ¶
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 InsertRecord ¶
func InsertRecord(record *ProxyRecord)
Types ¶
type Content ¶
type Content struct { // Protocol of current content. Protocol string SniffingRequest SniffingRequest Attributes map[string]interface{} Application []string Network string LocalAddr string RemoteAddr string Extra string OutboundTag string }
Content is the metadata of the connection content.
func ContentFromContext ¶
func (*Content) SetAttribute ¶
type DBService ¶
type DBService interface {
InsertProxyLog(target, tag string, startTime, endTime int64, uploadBytes, downloadBytes int32, recordType, dnsQueryType int32, dnsRequest, dnsResponse string, dnsNumIPs int32)
}
var DefaultDBService DBService
type ID ¶
type ID uint32
ID of a session.
func IDFromContext ¶
IDFromContext returns ID in this context, or 0 if not contained.
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 NoSource bool }
Inbound is the metadata of an inbound connection.
func InboundFromContext ¶
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 Timeout time.Duration }
Outbound is the metadata of an outbound connection.
func OutboundFromContext ¶
type ProxyRecord ¶
type ProxyRecord struct { Target string Tag string StartTime int64 EndTime int64 UploadBytes int32 DownloadBytes int32 RecordType int32 // 0: TCP/UDP, 1: DNS DNSQueryType int32 DNSRequest string DNSResponse string DNSNumIPs int32 }
func ProxyRecordFromContext ¶
func ProxyRecordFromContext(ctx context.Context) *ProxyRecord
func (*ProxyRecord) AddDownloadBytes ¶
func (r *ProxyRecord) AddDownloadBytes(n int32)
func (*ProxyRecord) AddUploadBytes ¶
func (r *ProxyRecord) AddUploadBytes(n int32)
type SniffingRequest ¶
Click to show internal directories.
Click to hide internal directories.