ceremonyclient/go-libp2p/core/sec/security.go
2023-08-20 23:07:43 -05:00

32 lines
954 B
Go

// Package sec provides secure connection and transport interfaces for libp2p.
package sec
import (
"context"
"net"
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/core/protocol"
)
// SecureConn is an authenticated, encrypted connection.
type SecureConn interface {
net.Conn
network.ConnSecurity
}
// A SecureTransport turns inbound and outbound unauthenticated,
// plain-text, native connections into authenticated, encrypted connections.
type SecureTransport interface {
// SecureInbound secures an inbound connection.
// 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)
// ID is the protocol ID of the security protocol.
ID() protocol.ID
}