comm

package
v0.0.0-...-95b87ed Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2019 License: Apache-2.0 Imports: 29 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MaxRecvMsgSize = 100 * 1024 * 1024
	MaxSendMsgSize = 100 * 1024 * 1024

	DefaultKeepaliveOptions = KeepaliveOptions{
		ClientInterval:    time.Duration(1) * time.Minute,
		ClientTimeout:     time.Duration(20) * time.Second,
		ServerInterval:    time.Duration(2) * time.Hour,
		ServerTimeout:     time.Duration(20) * time.Second,
		ServerMinInterval: time.Duration(1) * time.Minute,
	}

	DefaultTLSCipherSuites = []uint16{
		tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
		tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
		tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
		tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
		tls.TLS_RSA_WITH_AES_128_GCM_SHA256,
		tls.TLS_RSA_WITH_AES_256_GCM_SHA384,
	}

	DefaultConnectionTimeout = 5 * time.Second
)
View Source
var (
	ErrClientHandshakeNotImplemented = errors.New("core/comm: client handshakes are not implemented with serverCreds")
	ErrOverrideHostnameNotSupported  = errors.New("core/comm: OverrideServerName is not supported")
)

Functions

func AddPemToCertPool

func AddPemToCertPool(pemCerts []byte, pool *x509.CertPool) error

func ClientKeepaliveOptions

func ClientKeepaliveOptions(ka KeepaliveOptions) []grpc.DialOption

func ExtractCertificateFromContext

func ExtractCertificateFromContext(ctx context.Context) *x509.Certificate

func ExtractCertificateHashFromContext

func ExtractCertificateHashFromContext(ctx context.Context) []byte

func ExtractRawCertificateFromContext

func ExtractRawCertificateFromContext(ctx context.Context) []byte

func GetLocalIP

func GetLocalIP() (string, error)

func NewServerTransportCredentials

func NewServerTransportCredentials(
	serverConfig *tls.Config,
	logger *flogging.FabricLogger) credentials.TransportCredentials

func ServerKeepaliveOptions

func ServerKeepaliveOptions(ka KeepaliveOptions) []grpc.ServerOption

Types

type BindingInspector

type BindingInspector func(context.Context, proto.Message) error

func NewBindingInspector

func NewBindingInspector(mutualTLS bool, extractTLSCertHash CertHashExtractor) BindingInspector

type CertHashExtractor

type CertHashExtractor func(proto.Message) []byte

type ClientConfig

type ClientConfig struct {
	SecOpts SecureOptions

	KaOpts KeepaliveOptions

	Timeout time.Duration

	AsyncConnect bool
}

func (ClientConfig) Clone

func (cc ClientConfig) Clone() ClientConfig

type ConnectionFactory

type ConnectionFactory func(endpoint string, connectionTimeout time.Duration) (*grpc.ClientConn, error)

type ConnectionProducer

type ConnectionProducer interface {
	NewConnection() (*grpc.ClientConn, string, error)

	UpdateEndpoints(endpoints []string)

	GetEndpoints() []string
}

func NewConnectionProducer

func NewConnectionProducer(
	factory ConnectionFactory,
	endpoints []string,
	deliverClientDialOpts []grpc.DialOption,
	peerTLSEnabled bool,
	connectionTimeout time.Duration,
) ConnectionProducer

type CredentialSupport

type CredentialSupport struct {
	// contains filtered or unexported fields
}

func NewCredentialSupport

func NewCredentialSupport(rootCAs ...[]byte) *CredentialSupport

func (*CredentialSupport) AppRootCAsByChain

func (cs *CredentialSupport) AppRootCAsByChain() map[string][][]byte

func (*CredentialSupport) BuildTrustedRootsForChain

func (cs *CredentialSupport) BuildTrustedRootsForChain(cm channelconfig.Resources)

func (*CredentialSupport) GetClientCertificate

func (cs *CredentialSupport) GetClientCertificate() tls.Certificate

func (*CredentialSupport) GetDeliverServiceCredentials

func (cs *CredentialSupport) GetDeliverServiceCredentials(channelID string) (credentials.TransportCredentials, error)

func (*CredentialSupport) GetPeerCredentials

func (cs *CredentialSupport) GetPeerCredentials() credentials.TransportCredentials

func (*CredentialSupport) SetClientCertificate

func (cs *CredentialSupport) SetClientCertificate(cert tls.Certificate)

type EndpointCriteria

type EndpointCriteria struct {
	Endpoint      string
	Organizations []string
}

func (EndpointCriteria) Equals

func (ec EndpointCriteria) Equals(other EndpointCriteria) bool

type GRPCClient

type GRPCClient struct {
	// contains filtered or unexported fields
}

func NewGRPCClient

func NewGRPCClient(config ClientConfig) (*GRPCClient, error)

func (*GRPCClient) Certificate

func (client *GRPCClient) Certificate() tls.Certificate

func (*GRPCClient) MutualTLSRequired

func (client *GRPCClient) MutualTLSRequired() bool

func (*GRPCClient) NewConnection

func (client *GRPCClient) NewConnection(address string, tlsOptions ...TLSOption) (*grpc.ClientConn, error)

func (*GRPCClient) SetMaxRecvMsgSize

func (client *GRPCClient) SetMaxRecvMsgSize(size int)

func (*GRPCClient) SetMaxSendMsgSize

func (client *GRPCClient) SetMaxSendMsgSize(size int)

func (*GRPCClient) SetServerRootCAs

func (client *GRPCClient) SetServerRootCAs(serverRoots [][]byte) error

func (*GRPCClient) TLSEnabled

func (client *GRPCClient) TLSEnabled() bool

type GRPCServer

type GRPCServer struct {
	// contains filtered or unexported fields
}

func NewGRPCServer

func NewGRPCServer(address string, serverConfig ServerConfig) (*GRPCServer, error)

func NewGRPCServerFromListener

func NewGRPCServerFromListener(listener net.Listener, serverConfig ServerConfig) (*GRPCServer, error)

func (*GRPCServer) Address

func (gServer *GRPCServer) Address() string

func (*GRPCServer) AppendClientRootCAs

func (gServer *GRPCServer) AppendClientRootCAs(clientRoots [][]byte) error

func (*GRPCServer) Listener

func (gServer *GRPCServer) Listener() net.Listener

func (*GRPCServer) MutualTLSRequired

func (gServer *GRPCServer) MutualTLSRequired() bool

func (*GRPCServer) Server

func (gServer *GRPCServer) Server() *grpc.Server

func (*GRPCServer) ServerCertificate

func (gServer *GRPCServer) ServerCertificate() tls.Certificate

func (*GRPCServer) SetClientRootCAs

func (gServer *GRPCServer) SetClientRootCAs(clientRoots [][]byte) error

func (*GRPCServer) SetServerCertificate

func (gServer *GRPCServer) SetServerCertificate(cert tls.Certificate)

func (*GRPCServer) Start

func (gServer *GRPCServer) Start() error

func (*GRPCServer) Stop

func (gServer *GRPCServer) Stop()

func (*GRPCServer) TLSEnabled

func (gServer *GRPCServer) TLSEnabled() bool

type HealthCheckClient

type HealthCheckClient struct {
	Client  *GRPCClient
	Address string
	Service string
}

func NewHealthCheckClient

func NewHealthCheckClient(config ClientConfig, address, service string) (HealthCheckClient, error)

func (HealthCheckClient) HealthCheck

func (hcc HealthCheckClient) HealthCheck(ctx context.Context) error

type KeepaliveOptions

type KeepaliveOptions struct {
	ClientInterval time.Duration

	ClientTimeout time.Duration

	ServerInterval time.Duration

	ServerTimeout time.Duration

	ServerMinInterval time.Duration
}

type Metrics

type Metrics struct {
	OpenConnCounter metrics.Counter

	ClosedConnCounter metrics.Counter
}

type NewSemaphoreFunc

type NewSemaphoreFunc func(size int) Semaphore

type SecureOptions

type SecureOptions struct {
	VerifyCertificate func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error

	Certificate []byte

	Key []byte

	ServerRootCAs [][]byte

	ClientRootCAs [][]byte

	UseTLS bool

	RequireClientCert bool

	CipherSuites []uint16

	TimeShift time.Duration
}

type Semaphore

type Semaphore interface {
	Acquire(ctx context.Context) error
	Release()
}

type ServerConfig

type ServerConfig struct {
	ConnectionTimeout time.Duration

	SecOpts SecureOptions

	KaOpts KeepaliveOptions

	StreamInterceptors []grpc.StreamServerInterceptor

	UnaryInterceptors []grpc.UnaryServerInterceptor

	Logger *flogging.FabricLogger

	MetricsProvider metrics.Provider

	HealthCheckEnabled bool
}

type ServerStatsHandler

type ServerStatsHandler struct {
	OpenConnCounter   metrics.Counter
	ClosedConnCounter metrics.Counter
}

func NewServerStatsHandler

func NewServerStatsHandler(p metrics.Provider) *ServerStatsHandler

func (*ServerStatsHandler) HandleConn

func (h *ServerStatsHandler) HandleConn(ctx context.Context, s stats.ConnStats)

func (*ServerStatsHandler) HandleRPC

func (h *ServerStatsHandler) HandleRPC(ctx context.Context, s stats.RPCStats)

func (*ServerStatsHandler) TagConn

func (*ServerStatsHandler) TagRPC

type TLSOption

type TLSOption func(tlsConfig *tls.Config)

func ServerNameOverride

func ServerNameOverride(name string) TLSOption

type Throttle

type Throttle struct {
	// contains filtered or unexported fields
}

func NewThrottle

func NewThrottle(maxConcurrency int, options ...ThrottleOption) *Throttle

func (*Throttle) StreamServerInterceptor

func (t *Throttle) StreamServerInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error

func (*Throttle) UnaryServerIntercptor

func (t *Throttle) UnaryServerIntercptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

type ThrottleOption

type ThrottleOption func(t *Throttle)

func WithNewSemaphore

func WithNewSemaphore(newSemaphore NewSemaphoreFunc) ThrottleOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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