From 0e38f0687a1f35a3e05ef06550be142ef20aae4a Mon Sep 17 00:00:00 2001 From: iamqizhao Date: Fri, 1 May 2015 19:06:07 -0700 Subject: [PATCH] provide some info for the gRPC protocol and security protocol --- credentials/credentials.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/credentials/credentials.go b/credentials/credentials.go index 56c58ac3..01092049 100644 --- a/credentials/credentials.go +++ b/credentials/credentials.go @@ -70,6 +70,17 @@ type Credentials interface { GetRequestMetadata(ctx context.Context) (map[string]string, error) } +// ProtocolInfo provides information regarding the gRPC wire protocol version, +// security protocol, security protocol version in use, etc. +type ProtocolInfo struct { + // ProtocolVersion is the gRPC wire protocol version. + ProtocolVersion string + // SecurityProtocol is the security protocol in use. + SecurityProtocol string + // SecurityVersion is the security protocol version. + SecurityVersion string +} + // TransportAuthenticator defines the common interface for all the live gRPC wire // protocols and supported transport security protocols (e.g., TLS, SSL). type TransportAuthenticator interface { @@ -79,6 +90,8 @@ type TransportAuthenticator interface { // NewListener creates a listener which accepts connections with requested // authentication handshake. NewListener(lis net.Listener) net.Listener + // ProtocolInfo provides the ProtocolInfo of this TransportAuthenticator. + ProtocolInfo() ProtocolInfo Credentials } @@ -88,6 +101,13 @@ type tlsCreds struct { config tls.Config } +func (c *tlsCreds) ProtocolInfo() ProtocolInfo { + return ProtocolInfo{ + SecurityProtocol: "tls", + SecurityVersion: "1.2", + } +} + // GetRequestMetadata returns nil, nil since TLS credentials does not have // metadata. func (c *tlsCreds) GetRequestMetadata(ctx context.Context) (map[string]string, error) {