utils

package
v0.4.10 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BinaryDecoder

func BinaryDecoder(payload io.Reader, dests ...interface{}) error

BinaryDecoder decodes the given payload from a binary stream and puts it in dest

func CryptoRandomNumber added in v0.3.0

func CryptoRandomNumber(max int64) int64

func GenerateRand16

func GenerateRand16(max int) uint16

GenerateRand16 Generates random uint16 num within the given max

func GenerateRand32

func GenerateRand32(max int) uint32

GenerateRand32 Generates a random uint32 within the given max

func GetLastIP

func GetLastIP(ipNet *net.IPNet) (net.IP, error)

GetLastIP Gets the last IP of a given Network

func IPToNum

func IPToNum(ip net.IP) uint32

IPToNum Converts given IP to uint32

func IPto32

func IPto32(s string) uint32

IPto32 Converts given IP string to uint32 representation

func NumToIP

func NumToIP(num uint32) net.IP

NumToIP Converts given uint32 to IP

func RandStringBytes

func RandStringBytes(n int) string

RandStringBytes Generates a random string of given length

func RandomIP

func RandomIP(cidr string) (net.IP, error)

RandomIP Picks a random IP from the given CIDR TODO: Better error handling needed

func RandomNum

func RandomNum(min, max int) int

RandomNum Generates a random number between the given min and max

func SendPacket added in v0.2.0

func SendPacket(conn *net.UDPConn, addr *net.UDPAddr, data bytes.Buffer, verbose bool) (int, error)

SendPacket Takes a given byte stream and puts on the wire towards the given host

func ToBytes

func ToBytes(key interface{}) ([]byte, error)

ToBytes Converts a given interface to a byte stream. Not used currently, but handy to have for later. Did not work for encoding Netflow packets as it encoded field names.

Types

type StatCollector added in v0.3.0

type StatCollector struct {
	StatsMap    map[int]models.WorkerStat
	StatsChan   chan models.WorkerStat
	StatsTotals models.StatTotals
	Config      *models.Config
}

StatCollector is used to gather stats about barrage and emit those stats via stdout and web ui

func (*StatCollector) DashboardHandler added in v0.3.1

func (sc *StatCollector) DashboardHandler(w http.ResponseWriter, r *http.Request)

DashboardHandler is used by web server to emit the Dashboard

func (*StatCollector) Run added in v0.3.0

func (sc *StatCollector) Run(wg *sync.WaitGroup, ctx context.Context)

Run is used to start the StatCollector

func (*StatCollector) StatsHandler added in v0.3.0

func (sc *StatCollector) StatsHandler(w http.ResponseWriter, r *http.Request)

StatsHandler is used by web server to emit stats as json

func (*StatCollector) Stop added in v0.3.0

func (sc *StatCollector) Stop()

Stop is used to close down the StatsChan gracefully

Jump to

Keyboard shortcuts

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