utils

package
v0.0.0-...-11a1dea Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2025 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

func Contains

func Contains(a string, values []string) bool

func DecryptAESGCM

func DecryptAESGCM(ciphertext, key []byte) ([]byte, error)

DecryptAESGCM decrypts ciphertext using AES-GCM with the provided key.

func DecryptAESGCMFromString

func DecryptAESGCMFromString(ciphertextB64 string, key []byte) ([]byte, error)

DecryptAESGCMFromString decodes base64 string and decrypts using AES-GCM.

func DownloadGeoIpDatabase

func DownloadGeoIpDatabase() error

func EncryptAESGCM

func EncryptAESGCM(plaintext, key []byte) ([]byte, error)

EncryptAESGCM encrypts plaintext using AES-GCM with the provided key.

func EncryptAESGCMToString

func EncryptAESGCMToString(plaintext, key []byte) (string, error)

EncryptAESGCMToString encrypts plaintext and returns a base64 string for DB storage.

func GetCountryShort

func GetCountryShort(ip string) string

func GetJoinCode

func GetJoinCode(unitId string) string

generate join code the join code is a JSON encoded in base64 with the following fields: - unit_id - registration token - fqdn

func HashPassword

func HashPassword(password string) string

func InitGeoIP

func InitGeoIP() error

func ListIPs

func ListIPs(ipArg string, netmaskArg string) ([]string, error)

func Remove

func Remove(a string, values []string) []string

func ToCIDR

func ToCIDR(ipStr, maskStr string) string

ToCIDR converts an IPv4 address and a netmask string into CIDR notation. It returns an empty string if the input IP or mask is invalid. For example, given "192.168.0.1" and "255.255.255.0", it returns "192.168.0.1/24".

func ToIpMask

func ToIpMask(cidr string) (string, string)

ToIpMask takes an IP address in CIDR notation (e.g., "192.168.100.2/24") and returns the IP address and its corresponding netmask string (e.g., "255.255.255.0").

Types

This section is empty.

Jump to

Keyboard shortcuts

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