@@ -80,33 +80,35 @@ protected override string PeerCore
8080 // Follows the standard at https://github.com/grpc/grpc/blob/master/doc/naming.md
8181 if ( _peer == null )
8282 {
83- var connection = HttpContext . Connection ;
84- if ( connection . RemoteIpAddress != null )
85- {
86- switch ( connection . RemoteIpAddress . AddressFamily )
87- {
88- case AddressFamily . InterNetwork :
89- _peer = "ipv4:" + connection . RemoteIpAddress + ":" + connection . RemotePort ;
90- break ;
91- case AddressFamily . InterNetworkV6 :
92- _peer = "ipv6:[" + connection . RemoteIpAddress + "]:" + connection . RemotePort ;
93- break ;
94- default :
95- // TODO(JamesNK) - Test what should be output when used with UDS and named pipes
96- _peer = "unknown:" + connection . RemoteIpAddress + ":" + connection . RemotePort ;
97- break ;
98- }
99- }
100- else
101- {
102- _peer = "unknown" ; // Match Grpc.Core
103- }
83+ _peer = BuildPeer ( ) ;
10484 }
10585
10686 return _peer ;
10787 }
10888 }
10989
90+ private string BuildPeer ( )
91+ {
92+ var connection = HttpContext . Connection ;
93+ if ( connection . RemoteIpAddress != null )
94+ {
95+ switch ( connection . RemoteIpAddress . AddressFamily )
96+ {
97+ case AddressFamily . InterNetwork :
98+ return $ "ipv4:{ connection . RemoteIpAddress } :{ connection . RemotePort } ";
99+ case AddressFamily . InterNetworkV6 :
100+ return $ "ipv6:[{ connection . RemoteIpAddress } ]:{ connection . RemotePort } ";
101+ default :
102+ // TODO(JamesNK) - Test what should be output when used with UDS and named pipes
103+ return $ "unknown:{ connection . RemoteIpAddress } :{ connection . RemotePort } ";
104+ }
105+ }
106+ else
107+ {
108+ return "unknown" ; // Match Grpc.Core
109+ }
110+ }
111+
110112 protected override DateTime DeadlineCore => DeadlineManager ? . Deadline ?? DateTime . MaxValue ;
111113
112114 protected override Metadata RequestHeadersCore
0 commit comments