mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-27 00:19:36 -05:00
bd63aa3c6b
sed -i '1i/*\nCopyright (c) Edgeless Systems GmbH\n\nSPDX-License-Identifier: AGPL-3.0-only\n*/\n' `grep -rL --include='*.go' 'DO NOT EDIT'` gofumpt -w .
24 lines
439 B
Go
24 lines
439 B
Go
/*
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
// grpclog provides a logging utilities for gRPC.
|
|
package grpclog
|
|
|
|
import (
|
|
"context"
|
|
|
|
"google.golang.org/grpc/peer"
|
|
)
|
|
|
|
// PeerAddrFromContext returns a peer's address from context, or "unknown" if not found.
|
|
func PeerAddrFromContext(ctx context.Context) string {
|
|
p, ok := peer.FromContext(ctx)
|
|
if !ok {
|
|
return "unknown"
|
|
}
|
|
return p.Addr.String()
|
|
}
|