package corenet

import "github.com/purpleidea/mgmt/lang/core/net"

Index

Constants

const (
	// ModuleName is the prefix given to all the functions in this module.
	ModuleName = "net"
)

Functions

func CidrToFirst

func CidrToFirst(ctx context.Context, input []types.Value) (types.Value, error)

CidrToFirst returns the first usable IP from a CIDR address.

func CidrToIP

func CidrToIP(ctx context.Context, input []types.Value) (types.Value, error)

CidrToIP returns the IP from a CIDR address.

func CidrToLast

func CidrToLast(ctx context.Context, input []types.Value) (types.Value, error)

CidrToLast returns the last IP from a CIDR address. It's often used as the "broadcast" ip.

func CidrToMask

func CidrToMask(ctx context.Context, input []types.Value) (types.Value, error)

CidrToMask returns the subnet mask from a CIDR address.

func CidrToPrefix

func CidrToPrefix(ctx context.Context, input []types.Value) (types.Value, error)

CidrToPrefix returns the prefix from a CIDR address. For example, if you give us 192.0.2.0/24 then we will return "24" as a string.

func IsMac

func IsMac(ctx context.Context, input []types.Value) (types.Value, error)

IsMac takes a string and returns true if it's a mac in the standard format.

func MacFmt

func MacFmt(ctx context.Context, input []types.Value) (types.Value, error)

MacFmt takes a MAC address with hyphens and converts it to a format with colons.

func Macs

func Macs(ctx context.Context, input []types.Value) (types.Value, error)

Macs returns the list of mac addresses that are seen on the machine.

XXX: These should produce new values if the list of interfaces change.

func OldMacFmt

func OldMacFmt(ctx context.Context, input []types.Value) (types.Value, error)

OldMacFmt takes a MAC address with colons and converts it to a format with hyphens. This is the old deprecated style that nobody likes.

func URLParser

func URLParser(ctx context.Context, input []types.Value) (types.Value, error)

URLParser takes a URL as a string, and extracts the different components of the URL: scheme, host, path, and query. The function will error out if the given URL doesn't contain a valid URL, as this is a requirement of the underlying net/url library. Note that additional fields may be added to the output in the future.

Source Files

cidr_to_ip.go macfmt.go macs.go net.go url_parser.go

Version
v0.0.0-20250322185616-c50a578426f1 (latest)
Published
Mar 22, 2025
Platform
linux/amd64
Imports
11 packages
Last checked
4 days ago

Tools for package owners.