Documentation ¶
Index ¶
- Constants
- type InstrumentedConn
- func (ic *InstrumentedConn) Close() error
- func (ic *InstrumentedConn) Error(err error)
- func (ic *InstrumentedConn) Idle() bool
- func (ic *InstrumentedConn) JsonStats() ([]byte, error)
- func (ic *InstrumentedConn) Read(b []byte) (int, error)
- func (ic *InstrumentedConn) Stats() *InstrumentedConnStats
- func (ic *InstrumentedConn) Write(b []byte) (int, error)
- type InstrumentedConnStats
- type Tracker
- func (tr *Tracker) MaybeIdleIn(d time.Duration) time.Duration
- func (t *Tracker) NewInstrumentedConn(conn net.Conn, logger *logrus.Entry, role, outboundHost, proxyType string) *InstrumentedConn
- func (t *Tracker) NewInstrumentedConnWithTimeout(conn net.Conn, timeout time.Duration, logger *logrus.Entry, ...) *InstrumentedConn
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) Stats ¶
func (ic *InstrumentedConn) Stats() *InstrumentedConnStats
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 (*Tracker) MaybeIdleIn ¶
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 ¶
Click to show internal directories.
Click to hide internal directories.