freconn

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2021 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagRatelimit = 1 << iota
	FlagStat
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	net.Conn
	Flag     int
	TxBucket *ratelimit.Bucket
	RxBucket *ratelimit.Bucket
	*Stat
}

func UpgradeConn

func UpgradeConn(c net.Conn) *Conn

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) EnableStat

func (c *Conn) EnableStat(stat *Stat)

func (*Conn) Read

func (c *Conn) Read(b []byte) (int, error)

func (*Conn) Write

func (c *Conn) Write(b []byte) (int, error)

type PacketConn

type PacketConn struct {
	net.PacketConn
	Flag     int
	TxBucket *ratelimit.Bucket
	RxBucket *ratelimit.Bucket
	Stat     *Stat
}

func UpgradePacketConn

func UpgradePacketConn(pc net.PacketConn) *PacketConn

func (*PacketConn) EnableStat

func (c *PacketConn) EnableStat(stat *Stat)

func (*PacketConn) ReadFrom

func (c *PacketConn) ReadFrom(b []byte) (int, net.Addr, error)

func (*PacketConn) WriteTo

func (c *PacketConn) WriteTo(b []byte, addr net.Addr) (int, error)

type Stat

type Stat struct {
	Rx uint64 `json:"rx"`
	Tx uint64 `json:"tx"`

	In1  StatStatus `json:"in1"`
	In10 StatStatus `json:"in10"`
	// contains filtered or unexported fields
}

func NewStat

func NewStat() *Stat

func (*Stat) AddRx

func (s *Stat) AddRx(len uint64)

func (*Stat) AddTx

func (s *Stat) AddTx(len uint64)

func (*Stat) Bandwidth1

func (s *Stat) Bandwidth1() (r, t uint64, lastTime time.Time)

func (*Stat) Bandwidth10

func (s *Stat) Bandwidth10() (r, t uint64, lastTime time.Time)

func (*Stat) Reset

func (s *Stat) Reset()

func (*Stat) RunBandwidthIn1

func (s *Stat) RunBandwidthIn1()

func (*Stat) RunBandwidthIn10

func (s *Stat) RunBandwidthIn10()

func (*Stat) StopBandwidthIn1

func (s *Stat) StopBandwidthIn1()

type StatStatus

type StatStatus struct {
	Time        time.Time
	Rx          uint64 `json:"rx"`
	Tx          uint64 `json:"tx"`
	BandwidthRx uint64 `json:"bandwidth_rx"`
	BandwidthTx uint64 `json:"bandwidth_tx"`
}

func (*StatStatus) Reset

func (s *StatStatus) Reset()

Jump to

Keyboard shortcuts

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