test peer addr
This commit is contained in:
@ -44,7 +44,10 @@ import (
|
||||
|
||||
// Peer contains the information of the peer for an RPC.
|
||||
type Peer struct {
|
||||
Address net.Addr
|
||||
// Addr is the peer address.
|
||||
Addr net.Addr
|
||||
// AuthInfo is the authentication information of the transport.
|
||||
// It is nil if there is no transport security being used.
|
||||
AuthInfo credentials.AuthInfo
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,10 @@ func (s *testServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (*
|
||||
}
|
||||
pr, ok := peer.FromContext(ctx)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("Failed to get peer from ctx.")
|
||||
return nil, fmt.Errorf("failed to get peer from ctx")
|
||||
}
|
||||
if pr.Addr == net.Addr(nil) {
|
||||
return nil, fmt.Errorf("failed to get peer address")
|
||||
}
|
||||
if s.security != "" {
|
||||
// Check Auth info
|
||||
|
@ -240,7 +240,7 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (_ *Strea
|
||||
}
|
||||
}
|
||||
pr := &peer.Peer{
|
||||
Address: t.conn.RemoteAddr(),
|
||||
Addr: t.conn.RemoteAddr(),
|
||||
}
|
||||
// Attach Auth info if there is any.
|
||||
if t.authInfo != nil {
|
||||
|
@ -170,7 +170,7 @@ func (t *http2Server) operateHeaders(hDec *hpackDecoder, s *Stream, frame header
|
||||
s.ctx, s.cancel = context.WithCancel(context.TODO())
|
||||
}
|
||||
pr := &peer.Peer{
|
||||
Address: t.conn.RemoteAddr(),
|
||||
Addr: t.conn.RemoteAddr(),
|
||||
}
|
||||
// Attach Auth info if there is any.
|
||||
if t.authInfo != nil {
|
||||
|
Reference in New Issue
Block a user