client

package
v0.0.0-...-30b4a77 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2016 License: BSD-3-Clause Imports: 25 Imported by: 0

Documentation

Overview

Package client implements client functionality for the Mute mix system.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMaxSize is returned if a message is too long.
	ErrMaxSize = errors.New("mixclient: message too long")
	// ErrNoHost is returned if no host could be selected.
	ErrNoHost = errors.New("mixclient: no RPC host found")
	// ErrNIL is returned when operating on nil value because of coding errors.
	ErrNIL = errors.New("mixclient: nil value")
	// ErrAlreadySent is returned if trying to resend a message. Coding error!
	ErrAlreadySent = errors.New("mixclient: already sent")
	// ErrProto is returned if there was a protocol error in RPC.
	ErrProto = errors.New("mixclient: bad RPC protocol")
	// ErrNoMatch is returned if no account was found.
	ErrNoMatch = errors.New("mixclient: no match")
)
View Source
var DefaultAccountServer = "rr.accounts.mute.one"

DefaultAccountServer is the URL of the account server round-robin.

View Source
var DefaultClientFactory = jsonclient.New

DefaultClientFactory is the default factory for new clients.

View Source
var DefaultSender = "client@mute.one"

DefaultSender is the sender address for client messages.

View Source
var DefaultTimeOut = 30

DefaultTimeOut is the timeout for RPC calls.

View Source
var GetMixAddress = getMixAddressReal

GetMixAddress is used to get the address of a mix rpc. It should only be changed for debugging purposes or if the routing is replaced.

View Source
var MaxMessageSize = 266240

MaxMessageSize is the maximum size a message may have.

View Source
var RPCPort = "2080"

RPCPort is the default port for RPC calls.

Functions

func AccountStat

func AccountStat(privkey *[ed25519.PrivateKeySize]byte, server string, cacert []byte) (loadTime int64, err error)

AccountStat gets the time until which the account of privkey on server expires.

func DeleteAccount

func DeleteAccount(privkey *[ed25519.PrivateKeySize]byte, server string, cacert []byte) (err error)

DeleteAccount deletes the account of privkey on server.

func FetchMessage

func FetchMessage(privkey *[ed25519.PrivateKeySize]byte, messageID []byte, server string, cacert []byte) ([]byte, error)

FetchMessage fetches a message from the accountserver.

func GetMixKeys

func GetMixKeys(mixaddress string, cacert []byte) (*mixaddr.AddressStatement, error)

GetMixKeys gets the keys for the mix.

func HTTPSGet

func HTTPSGet(getURL string, cacert []byte) ([]byte, error)

HTTPSGet executes a get call over HTTPs.

func HTTPSPost

func HTTPSPost(postValues url.Values, postURL string, cacert []byte) ([]byte, error)

HTTPSPost executes a post call over HTTPs.

func PayAccount

func PayAccount(privkey *[ed25519.PrivateKeySize]byte, paytoken []byte, serverKnown string, cacert []byte) (server string, err error)

PayAccount makes a pay call to server (or selects a new one) to create or extend an account identified by privkey.

func ReadMail

func ReadMail(message []byte) (body []byte, err error)

ReadMail reads an email and returns the decoded body.

func RevokeMessage

func RevokeMessage(revokeID []byte, mixaddress string, cacert []byte) (bool, error)

RevokeMessage calls the revokation RPC to revoke a message, if possible.

func WriteMail

func WriteMail(sender, receiver string, body []byte) (mail []byte)

WriteMail writes an encoded mail.

Types

type MessageInput

type MessageInput struct {
	SenderMinDelay, SenderMaxDelay int32  // Mix settings
	Token                          []byte // Payment token
	NymAddress                     []byte // The nym-address of the recipient
	Message                        []byte // The message itself
	SMTPPort                       int    // Port on which to do SMTP. Can be empty
	SmartHost                      string // Server to which to send. Can be empty
	CACert                         []byte // CACert for TLS verification on SMTP
}

MessageInput contains everything to describe an outgoing message.

func (MessageInput) Create

func (mi MessageInput) Create() (messageOut *MessageOutput)

Create a message described in messageInput.

type MessageMarshalled

type MessageMarshalled []byte

MessageMarshalled contains a marshalled MessageOutput.

func (MessageMarshalled) Unmarshal

func (mm MessageMarshalled) Unmarshal() *MessageOutput

Unmarshal a MessageMarshalled.

type MessageMeta

type MessageMeta struct {
	MessageID                              []byte
	ReceiveTime, ReceiveTimeNano, ReadTime int64
	UserKey                                [ed25519.PublicKeySize]byte
}

MessageMeta contains metadata on a message.

func ListMessages

func ListMessages(privkey *[ed25519.PrivateKeySize]byte, lastMessageTime int64, server string, cacert []byte) (messages []MessageMeta, err error)

ListMessages gets the messages for account identified by privkey.

type MessageOutput

type MessageOutput struct {
	Message   []byte // Nil on success
	To        string // Empty on success
	From      string // Empty on success
	RevokeID  []byte // Set if develivery was attempted
	SMTPPort  int    // Port on which to do SMTP. Can be empty
	SmartHost string // Server to which to send. Can be empty
	CACert    []byte // CACert for TLS verification on SMTP
	Error     error  // Non-Nil on error
	Resend    bool   // Bool if sending might help
}

MessageOutput contains the result of a develivery attempt.

func (*MessageOutput) Deliver

func (mo *MessageOutput) Deliver() (messageOut *MessageOutput, err error)

Deliver a message countained in messageOutput. Can be used like this:

messageOut, err := messageIn.Create().Deliver()
for err!=nil && messageOut.Resend {
    cache := messageOut.Marshal()
    //...wait/stop/quit/sleep -> restart/wakeup
    messageOut, err = cache.UnMarshal().Deliver()
}
//...done

func (*MessageOutput) Marshal

func (mo *MessageOutput) Marshal() MessageMarshalled

Marshal a MessageOutput to a MessageMarshalled.

Jump to

Keyboard shortcuts

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