Documentation ¶
Index ¶
- func CheckClosedConnectionWithErr(conn network.Connection, err error) bool
- func ContainsDNS(addr ma.Multiaddr) bool
- func ConvertProtocolIDsToStrArr(protocols ...protocol.ID) []string
- func ConvertStrArrToProtocolIDs(strArr ...string) []protocol.ID
- func EasyToUsePIDLoader(certs []*x509.Certificate) (peer.ID, error)
- func EasyToUseTLSConfig(sk cc.PriKey, certTemplate *x509.Certificate) (*tls.Config, error)
- func ExcludeUnspecifiedAndLoopBack(addresses []ma.Multiaddr) []ma.Multiaddr
- func GenerateSignedExtension(sk cc.PriKey, pubKey crypto.PublicKey) (pkix.Extension, error)
- func IsConnClosedError(err error) bool
- func IsNetErrorTimeout(err error) bool
- func NetError(err error) (net.Error, bool)
- func PIDAndNetAddrToMultiAddr(pid peer.ID, netAddr ma.Multiaddr) ma.Multiaddr
- func PIDToMultiAddr(pid peer.ID) ma.Multiaddr
- func PubKeyFromCertChain(chain []*x509.Certificate) (cc.PubKey, error)
- func ReadPackageData(stream network.ReceiveStream, length uint64) ([]byte, error)
- func ReadPackageLength(stream network.ReceiveStream) (uint64, []byte, error)
- func SplitAddrToTransportAndPID(addr ma.Multiaddr) (ma.Multiaddr, peer.ID)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckClosedConnectionWithErr ¶
func CheckClosedConnectionWithErr(conn network.Connection, err error) bool
CheckClosedConnectionWithErr checks if the network connection is closed based on the provided error. It returns true if the error indicates a timeout, a closed connection error, or if the connection itself is closed. Otherwise, it returns false.
func ContainsDNS ¶
ContainsDNS returns true if the given address contains the DNS protocol, otherwise returns false
func ConvertProtocolIDsToStrArr ¶
ConvertProtocolIDsToStrArr converts an array of protocol.IDs to an array of strings.
func ConvertStrArrToProtocolIDs ¶
ConvertStrArrToProtocolIDs converts an array of strings to an array of protocol.IDs.
func EasyToUsePIDLoader ¶
func EasyToUsePIDLoader(certs []*x509.Certificate) (peer.ID, error)
EasyToUsePIDLoader generates a peer ID based on the provided certificate chain. It extracts the public key from the certificate chain using PubKeyFromCertChain(), and then uses the extracted public key to generate a peer ID using peer.IDFromPubKey(). It returns the generated peer ID.
func EasyToUseTLSConfig ¶
EasyToUseTLSConfig generates a TLS configuration based on the provided private key and certificate template. If the certificate template is nil, it generates a new one using tlsCertTemplate(). It returns a *tls.Config that can be used to configure TLS settings for a server or client.
func ExcludeUnspecifiedAndLoopBack ¶
ExcludeUnspecifiedAndLoopBack filters out unspecified and loopback addresses from the given list.
func GenerateSignedExtension ¶
GenerateSignedExtension uses the provided private key to sign the public key, and returns the signature within a pkix.Extension. This extension is included in a certificate to cryptographically tie it to the rainbow-bee private key.
func IsConnClosedError ¶
IsConnClosedError checks if the provided error corresponds to a closed connection error. It checks if the error string contains specific substrings that commonly indicate a closed connection. It returns true if the error represents a closed connection, and false otherwise.
func IsNetErrorTimeout ¶
IsNetErrorTimeout checks if the provided error is a network error and specifically a timeout error. It uses the NetError function to obtain the net.Error value and checks if the error's Timeout() method returns true. It returns true if the error represents a network timeout, and false otherwise.
func NetError ¶
NetError checks if the provided error implements the net.Error interface. It returns the net.Error value and true if the error implements the interface. Otherwise, it returns nil and false.
func PIDAndNetAddrToMultiAddr ¶
PIDAndNetAddrToMultiAddr joins the peer.ID's p2p multiaddress with the given network address. For example, "QmcQHCuAXaFkbcsPUj7e37hXXfZ9DdN7bozseo5oX4qiC4" and "/ip4/127.0.0.1/tcp/8080" become "/ip4/127.0.0.1/tcp/8080/p2p/QmcQHCuAXaFkbcsPUj7e37hXXfZ9DdN7bozseo5oX4qiC4".
func PIDToMultiAddr ¶
PIDToMultiAddr converts a peer.ID to a p2p multiaddress. For example, "QmcQHCuAXaFkbcsPUj7e37hXXfZ9DdN7bozseo5oX4qiC4" becomes "/p2p/QmcQHCuAXaFkbcsPUj7e37hXXfZ9DdN7bozseo5oX4qiC4".
func PubKeyFromCertChain ¶
func PubKeyFromCertChain(chain []*x509.Certificate) (cc.PubKey, error)
PubKeyFromCertChain verifies the certificate chain and extract the remote's public key.
func ReadPackageData ¶
func ReadPackageData(stream network.ReceiveStream, length uint64) ([]byte, error)
ReadPackageData reads the specified length of data from the receive stream. It reads the data in batches of defaultBatchSize (4KB) to optimize performance. Returns the read data and any error encountered.
func ReadPackageLength ¶
func ReadPackageLength(stream network.ReceiveStream) (uint64, []byte, error)
ReadPackageLength reads the package length from the receive stream. It expects the length to be encoded as 8 bytes in big-endian format. Returns the package length, the length bytes, and any error encountered.
func SplitAddrToTransportAndPID ¶
SplitAddrToTransportAndPID resolves a network address and peer.ID from the given multiaddress. For example, if the multiaddress is "/ip4/127.0.0.1/tcp/8080/p2p/QmcQHCuAXaFkbcsPUj7e37hXXfZ9DdN7bozseo5oX4qiC4", it returns "/ip4/127.0.0.1/tcp/8080" as the network address and "QmcQHCuAXaFkbcsPUj7e37hXXfZ9DdN7bozseo5oX4qiC4" as the peer.ID. If the multiaddress is "/ip4/127.0.0.1/tcp/8080", it returns "/ip4/127.0.0.1/tcp/8080" as the network address and an empty string as the peer.ID.
Types ¶
This section is empty.