Documentation ¶
Index ¶
- func MarshalDuration(dur time.Duration, ignoreEmpty bool) string
- func MarshalPrivateKey(key crypto.PrivKey) (string, error)
- func MarshalPrivateKeyPEM(key crypto.PrivKey) ([]byte, error)
- func MarshalPublicKey(key crypto.PubKey) (string, error)
- func MarshalPublicKeyPEM(key crypto.PubKey) ([]byte, error)
- func MarshalTimestamp(ts *timestamppb.Timestamp) string
- func ParseDuration(dur string) (time.Duration, error)
- func ParsePeer(privKey string, pubKey string, peerId string) (peer.Peer, error)
- func ParsePeerID(peerID string) (peer.ID, error)
- func ParsePeerIDs(ids []string, allowEmpty bool) ([]peer.ID, error)
- func ParsePeerIDsUnique(ids []string, allowEmpty bool) ([]peer.ID, error)
- func ParsePrivateKey(privKeyStr string) (crypto.PrivKey, error)
- func ParsePrivateKeyPEM(privKeyDat []byte) (crypto.PrivKey, error)
- func ParseProtocolID(protocolID string, allowEmpty bool) (protocol.ID, error)
- func ParseProtocolIDs(ids []string, allowEmpty bool) ([]protocol.ID, error)
- func ParseProtocolIDsUnique(ids []string, allowEmpty bool) ([]protocol.ID, error)
- func ParsePublicKey(pubKeyStr string) (crypto.PubKey, error)
- func ParsePublicKeyPEM(pubKeyDat []byte) (crypto.PubKey, error)
- func ParseRegexp(re string) (*regexp.Regexp, error)
- func ParseTimestamp(timestampStr string) (*timestamppb.Timestamp, error)
- func ParseURL(uri string) (*url.URL, error)
- func ParseURLs(urlStrs []string, allowEmpty bool) ([]*url.URL, error)
- func ValidatePeerID(id string) error
- func ValidateProtocolID(id string, allowEmpty bool) error
- func ValidatePubKey(id string, peerID peer.ID) error
- func ValidateURL(uri string, allowEmpty bool) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalDuration ¶
MarshalDuration marshals a duration to a string.
func MarshalPrivateKey ¶
MarshalPrivateKey marshals the private key in b58 format.
func MarshalPrivateKeyPEM ¶
MarshalPrivateKeyPEM marshals the private key in pem format.
func MarshalPublicKey ¶
MarshalPublicKey marshals the public key in b58 format.
func MarshalPublicKeyPEM ¶
MarshalPublicKeyPEM marshals the public key in pem format.
func MarshalTimestamp ¶ added in v0.14.5
func MarshalTimestamp(ts *timestamppb.Timestamp) string
MarshalTimestamp marshals a timestamp to a RFC3339 string. This format is also supported by proto3.
func ParseDuration ¶
ParseDuration parses a duration or returns 0, nil if empty.
func ParsePeerID ¶
ParsePeerID parses the peer ID if it is not empty.
func ParsePeerIDs ¶
ParsePeerIDs parses a list of peer IDs.
func ParsePeerIDsUnique ¶ added in v0.1.1
ParsePeerIDsUnique parses a list of peer IDs and dedupes.
func ParsePrivateKey ¶
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 ¶
ParsePrivateKeyPEM parses the private key from a configuration. If there is no private key specified, returns nil, nil.
func ParseProtocolID ¶ added in v0.20.2
ParseProtocolID parses the peer ID if it is not empty.
func ParseProtocolIDs ¶ added in v0.20.2
ParseProtocolIDs parses a list of peer IDs.
func ParseProtocolIDsUnique ¶ added in v0.20.2
ParseProtocolIDsUnique parses a list of peer IDs and dedupes.
func ParsePublicKey ¶
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 ¶
ParsePublicKeyPEM parses the public key from a configuration. If there is no public key specified, returns nil, nil.
func ParseRegexp ¶ added in v0.7.6
ParseRegexp parses a regular expression. If the field is empty, returns nil, nil.
func ParseTimestamp ¶ added in v0.14.5
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 ¶ added in v0.14.2
ParseURL parses the url from a string. If there is no URL specified, returns nil, nil.
func ValidatePeerID ¶ added in v0.1.1
ValidatePeerID checks if a peer ID is valid and set.
func ValidateProtocolID ¶ added in v0.20.2
ValidateProtocolID checks if a peer ID is valid.
func ValidatePubKey ¶ added in v0.1.1
ValidatePubKey checks if a public key is set and valid.
if the peer id is given, checks if it matches
func ValidateURL ¶ added in v0.14.2
ValidateURL checks if a URL is set and valid.
Types ¶
This section is empty.