util

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// IP4arpa is the reverse tree suffix for v4 IP addresses.
	IP4arpa = ".in-addr.arpa."
	// IP6arpa is the reverse tree suffix for v6 IP addresses.
	IP6arpa = ".ip6.arpa."
)
View Source
const DefaultEditor = "vim"

DefaultEditor is vim because we're adults ;)

Variables

This section is empty.

Functions

func CaptureInputFromEditor

func CaptureInputFromEditor(data []byte) ([]byte, error)

CaptureInputFromEditor opens a temporary file with data in a text editor and returns the written bytes on success or an error on failure. It handles deletion of the temporary file behind the scenes.

func DefaultGateway added in v0.0.7

func DefaultGateway(ip net.IP) net.IP

func ExtractAddressFromReverse

func ExtractAddressFromReverse(reverseName string) string

ExtractAddressFromReverse turns a standard PTR reverse record name into an IP address. This works for ipv4 or ipv6.

54.119.58.176.in-addr.arpa. becomes 176.58.119.54. If the conversion fails the empty string is returned.

func GenerateSecret

func GenerateSecret(n int) (string, error)

func GetFirstExternalIPFromInterfaces

func GetFirstExternalIPFromInterfaces() (net.IP, error)

func GetInterfaceFromIP

func GetInterfaceFromIP(ip net.IP) (string, net.IPMask, error)

func GetInterfaceIPMap added in v0.0.8

func GetInterfaceIPMap() (map[int]net.IP, error)

func GetPreferredEditorFromEnvironment

func GetPreferredEditorFromEnvironment() string

GetPreferredEditorFromEnvironment returns the user's editor as defined by the `$EDITOR` environment variable, or the `DefaultEditor` if it is not set.

func IsReverse

func IsReverse(name string) int

IsReverse returns 0 is name is not in a reverse zone. Anything > 0 indicates name is in a reverse zone. The returned integer will be 1 for in-addr.arpa. (IPv4) and 2 for ip6.arpa. (IPv6).

func Normalize

func Normalize(name string) string

func OpenFileInEditor

func OpenFileInEditor(filename string) error

OpenFileInEditor opens filename in a text editor.

Types

type PreferredEditorResolver

type PreferredEditorResolver func() string

PreferredEditorResolver is a function that returns an editor that the user prefers to use, such as the configured `$EDITOR` environment variable.

Jump to

Keyboard shortcuts

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