conntrack

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogFieldBytesIn         = "bytes_in"
	LogFieldBytesOut        = "bytes_out"
	LogFieldEndTime         = "end_time"
	LogFieldDuration        = "duration"
	LogFieldError           = "error"
	LogFieldLastActivity    = "last_activity"
	CanonicalProxyConnClose = "CANONICAL-PROXY-CN-CLOSE"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type InstrumentedConn

type InstrumentedConn struct {
	net.Conn
	Role         string
	OutboundHost string

	ConnError error

	Start        time.Time
	LastActivity *int64 // Unix nano

	BytesIn  *uint64
	BytesOut *uint64

	sync.Mutex

	CloseError error
	// contains filtered or unexported fields
}

func (*InstrumentedConn) Close

func (ic *InstrumentedConn) Close() error

func (*InstrumentedConn) Error

func (ic *InstrumentedConn) Error(err error)

func (*InstrumentedConn) Idle

func (ic *InstrumentedConn) Idle() bool

Idle returns true when the connection's last activity occured before the configured idle threshold.

Idle should be called with the connection's lock held.

func (*InstrumentedConn) JsonStats

func (ic *InstrumentedConn) JsonStats() ([]byte, error)

func (*InstrumentedConn) Read

func (ic *InstrumentedConn) Read(b []byte) (int, error)

func (*InstrumentedConn) Stats

func (*InstrumentedConn) Write

func (ic *InstrumentedConn) Write(b []byte) (int, error)

type InstrumentedConnStats

type InstrumentedConnStats struct {
	Role                     string    `json:"role"`
	Rhost                    string    `json:"rhost"`
	Raddr                    string    `json:"raddr"`
	Created                  time.Time `json:"created"`
	BytesIn                  uint64    `json:"bytesIn"`
	BytesOut                 uint64    `json:"bytesOut"`
	SecondsSinceLastActivity float64   `json:"secondsSinceLastActivity"`
	ProxyType                string    `json:"proxyType"`
}

type Tracker

type Tracker struct {
	*sync.Map
	ShuttingDown atomic.Value
	Wg           *sync.WaitGroup

	// A connection is idle if it has been inactive (no bytes in/out) for this
	// many seconds.
	IdleTimeout time.Duration
	// contains filtered or unexported fields
}

func NewTracker

func NewTracker(idle time.Duration, statsc statsd.ClientInterface, logger *logrus.Logger, sd atomic.Value) *Tracker

func (*Tracker) MaybeIdleIn

func (tr *Tracker) MaybeIdleIn(d time.Duration) time.Duration

MaybeIdleIn returns the longest amount of time it will take for all tracked connections to become idle based on the configured IdleTimeout.

A duration of 0 indicates all connections are idle.

func (*Tracker) NewInstrumentedConn

func (t *Tracker) NewInstrumentedConn(conn net.Conn, logger *logrus.Entry, role, outboundHost, proxyType string) *InstrumentedConn

func (*Tracker) NewInstrumentedConnWithTimeout

func (t *Tracker) NewInstrumentedConnWithTimeout(conn net.Conn, timeout time.Duration, logger *logrus.Entry, role, outboundHost, proxyType string) *InstrumentedConn

Jump to

Keyboard shortcuts

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