test peer addr
diff --git a/peer/peer.go b/peer/peer.go
index e2ffe8b..bfa6205 100644
--- a/peer/peer.go
+++ b/peer/peer.go
@@ -44,7 +44,10 @@
// 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
}
diff --git a/test/end2end_test.go b/test/end2end_test.go
index 7138331..93944f8 100644
--- a/test/end2end_test.go
+++ b/test/end2end_test.go
@@ -113,7 +113,10 @@
}
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
diff --git a/transport/http2_client.go b/transport/http2_client.go
index c1b48e8..9eae37d 100644
--- a/transport/http2_client.go
+++ b/transport/http2_client.go
@@ -240,7 +240,7 @@
}
}
pr := &peer.Peer{
- Address: t.conn.RemoteAddr(),
+ Addr: t.conn.RemoteAddr(),
}
// Attach Auth info if there is any.
if t.authInfo != nil {
diff --git a/transport/http2_server.go b/transport/http2_server.go
index f074638..98088d9 100644
--- a/transport/http2_server.go
+++ b/transport/http2_server.go
@@ -170,7 +170,7 @@
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 {