only 1 credentials on server
This commit is contained in:
17
server.go
17
server.go
@ -86,7 +86,7 @@ type Server struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type options struct {
|
type options struct {
|
||||||
creds []credentials.Credentials
|
creds credentials.Credentials
|
||||||
codec Codec
|
codec Codec
|
||||||
maxConcurrentStreams uint32
|
maxConcurrentStreams uint32
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ func MaxConcurrentStreams(n uint32) ServerOption {
|
|||||||
// Creds returns a ServerOption that sets credentials for server connections.
|
// Creds returns a ServerOption that sets credentials for server connections.
|
||||||
func Creds(c credentials.Credentials) ServerOption {
|
func Creds(c credentials.Credentials) ServerOption {
|
||||||
return func(o *options) {
|
return func(o *options) {
|
||||||
o.creds = append(o.creds, c)
|
o.creds = c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,14 +195,11 @@ func (s *Server) Serve(lis net.Listener) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, o := range s.opts.creds {
|
if creds, ok := s.opts.creds.(credentials.TransportAuthenticator); ok {
|
||||||
if creds, ok := o.(credentials.TransportAuthenticator); ok {
|
c, err = creds.ServerHandshake(c)
|
||||||
c, err = creds.ServerHandshake(c)
|
if err != nil {
|
||||||
if err != nil {
|
grpclog.Println("grpc: Server.Serve failed to complete security handshake.")
|
||||||
grpclog.Println("grpc: Server.Serve failed to complete security handshake.")
|
continue
|
||||||
continue
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
|
Reference in New Issue
Block a user