package insecure
import "github.com/libp2p/go-libp2p/core/sec/insecure"
Package insecure provides an insecure, unencrypted implementation of the SecureConn and SecureTransport interfaces.
Recommended only for testing and other non-production usage.
Index ¶
- Constants
- type Conn
- func (ic *Conn) ConnState() network.ConnectionState
- func (ic *Conn) LocalPeer() peer.ID
- func (ic *Conn) RemotePeer() peer.ID
- func (ic *Conn) RemotePublicKey() ci.PubKey
- type Transport
- func NewWithIdentity(protocolID protocol.ID, id peer.ID, key ci.PrivKey) *Transport
- func (t *Transport) ID() protocol.ID
- func (t *Transport) LocalPeer() peer.ID
- func (t *Transport) SecureInbound(_ context.Context, insecure net.Conn, p peer.ID) (sec.SecureConn, error)
- func (t *Transport) SecureOutbound(_ context.Context, insecure net.Conn, p peer.ID) (sec.SecureConn, error)
Constants ¶
const ID = "/plaintext/2.0.0"
ID is the multistream-select protocol ID that should be used when identifying this security transport.
Types ¶
type Conn ¶
Conn is the connection type returned by the insecure transport.
func (*Conn) ConnState ¶
func (ic *Conn) ConnState() network.ConnectionState
ConnState returns the security connection's state information.
func (*Conn) LocalPeer ¶
LocalPeer returns the local peer ID.
func (*Conn) RemotePeer ¶
RemotePeer returns the remote peer ID if we initiated the dial. Otherwise, it returns "" (because this connection isn't actually secure).
func (*Conn) RemotePublicKey ¶
RemotePublicKey returns whatever public key was given by the remote peer. Note that no verification of ownership is done, as this connection is not secure.
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport is a no-op stream security transport. It provides no security and simply mocks the security methods. Identity methods return the local peer's ID and private key, and whatever the remote peer presents as their ID and public key. No authentication of the remote identity is performed.
func NewWithIdentity ¶
NewWithIdentity constructs a new insecure transport. The public key is sent to remote peers. No security is provided.
func (*Transport) ID ¶
func (*Transport) LocalPeer ¶
LocalPeer returns the transport's local peer ID.
func (*Transport) SecureInbound ¶
func (t *Transport) SecureInbound(_ context.Context, insecure net.Conn, p peer.ID) (sec.SecureConn, error)
SecureInbound *pretends to secure* an inbound connection to the given peer. It sends the local peer's ID and public key, and receives the same from the remote peer. No validation is performed as to the authenticity or ownership of the provided public key, and the key exchange provides no security.
SecureInbound may fail if the remote peer sends an ID and public key that are inconsistent with each other, or if a network error occurs during the ID exchange.
func (*Transport) SecureOutbound ¶
func (t *Transport) SecureOutbound(_ context.Context, insecure net.Conn, p peer.ID) (sec.SecureConn, error)
SecureOutbound *pretends to secure* an outbound connection to the given peer. It sends the local peer's ID and public key, and receives the same from the remote peer. No validation is performed as to the authenticity or ownership of the provided public key, and the key exchange provides no security.
SecureOutbound may fail if the remote peer sends an ID and public key that are inconsistent with each other, or if the ID sent by the remote peer does not match the one dialed. It may also fail if a network error occurs during the ID exchange.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
core/sec/insecure/pb |
- Version
- v0.42.0 (latest)
- Published
- Jun 18, 2025
- Platform
- linux/amd64
- Imports
- 12 packages
- Last checked
- 1 month ago –
Tools for package owners.