comm

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2020 License: GPL-3.0, GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientKeepaliveOptions

func ClientKeepaliveOptions(ka *KeepaliveOptions) []grpc.DialOption

ClientKeepaliveOptions returns gRPC keepalive options for clients. If opts is nil, the default keepalive options are returned

func GetCcDagHand

func GetCcDagHand() (dag.IDag, error)

func GetInternalIp added in v1.0.4

func GetInternalIp() string

func InitTLSForShim

func InitTLSForShim(key, certStr string) credentials.TransportCredentials

func MaxRecvMsgSize

func MaxRecvMsgSize() int

MaxRecvMsgSize returns the maximum message size in bytes that gRPC clients and servers can receive

func MaxSendMsgSize

func MaxSendMsgSize() int

MaxSendMsgSize returns the maximum message size in bytes that gRPC clients and servers can send

func NewClientConnectionWithAddress

func NewClientConnectionWithAddress(peerAddress string, block bool, tslEnabled bool,
	creds credentials.TransportCredentials, ka *KeepaliveOptions) (*grpc.ClientConn, error)

NewClientConnectionWithAddress Returns a new grpc.ClientConn to the given address

func ServerKeepaliveOptions

func ServerKeepaliveOptions(ka *KeepaliveOptions) []grpc.ServerOption

ServerKeepaliveOptions returns gRPC keepalive options for server. If opts is nil, the default keepalive options are returned

func SetCcDagHand

func SetCcDagHand(dag dag.IDag) error

func SetMaxRecvMsgSize

func SetMaxRecvMsgSize(size int)

SetMaxRecvMsgSize sets the maximum message size in bytes that gRPC clients and servers can receive

func SetMaxSendMsgSize

func SetMaxSendMsgSize(size int)

SetMaxSendMsgSize sets the maximum message size in bytes that gRPC clients and servers can send

func TLSEnabled

func TLSEnabled() bool

TLSEnabled return cached value for "peer.tls.enabled" configuration value

Types

type CASupport

type CASupport struct {
	sync.RWMutex
	AppRootCAsByChain     map[string][][]byte
	OrdererRootCAsByChain map[string][][]byte
	ClientRootCAs         [][]byte
	ServerRootCAs         [][]byte
}

CASupport type manages certificate authorities scoped by channel

func (*CASupport) GetClientRootCAs

func (cas *CASupport) GetClientRootCAs() (appRootCAs, ordererRootCAs [][]byte)

GetClientRootCAs returns the PEM-encoded root certificates for all of the application and orderer organizations defined for all chains. The root certificates returned should be used to set the trusted client roots for TLS servers.

func (*CASupport) GetServerRootCAs

func (cas *CASupport) GetServerRootCAs() (appRootCAs, ordererRootCAs [][]byte)

GetServerRootCAs returns the PEM-encoded root certificates for all of the application and orderer organizations defined for all chains. The root certificates returned should be used to set the trusted server roots for TLS clients.

type ClientConfig

type ClientConfig struct {
	// SecOpts defines the security parameters
	SecOpts *SecureOptions
	// KaOpts defines the keepalive parameters
	KaOpts *KeepaliveOptions
	// Timeout specifies how long the client will block when attempting to
	// establish a connection
	Timeout time.Duration
}

ClientConfig defines the parameters for configuring a GRPCClient instance

type CredentialSupport

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

CredentialSupport type manages credentials used for gRPC client connections

func GetCredentialSupport

func GetCredentialSupport() *CredentialSupport

GetCredentialSupport returns the singleton CredentialSupport instance

func (*CredentialSupport) GetClientCertificate

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

GetClientCertificate returns the client certificate of the CredentialSupport

func (*CredentialSupport) GetDeliverServiceCredentials

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

GetDeliverServiceCredentials returns GRPC transport credentials for given channel to be used by GRPC clients which communicate with ordering service endpoints. If the channel isn't found, error is returned.

func (*CredentialSupport) GetPeerCredentials

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

GetPeerCredentials returns GRPC transport credentials for use by GRPC clients which communicate with remote peer endpoints.

func (*CredentialSupport) SetClientCertificate

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

SetClientCertificate sets the tls.Certificate to use for gRPC client connections

type KeepaliveOptions

type KeepaliveOptions struct {
	// ClientInterval is the duration after which if the client does not see
	// any activity from the server it pings the server to see if it is alive
	//ClientInterval是持续时间之后的持续时间,如果客户端没有看到来自服务器的任何活动,
	// 它会ping服务器以查看它是否处于活动状态
	ClientInterval time.Duration
	// ClientTimeout is the duration the client waits for a response
	// from the server after sending a ping before closing the connection
	//ClientTimeout是客户端在关闭连接之前发送ping之后等待服务器响应的持续时间
	ClientTimeout time.Duration
	// ServerInterval is the duration after which if the server does not see
	// any activity from the client it pings the client to see if it is alive
	//ServerInterval是持续时间之后的持续时间,如果服务器没有看到来自客户端的任何活动,
	// 它会ping客户端以查看它是否处于活动状态
	ServerInterval time.Duration
	// ServerTimeout is the duration the server waits for a response
	// from the client after sending a ping before closing the connection
	//ServerTimeout是服务器在关闭连接之前发送ping之后等待客户端响应的持续时间
	ServerTimeout time.Duration
	// ServerMinInterval is the minimum permitted time between client pings.
	// If clients send pings more frequently, the server will disconnect them
	//ServerMinInterval是客户端ping之间允许的最短时间。 如果客户端更频繁地发送ping,服务器将断开它们
	ServerMinInterval time.Duration
}

KeepAliveOptions is used to set the gRPC keepalive settings for both clients and servers

func DefaultKeepaliveOptions

func DefaultKeepaliveOptions() *KeepaliveOptions

DefaultKeepaliveOptions returns sane default keepalive settings for gRPC servers and clients

type SecureOptions

type SecureOptions struct {
	// PEM-encoded X509 public key to be used for TLS communication
	Certificate []byte
	// PEM-encoded private key to be used for TLS communication
	Key []byte
	// Set of PEM-encoded X509 certificate authorities used by clients to
	// verify server certificates
	ServerRootCAs [][]byte
	// Set of PEM-encoded X509 certificate authorities used by servers to
	// verify client certificates
	ClientRootCAs [][]byte
	// Whether or not to use TLS for communication
	UseTLS bool
	// Whether or not TLS client must present certificates for authentication
	RequireClientCert bool
	// CipherSuites is a list of supported cipher suites for TLS
	CipherSuites []uint16
}

SecureOptions defines the security parameters (e.g. TLS) for a GRPCServer instance

type ServerConfig

type ServerConfig struct {
	// SecOpts defines the security parameters
	SecOpts *SecureOptions
	// KaOpts defines the keepalive parameters
	KaOpts *KeepaliveOptions
}

ServerConfig defines the parameters for configuring a GRPCServer instance

Jump to

Keyboard shortcuts

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