templates

package
v0.9.23 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package templates [provides utility functions to enable templating in app configuration]

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(logger *zap.Logger, tpl *template.Template, data any) string

Execute template, returns empty string in case of errors

func LocalIPV4 added in v0.8.0

func LocalIPV4() string

LocalIPV4 returns the first non loopback local ipv4 of the host

func LocalIPV6 added in v0.8.0

func LocalIPV6() string

LocalIPV6 returns the first non loopback local ipv4 of the host

func LocalMacAddres added in v0.8.0

func LocalMacAddres() string

LocalMacAddres returns first valid mac address

func Parse

func Parse(input string) (*template.Template, error)

Parse a template

func ParseAndExecute

func ParseAndExecute(logger *zap.Logger, input string, data any) string

ParseAndExecute template, returns input string in case of errors. Expensive operation.

func ParseAndExecuteMapStruct

func ParseAndExecuteMapStruct(logger *zap.Logger, input map[string]any, data any) map[string]any

ParseAndExecuteMapStruct is like ParseAndExecute but takes mapstructure as input

func RandomIP added in v0.8.0

func RandomIP() string

RandomIP returns a random ip to spoof packets.

func RandomMacAddr added in v0.8.0

func RandomMacAddr() net.HardwareAddr

RandomMacAddr returns a random MAC address to spoof packets.

func RandomPayload added in v0.8.0

func RandomPayload(length int) string

RandomPayload returns a string to spoof ip packets with random payload in specified length.

func RandomPayloadByte added in v0.8.3

func RandomPayloadByte(length int) []byte

RandomPayloadByte returns a byte slice to spoof ip packets with random payload in specified length.

func RandomPort added in v0.8.0

func RandomPort() int

RandomPort returns a random port to spoof packets.

func ResolveHostIPV4 added in v0.8.0

func ResolveHostIPV4(host string) (string, error)

ResolveHostIPV4 function gets a string and returns the ipv4 address

func ResolveHostIPV6 added in v0.8.0

func ResolveHostIPV6(host string) (string, error)

ResolveHostIPV6 function gets a string and returns the ipv4 address

Types

type ContextKey

type ContextKey string

ContextKey used to work with context and not trigger linter

type MapStruct

type MapStruct struct {
	// contains filtered or unexported fields
}

MapStruct is a helper structure to parse configs in a format accepted by mapstructure package

func ParseMapStruct

func ParseMapStruct(input map[string]any) (*MapStruct, error)

ParseMapStruct is like Parse but takes mapstructure as input

func (*MapStruct) Execute

func (tpl *MapStruct) Execute(logger *zap.Logger, data any) map[string]any

Execute same as regular Execute

Jump to

Keyboard shortcuts

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