utils

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: BSD-3-Clause, GPL-3.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanIdent

func CleanIdent(path string) string

CleanIdent will clean a path

func ClearLine

func ClearLine()

ClearLine clears the current line of the terminal.

func ClearScreen

func ClearScreen()

ClearScreen prints ANSI escape to flush screen.

func Confirm

func Confirm(s string) bool

Confirm displays a prompt message to the terminal and returns a bool indicating the user decision.

func CopyFile

func CopyFile(src, dst string)

CopyFile the source file contents to destination file attributes wont be copied and an existing file will be overwritten.

func CreateFlowIdent

func CreateFlowIdent(srcIP, srcPort, dstIP, dstPort string) string

CreateFlowIdent creates a flow identifier string. format: srcIP:srcPort->dstIP:dstPort

func CreateFlowIdentFromLayerFlows

func CreateFlowIdentFromLayerFlows(net gopacket.Flow, trans gopacket.Flow) string

CreateFlowIdentFromLayerFlows creates a flow identifier string. format: srcIP:srcPort->dstIP:dstPort

func DecodePort

func DecodePort(raw []byte) int32

DecodePort decodes the network port directly from a byte slice.

func GetBaseLayer

func GetBaseLayer(value string) (t gopacket.LayerType)

GetBaseLayer resolves a baselayer string to the gopacket.LayerType.

func GetDecodeOptions

func GetDecodeOptions(value string) (o gopacket.DecodeOptions)

GetDecodeOptions resolves a decode option string to the gopacket.DecodeOptions type. Supported options:

  • "default": Safe, eager decoding with buffer copying (slowest but safest)
  • "lazy": Lazy decoding - minimum layers decoded (faster, but not concurrency-safe)
  • "nocopy": No buffer copy - faster but input buffer must not be modified
  • "datagrams": Decode TCP streams as datagrams (enables app-level layer decoding in TCP)
  • "pool": Use memory pooling for packet buffers (requires calling Dispose() on packets) When using pool mode, packets must be disposed via packet.Dispose() once processing is complete

func IsASCII

func IsASCII(d []byte) bool

IsASCII checks if input consists of ascii characters.

func ListAllNetworkInterfaces

func ListAllNetworkInterfaces()

ListAllNetworkInterfaces dumps a list of all visible network interfaces to stdout.

func Pad

func Pad(in any, length int) string

Pad the input up to the given number of space characters..

func ParseFlowIdent

func ParseFlowIdent(i string) (srcIP, srcPort, dstIP, dstPort string)

ParseFlowIdent parses the flow identifier. e.g: 192.168.1.47:53032->165.227.109.154:80 will return: 192.168.1.47, 53032, 165.227.109.154, 80 TODO: benchmark and improve performance TODO: IPv6

func Pluralize

func Pluralize(name string) string

Pluralize returns the plural for a given noun.

func Progress

func Progress(current, total int64) string

Progress returns the value in percent as a string suffixed with a %.

func ReverseFlowIdent

func ReverseFlowIdent(i string) string

ReverseFlowIdent reverses the flow identifier. e.g: 192.168.1.47:53032->165.227.109.154:80 will return: 165.227.109.154:80->192.168.1.47:53032 TODO: benchmark and improve performance TODO: IPv6

func SanitizeUTF8

func SanitizeUTF8(s string) string

SanitizeUTF8 replaces invalid UTF-8 sequences with the Unicode replacement character. This is necessary because protobuf string fields require valid UTF-8.

func StringToTime

func StringToTime(val string) time.Time

StringToTime converts a seconds.micro string to a time.Time.

func StripQueryString

func StripQueryString(inputUrl string) string

StripQueryString returns an URL without parameters

func TimeToUTC

func TimeToUTC(val string) string

TimeToUTC returns a time string in netcap format to a UTC string.

func TrimFileExtension

func TrimFileExtension(file string) string

TrimFileExtension returns the netcap file name without file extension.

func UnixTimeToUTC

func UnixTimeToUTC(val int64) string

UnixTimeToUTC returns a time string in netcap format to a UTC string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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