Documentation
¶
Index ¶
- func ConnectToServer(remote string) (net.Conn, error)
- func SignAndSend(m Message, from *identity.Identity, to *identity.Address) error
- func SignAndSendToConnection(m Message, from *identity.Identity, to *identity.Address, conn net.Conn) error
- type Component
- type ComponentList
- type DataMessage
- type EncryptedMessage
- func (e *EncryptedMessage) AddRecipient(addr *identity.Address) error
- func (e *EncryptedMessage) Decrypt(id *identity.Identity) (*SignedMessage, error)
- func (e *EncryptedMessage) Reconstruct(receiver *identity.Identity, ts bool) ([]byte, string, Header, error)
- func (e *EncryptedMessage) Send() error
- func (e *EncryptedMessage) SendMessageToConnection(conn net.Conn) error
- func (e *EncryptedMessage) ToBytes() ([]byte, error)
- func (e *EncryptedMessage) UnencryptedMessage() (*SignedMessage, error)
- type EncryptionHeader
- type Header
- func CreateHeader(from *identity.Address, to ...*identity.Address) Header
- func SendMessageAndReceive(m Message, sender *identity.Identity, addr *identity.Address) ([]byte, string, Header, error)
- func SendMessageAndReceiveWithTimestamp(m Message, sender *identity.Identity, addr *identity.Address) ([]byte, string, Header, error)
- type Mail
- type Message
- type SignedMessage
- func (s *SignedMessage) AddSignature(id *identity.Identity) error
- func (s *SignedMessage) Encrypt(addr string, router routing.Router) (*EncryptedMessage, error)
- func (s *SignedMessage) EncryptWithKey(addr *identity.Address) (*EncryptedMessage, error)
- func (s *SignedMessage) ReconstructMessage() (data []byte, messageType string, header Header, err error)
- func (s *SignedMessage) ReconstructMessageWithTimestamp() (data []byte, messageType string, header Header, err error)
- func (s *SignedMessage) UnencryptedMessage(addr *identity.Address) (*EncryptedMessage, error)
- func (s *SignedMessage) Verify() bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectToServer ¶
ConnectToServer is a convenience method that attempts to dial a tcp connection to a server specified by a string.
func SignAndSend ¶
SignAndSend will take a message, a from identity, and a to address, and send it to the address (so long as to already contains key information).
Types ¶
type Component ¶
Component is a basic unit in an AirDispatch message. It has a name, generally a string akin to Apple's bundle ids.
E.G. if I am creating an AirDispatch application at http://airdispat.ch/notes I may have a data type called "ch.airdispat.notes.title".
func CreateComponent ¶
CreateComponent will return a new component given a name and data.
func CreateStringComponent ¶
CreateStringComponent will return a new component given a name and a UTF-8 string.
func (Component) String ¶
String will return the bytes of the component interpreted as UTF-8.
type ComponentList ¶
ComponentList maps keys (strings) to components.
func (ComponentList) AddComponent ¶
func (c ComponentList) AddComponent(comp Component)
AddComponent will add a new component object into the list.
func (ComponentList) GetComponent ¶
func (c ComponentList) GetComponent(name string) []byte
GetComponent will return the []byte associated with a component name.
func (ComponentList) GetStringComponent ¶
func (c ComponentList) GetStringComponent(name string) string
GetStringComponent will return the []byte associated with a component name interpreted as UTF-8.
func (ComponentList) HasComponent ¶
func (c ComponentList) HasComponent(name string) bool
HasComponent will return whether a Mail object contains a component.
func (ComponentList) ToArray ¶
func (c ComponentList) ToArray() []Component
ToArray will return the ComponentList as an array of components.
type DataMessage ¶
type DataMessage struct {
Hash []byte
Length uint64
Key []byte
DataType string
Name string
Filename string
// contains filtered or unexported fields
}
DataMessage allows transfer of arbitrarily large bytestreams.
func CreateDataMessage ¶
func CreateDataMessage(hash []byte, length uint64, typ, name, filename string, r io.ReadCloser, h Header) (*DataMessage, io.ReadCloser, error)
func CreateDataMessageFromBytes ¶
func CreateDataMessageFromBytes(by []byte, h Header) (*DataMessage, error)
CreateMailFromBytes will unmarshall a mail message given its bytes and header.
func (*DataMessage) DecryptReader ¶
func (*DataMessage) Header ¶
func (m *DataMessage) Header() Header
func (*DataMessage) ToBytes ¶
func (m *DataMessage) ToBytes() []byte
ToBytes will marshal a mail message to its component bytes.
func (*DataMessage) TrueLength ¶
func (m *DataMessage) TrueLength() uint64
func (*DataMessage) Type ¶
func (m *DataMessage) Type() string
func (*DataMessage) VerifyPayload ¶
func (m *DataMessage) VerifyPayload() bool
type EncryptedMessage ¶
type EncryptedMessage struct {
Data []byte
Header map[string]EncryptionHeader
// contains filtered or unexported fields
}
EncryptedMessage represents an AirDispatch message encrypted for one or many recipients.
func CreateEncryptedMessageFromBytes ¶
func CreateEncryptedMessageFromBytes(theBytes []byte) (*EncryptedMessage, error)
CreateEncryptedMessageFromBytes will take a series of bytes (usually read read from a connection) and Unmarshal them into the EncryptedMessage struct.
func ReadMessageFromConnection ¶
func ReadMessageFromConnection(conn net.Conn) (*EncryptedMessage, error)
ReadMessageFromConnection will return a read EncryptedMessage off a specified net.Conn.
func (*EncryptedMessage) AddRecipient ¶
func (e *EncryptedMessage) AddRecipient(addr *identity.Address) error
AddRecipient will take an *identity.Address and add information for it to decrypt the message.
func (*EncryptedMessage) Decrypt ¶
func (e *EncryptedMessage) Decrypt(id *identity.Identity) (*SignedMessage, error)
Decrypt will use an *identity.Identity to decrypt the EncryptedMessage into a SignedMessage.
func (*EncryptedMessage) Reconstruct ¶
func (e *EncryptedMessage) Reconstruct(receiver *identity.Identity, ts bool) ([]byte, string, Header, error)
Reconstruct will take an change an encrypted message into a message blob Message Type, Header, and Error by Decrypting with the receiver's identity, verifying the signed message, and reconstructing the signed message (optionally with timestamp support).
func (*EncryptedMessage) Send ¶
func (e *EncryptedMessage) Send() error
Send will connect to each recipient's server and send the message to them.
func (*EncryptedMessage) SendMessageToConnection ¶
func (e *EncryptedMessage) SendMessageToConnection(conn net.Conn) error
SendMessageToConnection will send an encryptedMessage to a connection.
func (*EncryptedMessage) ToBytes ¶
func (e *EncryptedMessage) ToBytes() ([]byte, error)
ToBytes will marshal an EncryptedMessage to an array of bytes suitable for sending on a wire.
func (*EncryptedMessage) UnencryptedMessage ¶
func (e *EncryptedMessage) UnencryptedMessage() (*SignedMessage, error)
UnencryptedMessage will downgrade an EncryptedMessage into a SignedMessage if you know that the message is not encrypted.
type EncryptionHeader ¶
EncryptionHeader holds the information necessary for a recipient to decrypt the message.
type Header ¶
type Header struct {
From *identity.Address
To []*identity.Address
Timestamp int64
// Location Options
EncryptionKey []byte
Alias string
}
Header is a message header that is sent across the wire signed and encrypted.
Each public field is an object that is important to be protected.
func CreateHeader ¶
CreateHeader will return a basic header for a from address and a to address.
func SendMessageAndReceive ¶
func SendMessageAndReceive(m Message, sender *identity.Identity, addr *identity.Address) ([]byte, string, Header, error)
SendMessageAndReceive does exactly what you think:
- Signs, Encrypts, and sends a message to a connection - Receives, Decrypts, Verifies, and Reconstructs a message from a connection (without timestamp support)
type Mail ¶
type Mail struct {
Name string
Components ComponentList
// contains filtered or unexported fields
}
Mail is the basic form of a user-visible AirDispatch message.
It contains a list of components that effectively serve as a key-value dictionary of string -> []byte. Most of the time, the []byte can be interpreted as a UTF-8 string.
func CreateMail ¶
CreateMail will return a new Mail object with the correct header, ready for adding components.
func CreateMailFromBytes ¶
CreateMailFromBytes will unmarshall a mail message given its bytes and header.
func (*Mail) Header ¶
Header just returns the stored header with the message.
func (*Mail) ToBytes ¶
ToBytes will marshal a mail message to its component bytes.
type Message ¶
Message is an interface that allows something to be sent on the AirDispatch wire. It requires a message that knows how to marshal itself to bytes (ToBytes()), retrieve a header (Header()), and return a message type (Type()).
type SignedMessage ¶
type SignedMessage struct {
Data []byte
Signature []*wire.Signature
SigningFunc []byte
// contains filtered or unexported fields
}
SignedMessage represents a chunk of data that has been signed by a user of AirDispatch.
func SignMessage ¶
func SignMessage(m Message, id *identity.Identity) (*SignedMessage, error)
SignMessage will sign an object that implements the message interface with an id and return the corresponding SignedMessage.
func (*SignedMessage) AddSignature ¶
func (s *SignedMessage) AddSignature(id *identity.Identity) error
AddSignature will add a new signature of the data by id onto the message. This is useful if you need a SignedMessage to be signed by multiple parties.
func (*SignedMessage) Encrypt ¶
func (s *