{"modulePath":"github.com/eric-erki/https-hyperledger.org","version":"v1.4.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package comm\n\n## Variables\n\n```go\nvar (\n\t// Max send and receive bytes for grpc clients and servers\n\tMaxRecvMsgSize = 100 * 1024 * 1024\n\tMaxSendMsgSize = 100 * 1024 * 1024\n\t// Default peer keepalive options\n\tDefaultKeepaliveOptions = \u0026KeepaliveOptions{\n\t\tClientInterval:    time.Duration(1) * time.Minute,\n\t\tClientTimeout:     time.Duration(20) * time.Second,\n\t\tServerInterval:    time.Duration(2) * time.Hour,\n\t\tServerTimeout:     time.Duration(20) * time.Second,\n\t\tServerMinInterval: time.Duration(1) * time.Minute,\n\t}\n\t// strong TLS cipher suites\n\tDefaultTLSCipherSuites = []uint16{\n\t\ttls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,\n\t\ttls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,\n\t\ttls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,\n\t\ttls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,\n\t\ttls.TLS_RSA_WITH_AES_128_GCM_SHA256,\n\t\ttls.TLS_RSA_WITH_AES_256_GCM_SHA384,\n\t}\n\t// default connection timeout\n\tDefaultConnectionTimeout = 5 * time.Second\n)\n```\nConfiguration defaults\n\n```go\nvar (\n\tClientHandshakeNotImplError = errors.New(\"core/comm: Client handshakes\" +\n\t\t\"are not implemented with serverCreds\")\n\tOverrrideHostnameNotSupportedError = errors.New(\n\t\t\"core/comm: OverrideServerName is \" +\n\t\t\t\"not supported\")\n\tMissingServerConfigError = errors.New(\n\t\t\"core/comm: `serverConfig` cannot be nil\")\n)\n```\n\n```go\nvar EndpointDisableInterval = time.Second * 10\n```\n\n## Functions\n\n```go\nfunc AddPemToCertPool(pemCerts []byte, pool *x509.CertPool) error\n```\nAddPemToCertPool adds PEM-encoded certs to a cert pool\n\n```go\nfunc ClientKeepaliveOptions(ka *KeepaliveOptions) []grpc.DialOption\n```\nClientKeepaliveOptions returns gRPC keepalive options for clients.  If opts is nil, the default keepalive options are returned\n\n```go\nfunc ExtractCertificateFromContext(ctx context.Context) *x509.Certificate\n```\nExtractCertificateFromContext returns the TLS certificate (if applicable) from the given context of a gRPC stream\n\n```go\nfunc ExtractCertificateHashFromContext(ctx context.Context) []byte\n```\nExtractCertificateHashFromContext extracts the hash of the certificate from the given context. If the certificate isn't present, nil is returned\n\n```go\nfunc ExtractRawCertificateFromContext(ctx context.Context) []byte\n```\nExtractRawCertificateFromContext returns the raw TLS certificate (if applicable) from the given context of a gRPC stream\n\n```go\nfunc InitTLSForShim(key, certStr string) credentials.TransportCredentials\n```\n\n```go\nfunc NewClientConnectionWithAddress(peerAddress string, block bool, tslEnabled bool,\n\tcreds credentials.TransportCredentials, ka *KeepaliveOptions) (*grpc.ClientConn, error)\n```\nNewClientConnectionWithAddress Returns a new grpc.ClientConn to the given address\n\n```go\nfunc NewServerTransportCredentials(\n\tserverConfig *tls.Config,\n\tlogger *flogging.FabricLogger) credentials.TransportCredentials\n```\nNewServerTransportCredentials returns a new initialized grpc/credentials.TransportCredentials\n\n```go\nfunc ServerKeepaliveOptions(ka *KeepaliveOptions) []grpc.ServerOption\n```\nServerKeepaliveOptions returns gRPC keepalive options for server.  If opts is nil, the default keepalive options are returned\n\n## Types\n\n```go\ntype BindingInspector func(context.Context, proto.Message) error\n```\nBindingInspector receives as parameters a gRPC context and an Envelope, and verifies whether the message contains an appropriate binding to the context\n\n```go\nfunc NewBindingInspector(mutualTLS bool, extractTLSCertHash CertHashExtractor) BindingInspector\n```\nNewBindingInspector returns a BindingInspector according to whether mutualTLS is configured or not, and according to a function that extracts TLS certificate hashes from proto messages\n\n```go\ntype CertHashExtractor func(proto.Message) []byte\n```\nCertHashExtractor extracts a certificate from a proto.Message message\n\n```go\ntype CertificateBundle [][]byte\n```\nCertificateBundle bundles certificates\n\n```go\ntype ClientConfig struct {\n\t// SecOpts defines the security parameters\n\tSecOpts *SecureOptions\n\t// KaOpts defines the keepalive parameters\n\tKaOpts *KeepaliveOptions\n\t// Timeout specifies how long the client will block when attempting to\n\t// establish a connection\n\tTimeout time.Duration\n\t// AsyncConnect makes connection creation non blocking\n\tAsyncConnect bool\n}\n```\nClientConfig defines the parameters for configuring a GRPCClient instance\n\n```go\nfunc (cc ClientConfig) Clone() ClientConfig\n```\nClone clones this ClientConfig\n\n```go\ntype ConnProducer struct {\n\tsync.RWMutex\n\t// contains filtered or unexported fields\n}\n```\nConnProducer produces connections\n\n```go\nfunc NewConnectionProducer(factory ConnectionFactory, endpoints []EndpointCriteria) *ConnProducer\n```\nNewConnectionProducer creates a new ConnectionProducer with given endpoints and connection factory. It returns nil, if the given endpoints slice is empty.\n\n```go\nfunc (cp *ConnProducer) GetEndpoints() []EndpointCriteria\n```\nGetEndpoints returns configured endpoint criteria for ordering service\n\n```go\nfunc (cp *ConnProducer) NewConnection() (*grpc.ClientConn, string, error)\n```\nNewConnection creates a new connection. Returns the connection, the endpoint selected, nil on success. Returns nil, \"\", error on failure\n\n```go\nfunc (cp *ConnProducer) UpdateEndpoints(endpoints []EndpointCriteria)\n```\nUpdateEndpoints updates the endpoints of the ConnectionProducer to be the given endpoints\n\n```go\ntype ConnectionFactory func(criteria EndpointCriteria) (*grpc.ClientConn, error)\n```\nConnectionFactory creates a connection to a certain endpoint\n\n```go\ntype ConnectionProducer interface {\n\t// NewConnection creates a new connection.\n\t// Returns the connection, the endpoint selected, nil on success.\n\t// Returns nil, \"\", error on failure\n\tNewConnection() (*grpc.ClientConn, string, error)\n\t// UpdateEndpoints updates the endpoint criteria of the ConnectionProducer\n\t// to be the given endpoints.\n\tUpdateEndpoints(endpoints []EndpointCriteria)\n\t// GetEndpoints return ordering service endpoint criteria.\n\tGetEndpoints() []EndpointCriteria\n}\n```\nConnectionProducer produces connections out of a set of predefined endpoints\n\n```go\ntype CredentialSupport struct {\n\tsync.RWMutex\n\tAppRootCAsByChain           map[string]CertificateBundle\n\tOrdererRootCAsByChainAndOrg OrgRootCAs\n\tClientRootCAs               CertificateBundle\n\tServerRootCAs               CertificateBundle\n\t// contains filtered or unexported fields\n}\n```\nCredentialSupport type manages credentials used for gRPC client connections\n\n```go\nfunc GetCredentialSupport() *CredentialSupport\n```\nGetCredentialSupport returns the singleton CredentialSupport instance\n\n```go\nfunc (cs *CredentialSupport) GetClientCertificate() tls.Certificate\n```\nGetClientCertificate returns the client certificate of the CredentialSupport\n\n```go\nfunc (cs *CredentialSupport) GetDeliverServiceCredentials(\n\tchannelID string,\n\tappendStaticRoots bool,\n\torgs []string,\n\tendpointOverrides map[string]*OrdererEndpoint,\n) (credentials.TransportCredentials, error)\n```\nGetDeliverServiceCredentials returns gRPC transport credentials for given channel to be used by gRPC clients which communicate with ordering service endpoints. If appendStaticRoots is set to true, ServerRootCAs are also included in the credentials.  If the channel isn't found, an error is returned.\n\n```go\nfunc (cs *CredentialSupport) GetPeerCredentials() credentials.TransportCredentials\n```\nGetPeerCredentials returns gRPC transport credentials for use by gRPC clients which communicate with remote peer endpoints.\n\n```go\nfunc (cs *CredentialSupport) SetClientCertificate(cert tls.Certificate)\n```\nSetClientCertificate sets the tls.Certificate to use for gRPC client connections\n\n```go\ntype EndpointCriteria struct {\n\tEndpoint      string\n\tOrganizations []string\n}\n```\nEndpointCriteria defines an endpoint, and a list of trusted organizations it corresponds to.\n\n```go\nfunc (ec EndpointCriteria) Equals(other EndpointCriteria) bool\n```\nEquals returns whether this EndpointCriteria is equivalent to the given other EndpointCriteria\n\n```go\ntype GRPCClient struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewGRPCClient(config ClientConfig) (*GRPCClient, error)\n```\nNewGRPCClient creates a new implementation of GRPCClient given an address and client configuration\n\n```go\nfunc (client *GRPCClient) Certificate() tls.Certificate\n```\nCertificate returns the tls.Certificate used to make TLS connections when client certificates are required by the server\n\n```go\nfunc (client *GRPCClient) MutualTLSRequired() bool\n```\nMutualTLSRequired is a flag indicating whether the client must send a certificate when making TLS connections\n\n```go\nfunc (client *GRPCClient) NewConnection(address string, serverNameOverride string) (\n\t*grpc.ClientConn, error)\n```\nNewConnection returns a grpc.ClientConn for the target address and overrides the server name used to verify the hostname on the certificate returned by a server when using TLS\n\n```go\nfunc (client *GRPCClient) SetMaxRecvMsgSize(size int)\n```\nSetMaxRecvMsgSize sets the maximum message size the client can receive\n\n```go\nfunc (client *GRPCClient) SetMaxSendMsgSize(size int)\n```\nSetMaxSendMsgSize sets the maximum message size the client can send\n\n```go\nfunc (client *GRPCClient) SetServerRootCAs(serverRoots [][]byte) error\n```\nSetServerRootCAs sets the list of authorities used to verify server certificates based on a list of PEM-encoded X509 certificate authorities\n\n```go\nfunc (client *GRPCClient) TLSEnabled() bool\n```\nTLSEnabled is a flag indicating whether to use TLS for client connections\n\n```go\ntype GRPCServer struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewGRPCServer(address string, serverConfig ServerConfig) (*GRPCServer, error)\n```\nNewGRPCServer creates a new implementation of a GRPCServer given a listen address\n\n```go\nfunc NewGRPCServerFromListener(listener net.Listener, serverConfig ServerConfig) (*GRPCServer, error)\n```\nNewGRPCServerFromListener creates a new implementation of a GRPCServer given an existing net.Listener instance using default keepalive\n\n```go\nfunc (gServer *GRPCServer) Address() string\n```\nAddress returns the listen address for this GRPCServer instance\n\n```go\nfunc (gServer *GRPCServer) AppendClientRootCAs(clientRoots [][]byte) error\n```\nAppendClientRootCAs appends PEM-encoded X509 certificate authorities to the list of authorities used to verify client certificates\n\n```go\nfunc (gServer *GRPCServer) Listener() net.Listener\n```\nListener returns the net.Listener for the GRPCServer instance\n\n```go\nfunc (gServer *GRPCServer) MutualTLSRequired() bool\n```\nMutualTLSRequired is a flag indicating whether or not client certificates are required for this GRPCServer instance\n\n```go\nfunc (gServer *GRPCServer) RemoveClientRootCAs(clientRoots [][]byte) error\n```\nRemoveClientRootCAs removes PEM-encoded X509 certificate authorities from the list of authorities used to verify client certificates\n\n```go\nfunc (gServer *GRPCServer) Server() *grpc.Server\n```\nServer returns the grpc.Server for the GRPCServer instance\n\n```go\nfunc (gServer *GRPCServer) ServerCertificate() tls.Certificate\n```\nServerCertificate returns the tls.Certificate used by the grpc.Server\n\n```go\nfunc (gServer *GRPCServer) SetClientRootCAs(clientRoots [][]byte) error\n```\nSetClientRootCAs sets the list of authorities used to verify client certificates based on a list of PEM-encoded X509 certificate authorities\n\n```go\nfunc (gServer *GRPCServer) SetServerCertificate(cert tls.Certificate)\n```\nSetServerCertificate assigns the current TLS certificate to be the peer's server certificate\n\n```go\nfunc (gServer *GRPCServer) Start() error\n```\nStart starts the underlying grpc.Server\n\n```go\nfunc (gServer *GRPCServer) Stop()\n```\nStop stops the underlying grpc.Server\n\n```go\nfunc (gServer *GRPCServer) TLSEnabled() bool\n```\nTLSEnabled is a flag indicating whether or not TLS is enabled for the GRPCServer instance\n\n```go\ntype KeepaliveOptions struct {\n\t// ClientInterval is the duration after which if the client does not see\n\t// any activity from the server it pings the server to see if it is alive\n\tClientInterval time.Duration\n\t// ClientTimeout is the duration the client waits for a response\n\t// from the server after sending a ping before closing the connection\n\tClientTimeout time.Duration\n\t// ServerInterval is the duration after which if the server does not see\n\t// any activity from the client it pings the client to see if it is alive\n\tServerInterval time.Duration\n\t// ServerTimeout is the duration the server waits for a response\n\t// from the client after sending a ping before closing the connection\n\tServerTimeout time.Duration\n\t// ServerMinInterval is the minimum permitted time between client pings.\n\t// If clients send pings more frequently, the server will disconnect them\n\tServerMinInterval time.Duration\n}\n```\nKeepaliveOptions is used to set the gRPC keepalive settings for both clients and servers\n\n```go\ntype Metrics struct {\n\t// OpenConnCounter keeps track of number of open connections\n\tOpenConnCounter metrics.Counter\n\t// ClosedConnCounter keeps track of number connections closed\n\tClosedConnCounter metrics.Counter\n}\n```\n\n```go\ntype NewSemaphoreFunc func(size int) Semaphore\n```\n\n```go\ntype OrdererEndpoint struct {\n\tAddress string\n\tPEMs    []byte\n}\n```\n\n```go\ntype OrgRootCAs map[string]PerOrgCertificateBundle\n```\nOrgRootCAs defines root CA certificates of organizations, by their corresponding channels. channel --\u003e organization --\u003e certificates\n\n```go\nfunc (orc OrgRootCAs) AppendCertificates(channel string, org string, rootCAs CertificateBundle)\n```\nAppendCertificates appends certificates that belong to the given organization in the context of the given channel. This operation isn't thread safe.\n\n```go\nfunc (orc OrgRootCAs) CertificatesByChannelAndOrg(channel string, org string) CertificateBundle\n```\nCertificatesByChannelAndOrg returns the certificates of the given organization in the context of the given channel.\n\n```go\ntype PerOrgCertificateBundle map[string]CertificateBundle\n```\nPerOrgCertificateBundle maps organizations to CertificateBundles\n\n```go\ntype SecureOptions struct {\n\t// VerifyCertificate, if not nil, is called after normal\n\t// certificate verification by either a TLS client or server.\n\t// If it returns a non-nil error, the handshake is aborted and that error results.\n\tVerifyCertificate func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error\n\t// PEM-encoded X509 public key to be used for TLS communication\n\tCertificate []byte\n\t// PEM-encoded private key to be used for TLS communication\n\tKey []byte\n\t// Set of PEM-encoded X509 certificate authorities used by clients to\n\t// verify server certificates\n\tServerRootCAs [][]byte\n\t// Set of PEM-encoded X509 certificate authorities used by servers to\n\t// verify client certificates\n\tClientRootCAs [][]byte\n\t// Whether or not to use TLS for communication\n\tUseTLS bool\n\t// Whether or not TLS client must present certificates for authentication\n\tRequireClientCert bool\n\t// CipherSuites is a list of supported cipher suites for TLS\n\tCipherSuites []uint16\n\t// TimeShift makes TLS handshakes time sampling shift to the past by a given duration\n\tTimeShift time.Duration\n}\n```\nSecureOptions defines the security parameters (e.g. TLS) for a GRPCServer or GRPCClient instance\n\n```go\ntype Semaphore interface {\n\tAcquire(ctx context.Context) error\n\tRelease()\n}\n```\n\n```go\ntype ServerConfig struct {\n\t// ConnectionTimeout specifies the timeout for connection establishment\n\t// for all new connections\n\tConnectionTimeout time.Duration\n\t// SecOpts defines the security parameters\n\tSecOpts *SecureOptions\n\t// KaOpts defines the keepalive parameters\n\tKaOpts *KeepaliveOptions\n\t// StreamInterceptors specifies a list of interceptors to apply to\n\t// streaming RPCs.  They are executed in order.\n\tStreamInterceptors []grpc.StreamServerInterceptor\n\t// UnaryInterceptors specifies a list of interceptors to apply to unary\n\t// RPCs.  They are executed in order.\n\tUnaryInterceptors []grpc.UnaryServerInterceptor\n\t// Logger specifies the logger the server will use\n\tLogger *flogging.FabricLogger\n\t// ServerStatsHandler should be set if metrics on connections are to be reported.\n\tServerStatsHandler *ServerStatsHandler\n}\n```\nServerConfig defines the parameters for configuring a GRPCServer instance\n\n```go\ntype ServerStatsHandler struct {\n\tOpenConnCounter   metrics.Counter\n\tClosedConnCounter metrics.Counter\n}\n```\n\n```go\nfunc NewServerStatsHandler(p metrics.Provider) *ServerStatsHandler\n```\n\n```go\nfunc (h *ServerStatsHandler) HandleConn(ctx context.Context, s stats.ConnStats)\n```\n\n```go\nfunc (h *ServerStatsHandler) HandleRPC(ctx context.Context, s stats.RPCStats)\n```\n\n```go\nfunc (h *ServerStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context\n```\n\n```go\nfunc (h *ServerStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context\n```\n\n```go\ntype Throttle struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewThrottle(maxConcurrency int, options ...ThrottleOption) *Throttle\n```\n\n```go\nfunc (t *Throttle) StreamServerInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error\n```\n\n```go\nfunc (t *Throttle) UnaryServerIntercptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)\n```\n\n```go\ntype ThrottleOption func(t *Throttle)\n```\n\n```go\nfunc WithNewSemaphore(newSemaphore NewSemaphoreFunc) ThrottleOption\n```\n\n","path":"github.com/eric-erki/https-hyperledger.org/core/comm","name":"comm","synopsis":"","isRedistributable":true}
