insecure

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2022 License: MIT Imports: 9 Imported by: 0

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

View Source
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

type Conn struct {
	net.Conn
	// contains filtered or unexported fields
}

Conn is the connection type returned by the insecure transport.

func (*Conn) LocalPeer

func (ic *Conn) LocalPeer() peer.ID

LocalPeer returns the local peer ID.

func (*Conn) LocalPrivateKey

func (ic *Conn) LocalPrivateKey() ci.PrivKey

LocalPrivateKey returns the private key for the local peer.

func (*Conn) RemotePeer

func (ic *Conn) RemotePeer() peer.ID

RemotePeer returns the remote peer ID if we initiated the dial. Otherwise, it returns "" (because this connection isn't actually secure).

func (*Conn) RemotePublicKey

func (ic *Conn) RemotePublicKey() ci.PubKey

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

func NewWithIdentity(id peer.ID, key ci.PrivKey) *Transport

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) LocalPeer

func (t *Transport) LocalPeer() peer.ID

LocalPeer returns the transport's local peer ID.

func (*Transport) LocalPrivateKey

func (t *Transport) LocalPrivateKey() ci.PrivKey

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL