util

package
v0.0.0-...-1e6caf6 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RED    = "\x1b[31m"
	GREEN  = "\x1b[32m"
	YELLOW = "\x1b[33m"
	BLUE   = "\x1b[34m"
	RESET  = "\x1b[0m"
)

Terminal colors. Use by adding the color to the beginning of a string. add RESET after the string to reset the color: otherwise all text will remain this color in future prints.

Variables

This section is empty.

Functions

func BitsToBytes

func BitsToBytes(ba bitarray.BitArray) []byte

func BytesToBits

func BytesToBits(bytes []byte) bitarray.BitArray

func CompressData

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

func CreateDir

func CreateDir(path string)

func CreateFile

func CreateFile(path string)

func DecompressData

func DecompressData(compressedData []byte) ([]byte, error)

func DeleteFilesAndDirectories

func DeleteFilesAndDirectories(path string) error

func GetCurrentMinute

func GetCurrentMinute() string

func GetCurrentPeriod

func GetCurrentPeriod() string

set it to be the same as GetCurrentMinute() for now

func GetCurrentSecond

func GetCurrentSecond() string

func GetCurrentTimestamp

func GetCurrentTimestamp() string

func GetRandomLatency

func GetRandomLatency(min int, max int) int

func GetSenderURL

func GetSenderURL(r *http.Request) string

func Getwaitingtime

func Getwaitingtime(MMD int) int

This needs to be changed with GetCurrentPeriod()

func IsOwner

func IsOwner(ownerURL string, parsedURL string) bool

Rules: If localhost, call it true. Otherwise compare the pre-port part of the url to see if they match.

func LoadConfiguration

func LoadConfiguration(config interface{}, file string)

func PEM2PK

func PEM2PK(s string) crypto.PublicKey

func PEM2PrivKey

func PEM2PrivKey(s string) crypto.PrivateKey

func ParseTBSCertificate

func ParseTBSCertificate(cert *x509.Certificate) *x509.Certificate

func ReadByte

func ReadByte(filename string) ([]byte, error)

func ReadCertificateFromDisk

func ReadCertificateFromDisk(filePath string) ([]byte, error)

func ReadKeyFromDisk

func ReadKeyFromDisk(filePath string) (*rsa.PrivateKey, error)

func SaveCertificateToDisk

func SaveCertificateToDisk(certBytes []byte, filePath string)

func SaveKeyToDisk

func SaveKeyToDisk(privKey *rsa.PrivateKey, filePath string)

func WriteData

func WriteData(filename string, data interface{}) error

Writes arbitrary data as a JSON File. If the file does not exist, it will be created.

Types

type OutOfBounds

type OutOfBounds struct{}

func (*OutOfBounds) Error

func (e *OutOfBounds) Error() string

Jump to

Keyboard shortcuts

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