package sec

import "github.com/libp2p/go-libp2p/core/sec"

Package sec provides secure connection and transport interfaces for libp2p.

Index

Types

type ErrPeerIDMismatch

type ErrPeerIDMismatch struct {
	Expected peer.ID
	Actual   peer.ID
}

func (ErrPeerIDMismatch) Error

func (e ErrPeerIDMismatch) Error() string

type SecureConn

type SecureConn interface {
	net.Conn
	network.ConnSecurity
}

SecureConn is an authenticated, encrypted connection.

type SecureTransport

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
}

A SecureTransport turns inbound and outbound unauthenticated, plain-text, native connections into authenticated, encrypted connections.

Source Files

security.go

Directories

PathSynopsis
core/sec/insecurePackage insecure provides an insecure, unencrypted implementation of the SecureConn and SecureTransport interfaces.
core/sec/insecure/pb
Version
v0.42.0 (latest)
Published
Jun 18, 2025
Platform
linux/amd64
Imports
6 packages
Last checked
1 week ago

Tools for package owners.