From 9f55be3238c3c0992839ea336a5bc4fe5de9522f Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sun, 5 Sep 2021 13:24:32 +0100 Subject: [PATCH] pass the peer ID to SecureInbound in the SecureTransport and SecureMuxer The peer ID may be empty. This will be the common case. In that case, connections from any peer are accepted. --- sec/security.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sec/security.go b/sec/security.go index 42321d18..a4cd7a2e 100644 --- a/sec/security.go +++ b/sec/security.go @@ -19,7 +19,8 @@ type SecureConn interface { // plain-text, native connections into authenticated, encrypted connections. type SecureTransport interface { // SecureInbound secures an inbound connection. - SecureInbound(ctx context.Context, insecure net.Conn) (SecureConn, error) + // If p is empty, connections from any peer are accepted. + SecureInbound(ctx context.Context, insecure net.Conn, p peer.ID) (SecureConn, error) // SecureOutbound secures an outbound connection. SecureOutbound(ctx context.Context, insecure net.Conn, p peer.ID) (SecureConn, error) @@ -29,9 +30,10 @@ type SecureTransport interface { // and open outbound connections with simultaneous open. type SecureMuxer interface { // SecureInbound secures an inbound connection. - // The returned boolean indicates whether the connection should be trated as a server + // The returned boolean indicates whether the connection should be treated as a server // connection; in the case of SecureInbound it should always be true. - SecureInbound(ctx context.Context, insecure net.Conn) (SecureConn, bool, error) + // If p is empty, connections from any peer are accepted. + SecureInbound(ctx context.Context, insecure net.Conn, p peer.ID) (SecureConn, bool, error) // SecureOutbound secures an outbound connection. // The returned boolean indicates whether the connection should be treated as a server