Documentation
¶
Index ¶
- Constants
- type EarlyDataHandler
- type SessionOption
- type SessionTransport
- type Transport
- 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)
- func (t *Transport) WithSessionOptions(opts ...SessionOption) (sec.SecureTransport, error)
Constants ¶
const ID = "/noise"
ID is the protocol ID for noise
const LengthPrefixLength = 2
LengthPrefixLength is the length of the length prefix itself, which precedes all transport messages in order to delimit them. In bytes.
const MaxPlaintextLength = MaxTransportMsgLength - chacha20poly1305.Overhead
MaxPlaintextLength is the maximum payload size. It is MaxTransportMsgLength minus the MAC size. Payloads over this size will be automatically chunked.
const MaxTransportMsgLength = 0xffff
MaxTransportMsgLength is the Noise-imposed maximum transport message length, inclusive of the MAC size (16 bytes, Poly1305 for noise-libp2p).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EarlyDataHandler ¶
type EarlyDataHandler interface { // Send is called for the client before sending the first handshake message. Send(context.Context, net.Conn, peer.ID) []byte // Received is called for the server when the first handshake message from the client is received. Received(context.Context, net.Conn, []byte) error }
EarlyDataHandler allows attaching an (unencrypted) application payload to the first handshake message. While unencrypted, the integrity of this early data is retroactively authenticated on completion of the handshake.
type SessionOption ¶
type SessionOption = func(*SessionTransport) error
func EarlyData ¶
func EarlyData(h EarlyDataHandler) SessionOption
func Prologue ¶
func Prologue(prologue []byte) SessionOption
Prologue sets a prologue for the Noise session. The handshake will only complete successfully if both parties set the same prologue. See https://noiseprotocol.org/noise.html#prologue for details.
type SessionTransport ¶
type SessionTransport struct {
// contains filtered or unexported fields
}
SessionTransport can be used to provide per-connection options
func (*SessionTransport) SecureInbound ¶
func (i *SessionTransport) SecureInbound(ctx context.Context, insecure net.Conn, p peer.ID) (sec.SecureConn, error)
SecureInbound runs the Noise handshake as the responder. If p is empty, connections from any peer are accepted.
func (*SessionTransport) SecureOutbound ¶
func (i *SessionTransport) SecureOutbound(ctx context.Context, insecure net.Conn, p peer.ID) (sec.SecureConn, error)
SecureOutbound runs the Noise handshake as the initiator.
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport implements the interface sec.SecureTransport https://godoc.org/github.com/John-LittleBearLabs/go-libp2p/core/sec#SecureConn
func New ¶
New creates a new Noise transport using the given private key as its libp2p identity key.
func (*Transport) SecureInbound ¶
func (t *Transport) SecureInbound(ctx context.Context, insecure net.Conn, p peer.ID) (sec.SecureConn, error)
SecureInbound runs the Noise handshake as the responder. If p is empty, connections from any peer are accepted.
func (*Transport) SecureOutbound ¶
func (t *Transport) SecureOutbound(ctx context.Context, insecure net.Conn, p peer.ID) (sec.SecureConn, error)
SecureOutbound runs the Noise handshake as the initiator.
func (*Transport) WithSessionOptions ¶
func (t *Transport) WithSessionOptions(opts ...SessionOption) (sec.SecureTransport, error)