transferstats

package
v0.0.8-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2015 License: GPL-3.0 Imports: 9 Imported by: 0

README

transferstats Package

This provides a net.Conn interface implementation that can be put in a chain of connections and used to collect transfer statistics for the network traffic passing through it.

Total bytes transferred is recorded, as well as per-hostname bytes transferred stats for HTTP and HTTPS traffic (as long as the HTTPS traffic contains SNI information). Which hostnames are recorded is specified by a set of regular expressions.

(TODO: More info.)

Documentation

Overview

Package stats 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 GetForServer

func GetForServer(serverID string) (payload *serverStats)

GetForServer returns the json-able stats package for the given server. If there are no stats, nil will be returned.

func PutBack

func PutBack(serverID string, ss *serverStats)

PutBack re-adds a set of server stats to the collection.

Types

type Conn

type Conn struct {
	net.Conn
	// contains filtered or unexported fields
}

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

func NewConn(nextConn net.Conn, serverID string, regexps *Regexps) *Conn

NewConn creates a Conn. serverID can be anything that uniquely identifies the server; it will be passed to GetForServer() when retrieving the accumulated stats.

func (*Conn) Read

func (conn *Conn) Read(buffer []byte) (n int, err error)

Read is called when responses to requests are being read from the remote server.

func (*Conn) Write

func (conn *Conn) Write(buffer []byte) (n int, err error)

Write is called when requests are being written out through the tunnel to the remote server.

type Regexps

type Regexps []regexpReplace

Regexps holds the regular expressions and replacement strings used for transforming URLs and hostnames into a stats-appropriate forms.

func MakeRegexps

func MakeRegexps(pageViewRegexes, httpsRequestRegexes []map[string]string) (regexps *Regexps, notices []string)

MakeRegexps takes the raw string-map form of the regex-replace pairs returned by the server handshake and turns them into a usable object.

Jump to

Keyboard shortcuts

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