common

package
v0.2403.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: Apache-2.0 Imports: 17 Imported by: 49

Documentation

Index

Constants

View Source
const (
	// NamespaceSize is the size of a chain namespace identifier in bytes.
	NamespaceSize = 32

	// NamespaceHexSize is the size of the chain namespace identifier in string format.
	NamespaceHexSize = NamespaceSize * 2

	// NamespaceIDSize is the size of the identifier component of a namespace.
	NamespaceIDSize = NamespaceSize - 8

	NamespaceTest       NamespaceFlag = 1 << 63
	NamespaceKeyManager NamespaceFlag = 1 << 62
)

Variables

View Source
var (
	// ErrMalformedNamespace is the error returned when a namespace
	// identifier is malformed.
	ErrMalformedNamespace = errors.New("malformed namespace")
)

Functions

func AtMostOneTrue added in v0.2402.0

func AtMostOneTrue(conds ...bool) bool

AtMostOneTrue returns true iff at most one of the passed conditions is true.

func CopyDir added in v0.2201.9

func CopyDir(src string, dst string) (err error)

CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist. Symlinks are ignored and skipped.

func CopyFile added in v0.2201.9

func CopyFile(src, dst string) (err error)

CopyFile copies the contents of the file named src to the file named by dst. The file will be created if it does not already exist. If the destination file exists, all it's contents will be replaced by the contents of the source file. The file mode will be copied from the source and the copied data is synced/flushed to stable storage. Taken from: https://github.com/hasura/graphql-engine/blob/6532a658eb3dfae9dde251c6c9377f2268ecc8a8/cli/util/copy.go#L13-L115

func ExactlyOneTrue added in v0.2202.0

func ExactlyOneTrue(conds ...bool) bool

ExactlyOneTrue returns true iff exactly one of the passed conditions is true.

func FindAllAddresses

func FindAllAddresses() ([]net.IP, error)

FindAllAddresses returns all addresses found by examining all up interfaces (skipping loopback).

func GetHostPort

func GetHostPort(rawURL string) (string, error)

GetHostPort makes a normalized "host:port" string from the given raw URL.

func GuessExternalAddress

func GuessExternalAddress() net.IP

GuessExternalAddress returns a best guess of the external address, or nil if the process fails.

func IsAddrPort

func IsAddrPort(s string) error

IsAddrPort validates that the provided string is an address + port.

func IsFQDN

func IsFQDN(s string) error

IsFQDN validates that the provided string is a well-formed FQDN.

func IsProbablyGloballyReachable added in v0.2103.0

func IsProbablyGloballyReachable(ip net.IP) bool

IsProbablyGloballyReachable returns true if the provided IP address is likely to be globally reachable.

func Mkdir

func Mkdir(d string) error

Mkdir creates a directory iff it does not exist, and otherwise ensures that the filesystem permissions are sufficiently restrictive.

func NormalizeFQDN

func NormalizeFQDN(s string) string

NormalizeFQDN normalizes the provided string as a FQDN.

func TrimArgs

func TrimArgs(osArgs []string) []string

TrimArgs removes all arguments in the argument list occurring before the "--" separator. The first argument is treated as the binary name (as in os.Args) and is left unchanged.

If the argument list does not include the separator, a slice containing only the first argument is returned.

It is an error to call this function with an empty slice.

Types

type Namespace

type Namespace [NamespaceSize]byte

Namespace is a chain namespace identifier.

func NewNamespace

func NewNamespace(id [NamespaceIDSize]byte, flags NamespaceFlag) (Namespace, error)

NewNamespace returns a new namespace from it's component ID and flags.

func NewTestNamespaceFromSeed

func NewTestNamespaceFromSeed(seed []byte, flags NamespaceFlag) Namespace

NewTestNamespaceFromSeed returns a test namespace from a seed and flags.

func (Namespace) Base64 added in v0.2103.1

func (n Namespace) Base64() string

Base64 returns the base64 string representation of a namespace identifier.

func (*Namespace) Equal

func (n *Namespace) Equal(cmp *Namespace) bool

Equal compares vs another namespace for equality.

func (Namespace) Hash added in v0.2300.0

func (n Namespace) Hash() hash.Hash

Hash returns a cryptographic hash of a namespace identifier.

func (Namespace) Hex added in v0.2103.1

func (n Namespace) Hex() string

Hex returns the hexadecimal string representation of a namespace identifier.

func (Namespace) IsKeyManager

func (n Namespace) IsKeyManager() bool

IsKeyManager returns true iff the namespace is for a key manager runtime.

func (Namespace) IsTest

func (n Namespace) IsTest() bool

IsTest returns true iff the namespace is for a test runtime.

func (*Namespace) MarshalBinary

func (n *Namespace) MarshalBinary() (data []byte, err error)

MarshalBinary encodes a namespace identifier into binary form.

func (*Namespace) MarshalHex added in v0.2103.0

func (n *Namespace) MarshalHex() ([]byte, error)

MarshalHex encodes a namespace identifier into a hexadecimal form.

func (Namespace) MarshalText

func (n Namespace) MarshalText() ([]byte, error)

MarshalText encodes a namespace identifier into text form.

func (Namespace) String

func (n Namespace) String() string

String returns the string representation of a namespace identifier.

func (*Namespace) UnmarshalBase64 added in v0.2200.0

func (n *Namespace) UnmarshalBase64(text []byte) error

UnmarshalBase64 deserializes a Base64 text string into the given type.

func (*Namespace) UnmarshalBinary

func (n *Namespace) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes a binary marshaled namespace identifier.

func (*Namespace) UnmarshalHex

func (n *Namespace) UnmarshalHex(text string) error

UnmarshalHex deserializes a hexadecimal text string into the given type.

func (*Namespace) UnmarshalText

func (n *Namespace) UnmarshalText(text []byte) error

UnmarshalText decodes a text marshaled namespace identifier.

type NamespaceFlag

type NamespaceFlag uint64

NamespaceFlag is a namespace flag.

Directories

Path Synopsis
Package accessctl implements access control for an Oasis node.
Package accessctl implements access control for an Oasis node.
Package backoff contains helpers for dealing with backoffs.
Package backoff contains helpers for dealing with backoffs.
Package badger contains convenience helpers for integrating BadgerDB.
Package badger contains convenience helpers for integrating BadgerDB.
cache
lru
Package lru implements an in-memory Least-Recently-Used cache.
Package lru implements an in-memory Least-Recently-Used cache.
Package cbor provides helpers for encoding and decoding canonical CBOR.
Package cbor provides helpers for encoding and decoding canonical CBOR.
Package crash provides a framework for adding probabilistic crash points.
Package crash provides a framework for adding probabilistic crash points.
crypto
address
Package address implements a generic cryptographic address with versioning and context separation.
Package address implements a generic cryptographic address with versioning and context separation.
drbg
Package drbg implements the HMAC_DRBG construct as per NIST Special Publication 800-90A Revision 1.
Package drbg implements the HMAC_DRBG construct as per NIST Special Publication 800-90A Revision 1.
hash
Package hash implements a cryptographic hash over arbitrary binary data.
Package hash implements a cryptographic hash over arbitrary binary data.
mathrand
Package mathrand implements an adapter from a cryptographically secure entropy source that implements an io.Reader to a math/rand.Source64.
Package mathrand implements an adapter from a cryptographically secure entropy source that implements an io.Reader to a math/rand.Source64.
mrae/api
Package api implements the MRAE API and common helpers.
Package api implements the MRAE API and common helpers.
mrae/deoxysii
Package deoxysii implements the Deoxys-II-256-128 based MRAE boxes.
Package deoxysii implements the Deoxys-II-256-128 based MRAE boxes.
sakg
Package sakg implements ADR 0008: Standard Account Key Generation.
Package sakg implements ADR 0008: Standard Account Key Generation.
signature
Package signature provides wrapper types around public key signatures.
Package signature provides wrapper types around public key signatures.
signature/signers/composite
Package composite provides a composite signer.
Package composite provides a composite signer.
signature/signers/file
Package file provides a PEM file backed signer.
Package file provides a PEM file backed signer.
signature/signers/memory
Package memory provides a memory backed Signer, primarily for use in testing.
Package memory provides a memory backed Signer, primarily for use in testing.
signature/signers/plugin
Package plugin implements the Go plugin signature signer.
Package plugin implements the Go plugin signature signer.
signature/signers/remote
Package remote provides a gRPC backed signer (both client and server).
Package remote provides a gRPC backed signer (both client and server).
slip10
Package slip10 implements the SLIP-0010 private key derivation scheme for Ed25519.
Package slip10 implements the SLIP-0010 private key derivation scheme for Ed25519.
tls
Package tls implements helpful wrappers for dealing with TLS certificates.
Package tls implements helpful wrappers for dealing with TLS certificates.
tuplehash
Package tuplehash implements TupleHash from NIST SP 800-15.
Package tuplehash implements TupleHash from NIST SP 800-15.
Package ctxsync contains some synchronization primitvies that are aware of a context becoming done and can bail on waits in that case.
Package ctxsync contains some synchronization primitvies that are aware of a context becoming done and can bail on waits in that case.
Package diff implements helpers for comparing objects.
Package diff implements helpers for comparing objects.
Package dynlib provides routines for interacting with the glibc ld.so dynamic linker/loader.
Package dynlib provides routines for interacting with the glibc ld.so dynamic linker/loader.
encoding
bech32
Package bech32 provides implementation of Bech32 encoding specified in BIP 173: https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki.
Package bech32 provides implementation of Bech32 encoding specified in BIP 173: https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki.
Package entity implements common entity routines.
Package entity implements common entity routines.
Package errors implements errors that can be easily sent across the wire and reconstructed at the other end.
Package errors implements errors that can be easily sent across the wire and reconstructed at the other end.
Package grpc implements common gRPC related services and utilities.
Package grpc implements common gRPC related services and utilities.
auth
Package auth implements gRPC authentication server interceptors.
Package auth implements gRPC authentication server interceptors.
testing
Package testing implements common grpc testing helpers.
Package testing implements common grpc testing helpers.
Package identity encapsulates the node identity.
Package identity encapsulates the node identity.
Package logging implements support for structured logging.
Package logging implements support for structured logging.
Package node implements common node identity routines.
Package node implements common node identity routines.
Package pem provides handy wrappers for dealing with PEM files.
Package pem provides handy wrappers for dealing with PEM files.
Package persistent provides a wrapper around a key-value database for use as general node-wide storage.
Package persistent provides a wrapper around a key-value database for use as general node-wide storage.
Package pubsub implements a generic publish-subscribe interface.
Package pubsub implements a generic publish-subscribe interface.
Package random provides a concurrency safe https://golang.org/pkg/math/rand/#Rand object.
Package random provides a concurrency safe https://golang.org/pkg/math/rand/#Rand object.
Package scheduling provides tools for scheduling tasks.
Package scheduling provides tools for scheduling tasks.
Package service provides service primitives.
Package service provides service primitives.
sgx
Package sgx provides common Intel SGX datatypes and utilities.
Package sgx provides common Intel SGX datatypes and utilities.
aesm
Package aesm provides a client for AESMD.
Package aesm provides a client for AESMD.
ias
Package ias provides routines for interacting with the Intel Attestation Service.
Package ias provides routines for interacting with the Intel Attestation Service.
pcs
Package sync provides sync primitives.
Package sync provides sync primitives.
Package syscall defines OS-specific syscall parameters.
Package syscall defines OS-specific syscall parameters.
Package version implements Oasis protocol and runtime versioning.
Package version implements Oasis protocol and runtime versioning.
Package workerpool implements a simple goroutine-based workerpool with a configurable number of workers.
Package workerpool implements a simple goroutine-based workerpool with a configurable number of workers.

Jump to

Keyboard shortcuts

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