insecure

package
v0.31.5 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package insecure provides an insecure, unencrypted implementation of 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) ConnState

func (ic *Conn) ConnState() network.ConnectionState

ConnState returns the security connection's state information.

func (*Conn) LocalPeer

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

LocalPeer returns the local peer ID.

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(protocolID protocol.ID, id peer.ID, key ci.PrivKey) *Transport

NewWithIdentity constructs a new insecure transport. The public key is sent to remote peers. No security is provided.

func (*Transport) ID

func (t *Transport) ID() protocol.ID

func (*Transport) LocalPeer

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

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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