confparse

package
v0.51.2 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalDuration

func MarshalDuration(dur time.Duration, ignoreEmpty bool) string

MarshalDuration marshals a duration to a string.

func MarshalPrivateKey

func MarshalPrivateKey(key crypto.PrivKey) (string, error)

MarshalPrivateKey marshals the private key in b58 format.

func MarshalPrivateKeyPEM

func MarshalPrivateKeyPEM(key crypto.PrivKey) ([]byte, error)

MarshalPrivateKeyPEM marshals the private key in pem format.

func MarshalPublicKey

func MarshalPublicKey(key crypto.PubKey) (string, error)

MarshalPublicKey marshals the public key in b58 format.

func MarshalPublicKeyPEM

func MarshalPublicKeyPEM(key crypto.PubKey) ([]byte, error)

MarshalPublicKeyPEM marshals the public key in pem format.

func MarshalTimestamp

func MarshalTimestamp(ts *timestamppb.Timestamp) string

MarshalTimestamp marshals a timestamp to a RFC3339 string. This format is also supported by proto3.

func ParseDuration

func ParseDuration(dur string) (time.Duration, error)

ParseDuration parses a duration or returns 0, nil if empty.

func ParsePeer

func ParsePeer(

	privKey string,

	pubKey string,

	peerId string,
) (peer.Peer, error)

ParsePeer parses one of privKey, pubKey, peerID to build a Peer.

func ParsePeerID

func ParsePeerID(peerID string) (peer.ID, error)

ParsePeerID parses the peer ID if it is not empty.

func ParsePeerIDs

func ParsePeerIDs(ids []string, allowEmpty bool) ([]peer.ID, error)

ParsePeerIDs parses a list of peer IDs.

func ParsePeerIDsUnique

func ParsePeerIDsUnique(ids []string, allowEmpty bool) ([]peer.ID, error)

ParsePeerIDsUnique parses a list of peer IDs and dedupes.

func ParsePrivateKey

func ParsePrivateKey(privKeyStr string) (crypto.PrivKey, error)

ParsePrivateKey parses the private key from a string. If the string starts with "-----BEGIN" assumes it is PEM. Otherwise: the string is a b58 encoded libp2p public key. If there is no public key specified, returns nil, nil.

func ParsePrivateKeyPEM

func ParsePrivateKeyPEM(privKeyDat []byte) (crypto.PrivKey, error)

ParsePrivateKeyPEM parses the private key from a configuration. If there is no private key specified, returns nil, nil.

func ParseProtocolID

func ParseProtocolID(protocolID string, allowEmpty bool) (protocol.ID, error)

ParseProtocolID parses the peer ID if it is not empty.

func ParseProtocolIDs

func ParseProtocolIDs(ids []string, allowEmpty bool) ([]protocol.ID, error)

ParseProtocolIDs parses a list of peer IDs.

func ParseProtocolIDsUnique

func ParseProtocolIDsUnique(ids []string, allowEmpty bool) ([]protocol.ID, error)

ParseProtocolIDsUnique parses a list of peer IDs and dedupes.

func ParsePublicKey

func ParsePublicKey(pubKeyStr string) (crypto.PubKey, error)

ParsePublicKey parses the public key from a string. If the string starts with "-----BEGIN" assumes it is PEM. Otherwise: the string is a b58 encoded libp2p public key. If there is no public key specified, returns nil, nil.

func ParsePublicKeyPEM

func ParsePublicKeyPEM(pubKeyDat []byte) (crypto.PubKey, error)

ParsePublicKeyPEM parses the public key from a configuration. If there is no public key specified, returns nil, nil.

func ParseRegexp

func ParseRegexp(re string) (*regexp.Regexp, error)

ParseRegexp parses a regular expression. If the field is empty, returns nil, nil.

func ParseTimestamp

func ParseTimestamp(timestampStr string) (*timestamppb.Timestamp, error)

ParseTimestamp parses a timestamp string.

The string can be either a unix time milliseconds or RFC3339 timestamp. Returns nil, nil if empty.

func ParseURL

func ParseURL(uri string) (*url.URL, error)

ParseURL parses the url from a string. If there is no URL specified, returns nil, nil.

func ParseURLs

func ParseURLs(urlStrs []string, allowEmpty bool) ([]*url.URL, error)

ParseURLs parses a list of urls.

Removes any empty values.

func ValidatePeerID

func ValidatePeerID(id string) error

ValidatePeerID checks if a peer ID is valid and set.

func ValidateProtocolID

func ValidateProtocolID(id string, allowEmpty bool) error

ValidateProtocolID checks if a peer ID is valid.

func ValidatePubKey

func ValidatePubKey(id string, peerID peer.ID) error

ValidatePubKey checks if a public key is set and valid.

if the peer id is given, checks if it matches

func ValidateURL

func ValidateURL(uri string, allowEmpty bool) error

ValidateURL checks if a URL is set and valid.

Types

This section is empty.

Jump to

Keyboard shortcuts

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