github.com/yacovm/fabric@v2.0.0-alpha.0.20191128145320-c5d4087dc723+incompatible/common/util/net.go (about) 1 /* 2 Copyright IBM Corp. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package util 8 9 import ( 10 "context" 11 12 "google.golang.org/grpc/peer" 13 ) 14 15 func ExtractRemoteAddress(ctx context.Context) string { 16 var remoteAddress string 17 p, ok := peer.FromContext(ctx) 18 if !ok { 19 return "" 20 } 21 if address := p.Addr; address != nil { 22 remoteAddress = address.String() 23 } 24 return remoteAddress 25 }