mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
18 lines
356 B
Go
18 lines
356 B
Go
|
// 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()
|
||
|
}
|