diff --git a/server/grpc/grpc.go b/server/grpc/grpc.go index 4ff4b79f..6575d3b6 100644 --- a/server/grpc/grpc.go +++ b/server/grpc/grpc.go @@ -28,6 +28,7 @@ import ( "google.golang.org/grpc/credentials" "google.golang.org/grpc/encoding" "google.golang.org/grpc/metadata" + "google.golang.org/grpc/peer" "google.golang.org/grpc/status" ) @@ -203,6 +204,12 @@ func (g *grpcServer) handler(srv interface{}, stream grpc.ServerStream) error { // create new context ctx := meta.NewContext(stream.Context(), md) + // get peer from context + if p, ok := peer.FromContext(stream.Context()); ok { + md["Remote"] = p.Addr.String() + ctx = peer.NewContext(ctx, p) + } + // set the timeout if we have it if len(to) > 0 { if n, err := strconv.ParseUint(to, 10, 64); err == nil {