zmtp

package module
v0.0.0-...-81d051b Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2021 License: MPL-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Index int
	Name  string
	Body  []byte
}

Command represents an underlying ZMTP command

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

Connection is a ZMTP level connection

func NewConnection

func NewConnection(rw io.ReadWriter) *Connection

NewConnection accepts an io.ReadWriter and creates a new ZMTP connection

func (*Connection) GetIdentity

func (c *Connection) GetIdentity() (string, error)

GetIdentity get connection's identity

func (*Connection) Prepare

func (c *Connection) Prepare(mechanism SecurityMechanism, socketType SocketType, socketID SocketIdentity, asServer bool, applicationMetadata map[string]string) (map[string]string, error)

Prepare performs a ZMTP handshake over a Connection's readWriter

func (*Connection) Recv

func (c *Connection) Recv(messageOut chan<- *Message)

Recv starts listening to the ReadWriter and passes *Message to a channel

func (*Connection) RecvMultipart

func (c *Connection) RecvMultipart(messageOut chan<- *Message)

RecvMultipart starts listening to the ReadWriter and passes *Message to a channel

func (*Connection) SendCommand

func (c *Connection) SendCommand(commandName string, body []byte) error

SendCommand sends a ZMTP command over a Connection

func (*Connection) SendFrame

func (c *Connection) SendFrame(body []byte) error

SendFrame sends a ZMTP frame over a Connection

func (*Connection) SendMultipart

func (c *Connection) SendMultipart(bs [][]byte) error

type Message

type Message struct {
	Index       int
	Name        string
	Body        [][]byte
	Err         error
	MessageType MessageType
}

Message represents a ZMTP message

type MessageType

type MessageType int

MessageType represents a "type" of ZMTP message (User, Command, Error)

const (
	// UserMessage is a ZMTP message sent by a user
	UserMessage MessageType = iota

	// CommandMessage is a ZMTP command
	CommandMessage

	// ErrorMessage is.. an error message
	ErrorMessage
)

type SecurityMechanism

type SecurityMechanism interface {
	Type() SecurityMechanismType
	Handshake() error
	Encrypt([]byte) []byte
}

SecurityMechanism is an interface for ZMTP security mechanisms

type SecurityMechanismType

type SecurityMechanismType string

SecurityMechanismType denotes types of ZMTP security mechanisms

const (
	// NullSecurityMechanismType is an empty security mechanism
	// that does no authentication nor encryption.
	NullSecurityMechanismType SecurityMechanismType = "NULL"

	// PlainSecurityMechanismType is a security mechanism that uses
	// plaintext passwords. It is a reference implementation and
	// should not be used to anything important.
	PlainSecurityMechanismType SecurityMechanismType = "PLAIN"

	// CurveSecurityMechanismType uses ZMQ_CURVE for authentication
	// and encryption.
	CurveSecurityMechanismType SecurityMechanismType = "CURVE"
)

type SecurityNull

type SecurityNull struct{}

SecurityNull implements the NullSecurityMechanismType

func NewSecurityNull

func NewSecurityNull() *SecurityNull

NewSecurityNull returns a SecurityNull mechanism

func (*SecurityNull) Encrypt

func (s *SecurityNull) Encrypt(data []byte) []byte

Encrypt encrypts a []byte

func (*SecurityNull) Handshake

func (s *SecurityNull) Handshake() error

Handshake performs the ZMTP handshake for this security mechanism

func (*SecurityNull) Type

Type returns the security mechanisms type

type Socket

type Socket interface {
	Type() SocketType
	IsSocketTypeCompatible(socketType SocketType) bool
	IsCommandTypeValid(name string) bool
}

Socket is a ZMTP socket

func NewSocket

func NewSocket(socketType SocketType) (Socket, error)

NewSocket returns a new ZMTP socket

type SocketIdentity

type SocketIdentity []byte

SocketIdentity is the ZMTP metadata socket identity. See:

https://rfc.zeromq.org/spec:23/ZMTP/.

func (SocketIdentity) String

func (id SocketIdentity) String() string

type SocketType

type SocketType string

SocketType is a ZMTP socket type

const (
	ClientSocketType SocketType = "CLIENT" // a ZMQ_CLIENT socket
	ServerSocketType SocketType = "SERVER" // a ZMQ_SERVER socket
	PullSocketType   SocketType = "PULL"   // a ZMQ_PULL socket
	PushSocketType   SocketType = "PUSH"   // a ZMQ_PUSH socket
	DealerSocketType SocketType = "DEALER" // a ZMQ_DEALER socket
	RouterSocketType SocketType = "ROUTER" // a ZMQ_ROUTER socket
	ReqSocketType    SocketType = "REQ"    // a ZMQ_REQ socket
	RepSocketType    SocketType = "REP"    // a ZMQ_REP socket
	PubSocketType    SocketType = "PUB"    // a ZMQ_PUB socket
	SubSocketType    SocketType = "SUB"    // a ZMQ_SUB socket
	XPubSocketType   SocketType = "XPUB"   // a ZMQ_XPUB socket
	XSubSocketType   SocketType = "XSUB"   // a ZMQ_XSUB socket
)

Jump to

Keyboard shortcuts

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