utils

package
v0.0.0-...-ee9beca Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MASK_LOOKUP = func() map[int]net.IPMask {
	out := make(map[int]net.IPMask)
	for i := 0; i < 32; i++ {
		val := (1 << i) - 1
		out[val] = net.CIDRMask(32-i, 32)
	}
	return out
}()

Functions

func CIDR2Range

func CIDR2Range(cidr string) (uint32, uint32, error)

func CollectMapValues

func CollectMapValues[K comparable, T any](m map[K]T, c func(T) string) []string

func CollectSliceValues

func CollectSliceValues[T any](m []T, c func(T) string) []string

func FindIpInfo

func FindIpInfo[T IpRangeRecord](lib []T, ip net.IP) (T, bool)

func IP2Int

func IP2Int(ip net.IP) uint32

func Int2IP

func Int2IP(ip uint32) net.IP

func MapKeys

func MapKeys[T any](m map[string]T) []string

func Range2CIDR

func Range2CIDR(start, end uint32) *net.IPNet

func SliceToMapIndex

func SliceToMapIndex(lib []string) map[string]int

func SortUniqueSlice

func SortUniqueSlice[T cmp.Ordered](lib []T) []T

Types

type IpRangeRecord

type IpRangeRecord interface {
	GetStartIP() uint32
	GetEndIP() uint32
}

Jump to

Keyboard shortcuts

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