mirror of
https://github.com/linka-cloud/grpc.git
synced 2025-11-23 12:43:13 +00:00
feat(creds): retrieve peer credentials when using unix socket
Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
@@ -29,6 +29,7 @@ import (
|
||||
"google.golang.org/grpc/health/grpc_health_v1"
|
||||
greflect "google.golang.org/grpc/reflection"
|
||||
|
||||
"go.linka.cloud/grpc-toolkit/creds/peercreds"
|
||||
"go.linka.cloud/grpc-toolkit/interceptors/chain"
|
||||
"go.linka.cloud/grpc-toolkit/internal/injectlogger"
|
||||
"go.linka.cloud/grpc-toolkit/logger"
|
||||
@@ -138,6 +139,9 @@ func newService(opts ...Option) (*service, error) {
|
||||
grpc.StreamInterceptor(si),
|
||||
grpc.UnaryInterceptor(ui),
|
||||
}
|
||||
if _, ok := s.opts.lis.(*net.UnixListener); ok || strings.HasPrefix(s.opts.address, "unix://") {
|
||||
gopts = append(gopts, grpc.Creds(peercreds.New()))
|
||||
}
|
||||
s.server = grpc.NewServer(append(gopts, s.opts.serverOpts...)...)
|
||||
if s.opts.reflection {
|
||||
greflect.Register(s.server)
|
||||
|
||||
Reference in New Issue
Block a user