Documentation ¶
Overview ¶
Package insecure provides an insecure, unencrypted implementation of the the SecureConn and SecureTransport interfaces.
Recommended only for testing and other non-production usage.
Index ¶
- Constants
- type Conn
- type Transport
- func (t *Transport) LocalPeer() peer.ID
- func (t *Transport) LocalPrivateKey() ci.PrivKey
- func (t *Transport) SecureInbound(ctx context.Context, insecure net.Conn, p peer.ID) (sec.SecureConn, error)
- func (t *Transport) SecureOutbound(ctx 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.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
Conn is the connection type returned by the insecure transport.
func (*Conn) LocalPrivateKey ¶
LocalPrivateKey returns the private key for the local peer.
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 provided private key is stored and returned from LocalPrivateKey to satisfy the SecureTransport interface, and the public key is sent to remote peers. No security is provided.
func (*Transport) LocalPrivateKey ¶
LocalPrivateKey returns the local private key. This key is used only for identity generation and provides no security.
func (*Transport) SecureInbound ¶
func (t *Transport) SecureInbound(ctx 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(ctx 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.