Documentation
¶
Overview ¶
Package traffic counts the bytes mimicry's sockets send and receive (Config.Traffic, decision 0070). Each socket keeps its own Counter, which a Meter sums when read, so counting is one uncontended atomic add per read or write. A socket's protocol and peer come from the Tag its dial carried in its context, set once per connection.
Index ¶
- func ProxyName(p *url.URL) string
- func With(ctx context.Context, t *Tag) context.Context
- func Wrap(conn net.Conn, c *Counter) net.Conn
- func WrapUDP(uc *net.UDPConn, c *Counter) net.PacketConn
- type Bytes
- type Conn
- type Counter
- type Meter
- type PacketConn
- type Peer
- type Protocol
- type Snapshot
- type Tag
- type UDPConn
- func (u *UDPConn) Close() error
- func (u *UDPConn) Read(p []byte) (int, error)
- func (u *UDPConn) ReadFrom(p []byte) (int, net.Addr, error)
- func (u *UDPConn) Received(n int)
- func (u *UDPConn) Sent(n int)
- func (u *UDPConn) UDP() *net.UDPConn
- func (u *UDPConn) Write(p []byte) (int, error)
- func (u *UDPConn) WriteTo(p []byte, addr net.Addr) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProxyName ¶
ProxyName is p without its credentials, path or query: scheme, host and port. "" for nil.
Types ¶
type Conn ¶
Conn is a TCP (or DNS) connection whose bytes c counts.
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
A Counter counts one socket's bytes. Methods are safe on nil.
type Meter ¶
type Meter struct {
// contains filtered or unexported fields
}
A Meter sums the counts of the sockets it opened. Its methods are safe on nil, which counts nothing.
type PacketConn ¶
type PacketConn struct {
Conn
// contains filtered or unexported fields
}
PacketConn is a connected datagram socket other than a *net.UDPConn (a Resolver.Dial's) whose bytes c counts.
type Peer ¶
type Peer struct {
Host, Proxy string
}
Peer is where a socket went: the host it was dialed for and the proxy it went through, as ProxyName gives it ("" for none).
type Snapshot ¶
type Snapshot struct {
Protocols [numProtocols]Bytes
// Hosts is nil unless the meter keeps them.
Hosts map[Peer]Bytes
}
Snapshot is a meter's counts.
type Tag ¶
type Tag struct {
// contains filtered or unexported fields
}
A Tag says what the sockets a dial opens carry and where they went. A dial passes it in its context (With); the socket reads it when its counts are summed, so the protocol may be set after the dial, once the handshake has picked it. Methods are safe on nil.
func (*Tag) Follow ¶
Follow makes t's sockets count as o's: an https proxy connection that carries one tunnel counts as that tunnel.
func (*Tag) SetProtocol ¶
SetProtocol sets what t's sockets carry.
type UDPConn ¶
UDPConn is a UDP socket whose bytes c counts. QUIC reads and writes the *net.UDPConn itself (UDP), in batches, counting through Sent and Received; its own Read, Write, ReadFrom and WriteTo count too.