Documentation ¶
Overview ¶
Package transferstats counts and keeps track of session stats. These are per-domain bytes transferred and total bytes transferred.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PutBackStatsForServer ¶
func PutBackStatsForServer(serverID string, accumulatedStats *AccumulatedStats)
PutBackStatsForServer re-adds a set of server stats to the collection.
func ReportRecentBytesTransferredForServer ¶
ReportRecentBytesTransferredForServer returns bytes sent and received since the last call to ReportRecentBytesTransferredForServer. The accumulated sent and received are reset to 0 by this call.
Types ¶
type AccumulatedStats ¶
type AccumulatedStats struct {
// contains filtered or unexported fields
}
AccumulatedStats holds the Psiphon Server API status request data for a given server. To accommodate status requests that may fail, and be retried, the TakeOutStatsForServer/PutBackStatsForServer procedure allows the requester to check out stats for reporting and merge back stats for a later retry.
func TakeOutStatsForServer ¶
func TakeOutStatsForServer(serverID string) (accumulatedStats *AccumulatedStats)
TakeOutStatsForServer borrows the AccumulatedStats for the specified server. When we fail to report these stats, resubmit them with PutBackStatsForServer. Stats will continue to be accumulated between TakeOut and PutBack calls. The recentBytes values are unaffected by TakeOut/PutBack. Returns empty stats if the serverID is not found.
func (AccumulatedStats) GetStatsForStatusRequest ¶
func (stats AccumulatedStats) GetStatsForStatusRequest() map[string]int64
GetStatsForStatusRequest summarizes AccumulatedStats data as required for the Psiphon Server API status request.
type Conn ¶
Conn is to be used as an intermediate link in a chain of net.Conn objects. It inspects requests and responses and derives stats from them.
func NewConn ¶
NewConn creates a Conn. serverID can be anything that uniquely identifies the server; it will be passed to TakeOutStatsForServer() when retrieving the accumulated stats.