From a7d9ced9f96a03a51c183fae61ec71ba046b14d9 Mon Sep 17 00:00:00 2001 From: Aarsh Shah Date: Sun, 14 Feb 2021 17:45:11 +0530 Subject: [PATCH] Secure Muxer Interface (#180) --- sec/security.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sec/security.go b/sec/security.go index 95c8e6a..42321d1 100644 --- a/sec/security.go +++ b/sec/security.go @@ -24,3 +24,17 @@ type SecureTransport interface { // SecureOutbound secures an outbound connection. SecureOutbound(ctx context.Context, insecure net.Conn, p peer.ID) (SecureConn, error) } + +// A SecureMuxer is a wrapper around SecureTransport which can select security protocols +// 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 + // connection; in the case of SecureInbound it should always be true. + SecureInbound(ctx context.Context, insecure net.Conn) (SecureConn, bool, error) + + // SecureOutbound secures an outbound connection. + // The returned boolean indicates whether the connection should be treated as a server + // connection due to simultaneous open. + SecureOutbound(ctx context.Context, insecure net.Conn, p peer.ID) (SecureConn, bool, error) +} -- GitLab