Documentation ¶
Index ¶
- Variables
- func AddPemToCertPool(pemCerts []byte, pool *x509.CertPool) error
- func ClientKeepaliveOptions(ka *KeepaliveOptions) []grpc.DialOption
- func ExtractCertificateFromContext(ctx context.Context) []byte
- func ExtractCertificateHashFromContext(ctx context.Context) []byte
- func InitTLSForShim(key, certStr string) credentials.TransportCredentials
- func NewClientConnectionWithAddress(peerAddress string, block bool, tslEnabled bool, ...) (*grpc.ClientConn, error)
- func NewServerTransportCredentials(serverConfig *tls.Config, logger *flogging.FabricLogger) credentials.TransportCredentials
- func ServerKeepaliveOptions(ka *KeepaliveOptions) []grpc.ServerOption
- type BindingInspector
- type CASupport
- type CertHashExtractor
- type ClientConfig
- type ConnectionFactory
- type ConnectionProducer
- type CredentialSupport
- func (cs *CredentialSupport) GetClientCertificate() tls.Certificate
- func (cs *CredentialSupport) GetDeliverServiceCredentials(channelID string) (credentials.TransportCredentials, error)
- func (cs *CredentialSupport) GetPeerCredentials() credentials.TransportCredentials
- func (cs *CredentialSupport) SetClientCertificate(cert tls.Certificate)
- type GRPCClient
- func (client *GRPCClient) Certificate() tls.Certificate
- func (client *GRPCClient) MutualTLSRequired() bool
- func (client *GRPCClient) NewConnection(address string, serverNameOverride string) (*grpc.ClientConn, error)
- func (client *GRPCClient) SetMaxRecvMsgSize(size int)
- func (client *GRPCClient) SetMaxSendMsgSize(size int)
- func (client *GRPCClient) SetServerRootCAs(serverRoots [][]byte) error
- func (client *GRPCClient) TLSEnabled() bool
- type GRPCServer
- func (gServer *GRPCServer) Address() string
- func (gServer *GRPCServer) AppendClientRootCAs(clientRoots [][]byte) error
- func (gServer *GRPCServer) Listener() net.Listener
- func (gServer *GRPCServer) MutualTLSRequired() bool
- func (gServer *GRPCServer) RemoveClientRootCAs(clientRoots [][]byte) error
- func (gServer *GRPCServer) Server() *grpc.Server
- func (gServer *GRPCServer) ServerCertificate() tls.Certificate
- func (gServer *GRPCServer) SetClientRootCAs(clientRoots [][]byte) error
- func (gServer *GRPCServer) SetServerCertificate(cert tls.Certificate)
- func (gServer *GRPCServer) Start() error
- func (gServer *GRPCServer) Stop()
- func (gServer *GRPCServer) TLSEnabled() bool
- type KeepaliveOptions
- type Metrics
- type NewSemaphoreFunc
- type SecureOptions
- type Semaphore
- type ServerConfig
- type ServerStatsHandler
- func (h *ServerStatsHandler) HandleConn(ctx context.Context, s stats.ConnStats)
- func (h *ServerStatsHandler) HandleRPC(ctx context.Context, s stats.RPCStats)
- func (h *ServerStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
- func (h *ServerStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
- type Throttle
- type ThrottleOption
Constants ¶
This section is empty.
Variables ¶
var ( //GRPC客户端和服务器的最大发送和接收字节数 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, } //强TLS密码套件 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 )
配置默认值
var ( ClientHandshakeNotImplError = errors.New("core/comm: Client handshakes" + "are not implemented with serverCreds") OverrrideHostnameNotSupportedError = errors.New( "core/comm: OverrideServerName is " + "not supported") MissingServerConfigError = errors.New( "core/comm: `serverConfig` cannot be nil") )
var EndpointDisableInterval = time.Second * 10
Functions ¶
func AddPemToCertPool ¶
addpemtocertpool将pem编码的证书添加到证书池
func ClientKeepaliveOptions ¶
func ClientKeepaliveOptions(ka *KeepaliveOptions) []grpc.DialOption
clientkeepaliveoptions为客户端返回grpc keepalive选项。如果 opts为nil,返回默认的keepalive选项
func ExtractCertificateFromContext ¶
ExtractCertificateFromContext返回TLS证书(如果适用) 从GRPC流的给定上下文
func ExtractCertificateHashFromContext ¶
ExtractCertificateHashFromContext从给定的上下文中提取证书的哈希。 如果证书不存在,则返回零。
func InitTLSForShim ¶
func InitTLSForShim(key, certStr string) credentials.TransportCredentials
func NewClientConnectionWithAddress ¶
func NewClientConnectionWithAddress(peerAddress string, block bool, tslEnabled bool, creds credentials.TransportCredentials, ka *KeepaliveOptions) (*grpc.ClientConn, error)
newclientconnectionwithaddress将新grpc.clientconn返回给给定地址
func NewServerTransportCredentials ¶
func NewServerTransportCredentials( serverConfig *tls.Config, logger *flogging.FabricLogger) credentials.TransportCredentials
NewServerTransportCredentials返回新的已初始化 GRPC/凭证.运输凭证
func ServerKeepaliveOptions ¶
func ServerKeepaliveOptions(ka *KeepaliveOptions) []grpc.ServerOption
server keepalive options返回服务器的grpc keepalive选项。如果 opts为nil,返回默认的keepalive选项
Types ¶
type BindingInspector ¶
bindingInspector作为参数接收GRPC上下文和信封, 并验证消息是否包含与上下文的适当绑定
func NewBindingInspector ¶
func NewBindingInspector(mutualTLS bool, extractTLSCertHash CertHashExtractor) BindingInspector
NewBindingInspector根据是否 是否配置了MutualTLS,并根据提取的函数 来自协议消息的TLS证书哈希
type CASupport ¶
type CASupport struct { sync.RWMutex AppRootCAsByChain map[string][][]byte OrdererRootCAsByChain map[string][][]byte ClientRootCAs [][]byte ServerRootCAs [][]byte }
casupport类型管理由通道作用域的证书颁发机构
func (*CASupport) GetClientRootCAs ¶
getclientrootcas返回所有 为所有链定义的应用程序和订购方组织。根 返回的证书应用于设置的受信任客户端根 TLS服务器。
func (*CASupport) GetServerRootCAs ¶
getserverrootcas返回所有 为所有链定义的应用程序和订购方组织。根 返回的证书应用于设置的受信任服务器根 TLS客户端。
type CertHashExtractor ¶
certhashextractor从proto.message消息中提取证书
type ClientConfig ¶
type ClientConfig struct { //secopts定义安全参数 SecOpts *SecureOptions //kaopts定义了keepalive参数 KaOpts *KeepaliveOptions //Timeout指定客户端在尝试阻止时阻止的时间 //建立连接 Timeout time.Duration //AsyncConnect使连接创建无阻塞 AsyncConnect bool }
clientconfig定义用于配置grpcclient实例的参数
type ConnectionFactory ¶
type ConnectionFactory func(endpoint string) (*grpc.ClientConn, error)
ConnectionFactory创建到某个端点的连接
type ConnectionProducer ¶
type ConnectionProducer interface { //NewConnection创建新连接。 //返回连接,所选端点,成功时为零。 //返回nil,“”,失败时出错 NewConnection() (*grpc.ClientConn, string, error) //updateEndpoints更新ConnectionProducer的端点 //作为给定的端点 UpdateEndpoints(endpoints []string) //禁用端点从端点删除端点一段时间 DisableEndpoint(endpoint string) //GetEndpoints返回对服务终结点的排序 GetEndpoints() []string }
ConnectionProducer从一组预定义的 端点
func NewConnectionProducer ¶
func NewConnectionProducer(factory ConnectionFactory, endpoints []string) ConnectionProducer
NewConnectionProducer创建具有给定端点和连接工厂的新ConnectionProducer。 如果给定的端点切片为空,则返回nil。
type CredentialSupport ¶
type CredentialSupport struct { *CASupport // contains filtered or unexported fields }
CredentialSupport类型管理用于GRPC客户端连接的凭据
func GetCredentialSupport ¶
func GetCredentialSupport() *CredentialSupport
getCredentialSupport返回Singleton CredentialSupport实例
func (*CredentialSupport) GetClientCertificate ¶
func (cs *CredentialSupport) GetClientCertificate() tls.Certificate
getclientCertificate返回凭证支持的客户端证书
func (*CredentialSupport) GetDeliverServiceCredentials ¶
func (cs *CredentialSupport) GetDeliverServiceCredentials(channelID string) (credentials.TransportCredentials, error)
GetDeliverServiceCredentials返回GRPC要使用的给定通道的GRPC传输凭据 与订购服务端点通信的客户端。 如果找不到通道,则返回错误。
func (*CredentialSupport) GetPeerCredentials ¶
func (cs *CredentialSupport) GetPeerCredentials() credentials.TransportCredentials
GetPeerCredentials返回GRPC使用的GRPC传输凭据 与远程对等端点通信的客户端。
func (*CredentialSupport) SetClientCertificate ¶
func (cs *CredentialSupport) SetClientCertificate(cert tls.Certificate)
setclientcertificate设置要用于GRPC客户端的tls.certificate 连接
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
证书返回用于建立TLS连接的TLS证书 当服务器需要客户端证书时
func (*GRPCClient) MutualTLSRequired ¶
func (client *GRPCClient) MutualTLSRequired() bool
mutualTlsRequired是一个标志,指示客户端 进行TLS连接时必须发送证书
func (*GRPCClient) NewConnection ¶
func (client *GRPCClient) NewConnection(address string, serverNameOverride string) ( *grpc.ClientConn, error)
NewConnection返回目标地址的grpc.clientconn,并 覆盖用于验证主机名的服务器名 使用TLS时服务器返回的证书
func (*GRPCClient) SetMaxRecvMsgSize ¶
func (client *GRPCClient) SetMaxRecvMsgSize(size int)
setmaxrecvmsgsize设置客户端可以接收的最大消息大小
func (*GRPCClient) SetMaxSendMsgSize ¶
func (client *GRPCClient) SetMaxSendMsgSize(size int)
setmaxsendmsgsize设置客户端可以发送的最大消息大小
func (*GRPCClient) SetServerRootCAs ¶
func (client *GRPCClient) SetServerRootCAs(serverRoots [][]byte) error
setserverrootcas设置用于验证服务器的权限列表 基于PEM编码的X509证书颁发机构列表的证书
func (*GRPCClient) TLSEnabled ¶
func (client *GRPCClient) TLSEnabled() bool
tlsenabled是一个标志,指示是否对客户端使用tls 连接
type GRPCServer ¶
type GRPCServer struct {
// contains filtered or unexported fields
}
func NewGRPCServer ¶
func NewGRPCServer(address string, serverConfig ServerConfig) (*GRPCServer, error)
new grpcserver在给定 收听地址
func NewGRPCServerFromListener ¶
func NewGRPCServerFromListener(listener net.Listener, serverConfig ServerConfig) (*GRPCServer, error)
newgrpcServerFromListener创建给定grpcServer的新实现 使用默认keepalive的现有net.listener实例
func (*GRPCServer) AppendClientRootCAs ¶
func (gServer *GRPCServer) AppendClientRootCAs(clientRoots [][]byte) error
AppendClientRootcas将PEM编码的X509证书颁发机构附加到 用于验证客户端证书的权限列表
func (*GRPCServer) Listener ¶
func (gServer *GRPCServer) Listener() net.Listener
listener返回grpcserver实例的net.listener
func (*GRPCServer) MutualTLSRequired ¶
func (gServer *GRPCServer) MutualTLSRequired() bool
mutualTlsRequired是一个标志,指示客户端证书是否 对于此grpcserver实例是必需的
func (*GRPCServer) RemoveClientRootCAs ¶
func (gServer *GRPCServer) RemoveClientRootCAs(clientRoots [][]byte) error
removeclientrootcas从中删除PEM编码的X509证书颁发机构 用于验证客户端证书的权限列表
func (*GRPCServer) Server ¶
func (gServer *GRPCServer) Server() *grpc.Server
server返回grpc server实例的grpc.server
func (*GRPCServer) ServerCertificate ¶
func (gServer *GRPCServer) ServerCertificate() tls.Certificate
serverCertificate返回grpc.server使用的tls.certificate
func (*GRPCServer) SetClientRootCAs ¶
func (gServer *GRPCServer) SetClientRootCAs(clientRoots [][]byte) error
setclientrootcas设置用于验证客户端的权限列表 基于PEM编码的X509证书颁发机构列表的证书
func (*GRPCServer) SetServerCertificate ¶
func (gServer *GRPCServer) SetServerCertificate(cert tls.Certificate)
setServerCertificate将当前的TLS证书分配为对等方的服务器证书
func (*GRPCServer) TLSEnabled ¶
func (gServer *GRPCServer) TLSEnabled() bool
TLSEnabled是一个标志,指示是否为 grpcserver实例
type KeepaliveOptions ¶
type KeepaliveOptions struct { //clientInterval是当客户端没有看到 //它对服务器执行ping操作以查看服务器是否处于活动状态的服务器上的任何活动 ClientInterval time.Duration //clientTimeout是客户端等待响应的持续时间 //在关闭连接前发送ping之后从服务器发送 ClientTimeout time.Duration //ServerInterval是如果服务器没有看到 //它从客户机ping客户机以查看其是否活动的任何活动 ServerInterval time.Duration //ServerTimeout是服务器等待响应的持续时间 //在关闭连接前发送ping之后从客户端发送 ServerTimeout time.Duration //ServerMinInterval是客户端Ping之间允许的最短时间。 //如果客户机更频繁地发送ping,服务器将断开它们的连接。 ServerMinInterval time.Duration }
keepaliveoptions用于为两个设置grpc keepalive设置 客户端和服务器
type NewSemaphoreFunc ¶
type SecureOptions ¶
type SecureOptions struct { //verifycertificate,如果不是nil,则在正常之后调用 //由TLS客户端或服务器进行证书验证。 //如果返回非零错误,则终止握手并导致该错误。 VerifyCertificate func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error //用于TLS通信的PEM编码的X509公钥 Certificate []byte //用于TLS通信的PEM编码私钥 Key []byte //客户端使用的一组PEM编码的X509证书颁发机构 //验证服务器证书 ServerRootCAs [][]byte //服务器使用的一组PEM编码的X509证书颁发机构 //验证客户端证书 ClientRootCAs [][]byte //是否使用TLS进行通信 UseTLS bool //TLS客户端是否必须提供用于身份验证的证书 RequireClientCert bool //CipherSuites是受支持的TLS密码套件列表 CipherSuites []uint16 }
SecureOptions定义 grpcserver或grpcclient实例
type ServerConfig ¶
type ServerConfig struct { //connectionTimeout指定建立连接的超时 //对于所有新连接 ConnectionTimeout time.Duration //secopts定义安全参数 SecOpts *SecureOptions //kaopts定义了keepalive参数 KaOpts *KeepaliveOptions //流拦截器指定要应用于的拦截器列表 //流式RPC。它们是按顺序执行的。 StreamInterceptors []grpc.StreamServerInterceptor //一元拦截器指定要应用于一元的拦截器列表 //RPCs。它们是按顺序执行的。 UnaryInterceptors []grpc.UnaryServerInterceptor //logger指定服务器将使用的记录器 Logger *flogging.FabricLogger //度量提供程序 MetricsProvider metrics.Provider }
serverconfig定义用于配置grpcserver实例的参数
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 (h *ServerStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
func (*ServerStatsHandler) TagRPC ¶
func (h *ServerStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
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
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
此源码被清华学神尹成大魔王专业翻译分析并修改 尹成QQ77025077 尹成微信18510341407 尹成所在QQ群721929980 尹成邮箱 yinc13@mails.tsinghua.edu.cn 尹成毕业于清华大学,微软区块链领域全球最有价值专家 https://mvp.microsoft.com/zh-cn/PublicProfile/4033620 伪造者生成的代码。
|
此源码被清华学神尹成大魔王专业翻译分析并修改 尹成QQ77025077 尹成微信18510341407 尹成所在QQ群721929980 尹成邮箱 yinc13@mails.tsinghua.edu.cn 尹成毕业于清华大学,微软区块链领域全球最有价值专家 https://mvp.microsoft.com/zh-cn/PublicProfile/4033620 伪造者生成的代码。 |