misc

package
v0.0.0-...-2036b99 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package misc are some small helper functions used throughout the xtcp code

It is perhaps poor form to name a module "misc", could be renamed to "utils"

Index

Constants

This section is empty.

Variables

View Source
var (
	// KernelEnumToString maps kernel enum to human string for the IP protocol
	KernelEnumToString = map[uint8]string{
		uint8(2):  "v4",
		uint8(10): "v6",
	}
)

Functions

func CheckFilePermissions

func CheckFilePermissions(filename string, permissions string) bool

CheckFilePermissions checks the permission bits on a filename 0755 e.g. pass filename and the permissions you want to check This is a crude string comparisions, and does NOT look at who is running this code, or the ownership of the file in question

func DieIfNotLinux

func DieIfNotLinux()

DieIfNotLinux as the name suggests kills this program if we aren't running on linux We only support Linux Although I think Darwin has netlink also TODO - test Darwin

func GetHostname

func GetHostname() string

GetHostname is a little gethostname helper with fatal error check arguably this function shouldn't exist

func MaxLoopsOrForEver

func MaxLoopsOrForEver(pollingLoops int, maxLoops int) bool

MaxLoopsOrForEver returns true if maxloops == 0, or pollingLoops < maxloops This function just allows us to embed if logic into the main pollingLoops for statement

func PrintMemUsage

func PrintMemUsage()

PrintMemUsage uses the go runtime libary to print out current memory usage

func ReadFile

func ReadFile(file string) []string

ReadFile reads a file and returns the lines as a slice Recommend using ScanFile because bufio.NewScanner is apparently faster Only including ReadFile to allow testing of ScanFile Compared to sc.Scan() above, rd.ReadString('\n') does NOT strip the '\n'

func ScanFile

func ScanFile(file string) []string

ScanFile reads a file and returns the lines as a slice Pleae note that the sc.Scan() strips the "\n", so this is being added back

Types

This section is empty.

Jump to

Keyboard shortcuts

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