minclient: github.com/katzenpost/minclient Index | Files | Directories

package minclient

import "github.com/katzenpost/minclient"

Package minclient provides a minimal Katzenpost client.

Index

Package Files

client.go connection.go pki.go send.go

Variables

var (
    // ErrNotConnected is the error returned when an operation fails due to the
    // client not currently being connected to the Provider.
    ErrNotConnected = errors.New("minclient/conn: not connected to the Provider")

    // ErrShutdown is the error returned when the connection is closed due to
    // a call to Shutdown().
    ErrShutdown = errors.New("shutdown requested")
)
var (

    // WarpedEpoch is a build time flag that accelerates the recheckInterval
    WarpedEpoch = "false"
)

type Client Uses

type Client struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

Client is a client instance.

func New Uses

func New(cfg *ClientConfig) (*Client, error)

New creates a new Client with the provided configuration.

func (*Client) ClockSkew Uses

func (c *Client) ClockSkew() time.Duration

ClockSkew returns the current best guess difference between the client's system clock and the network's global clock, rounded to the nearest second, as measured against the provider during the handshake process. Calls to this routine should not be made until the first `ClientConfig.OnConnFn(true)` callback.

func (*Client) ComposeSphinxPacket Uses

func (c *Client) ComposeSphinxPacket(recipient, provider string, surbID *[sConstants.SURBIDLength]byte, b []byte) ([]byte, []byte, time.Duration, error)

ComposeSphinxPacket is used to compose Sphinx packets.

func (*Client) CurrentDocument Uses

func (c *Client) CurrentDocument() *cpki.Document

CurrentDocument returns the current pki.Document, or nil iff one does not exist. The caller MUST NOT modify the returned object in any way.

func (*Client) ForceFetch Uses

func (c *Client) ForceFetch()

ForceFetch attempts to force an otherwise idle client to attempt to fetch the contents of the user's spool. This call has no effect if a connection is not established or if the connection is already in the middle of a fetch cycle, and should be considered a best effort operation.

func (*Client) GetPollInterval Uses

func (c *Client) GetPollInterval() time.Duration

func (*Client) SendCiphertext Uses

func (c *Client) SendCiphertext(recipient, provider string, surbID *[sConstants.SURBIDLength]byte, b []byte) ([]byte, time.Duration, error)

SendCiphertext sends the ciphertext b to the recipient/provider, with a SURB identified by surbID, and returns the SURB decryption key and total round trip delay.

func (*Client) SendSphinxPacket Uses

func (c *Client) SendSphinxPacket(pkt []byte) error

SendSphinxPacket sends the given Sphinx packet.

func (*Client) SendUnreliableCiphertext Uses

func (c *Client) SendUnreliableCiphertext(recipient, provider string, b []byte) error

SendUnreliableCiphertext sends the ciphertext b to the recipient/provider, in an unreliable manner. No notification of the packet being received will be generated by the recipient's provider.

func (*Client) SetPollInterval Uses

func (c *Client) SetPollInterval(interval time.Duration)

func (*Client) Shutdown Uses

func (c *Client) Shutdown()

Shutdown cleanly shuts down a given Client instance.

func (*Client) Wait Uses

func (c *Client) Wait()

Wait waits till the Client is terminated for any reason.

type ClientConfig Uses

type ClientConfig struct {
    // User is the user identifier used to connect to the Provider.
    User string

    // Provider is the provider identifier to connect to.
    Provider string

    // ProviderKeyPin is the optional pinned provider EdDSA signing key.
    // If specified, the client will refuse to accept provider descriptors
    // in PKI documents unless they are signed by the pinned key.
    ProviderKeyPin *eddsa.PublicKey

    // LinkKey is the user's ECDH link authentication private key.
    LinkKey *ecdh.PrivateKey

    // LogBackend is the logging backend to use for client logging.
    LogBackend *log.Backend

    // PKIClient is the PKI Document data source.
    PKIClient cpki.Client

    // OnConnFn is the callback function that will be called when the
    // connection status changes.  The error parameter will be nil on
    // successful connection establishment, otherwise it will be set
    // with the reason why a connection has been torn down (or a connect
    // attempt has failed).
    OnConnFn func(error)

    // OnMessageEmptyFn is the callback function that will be called
    // when the user's server side spool is empty.  This can happen
    // as the result of periodic background fetches.  Calls to the callback
    // that return an error will be treated as a signal to tear down the
    // connection.
    OnEmptyFn func() error

    // OnMessageFn is the callback function that will be called when
    // a message is retrived from the user's server side spool.  Callers
    // MUST be prepared to receive multiple callbacks with the same
    // message body.  Calls to the callback that return an error will
    // be treated as a signal to tear down the connection.
    OnMessageFn func([]byte) error

    // OnACKFn is the callback function that will be called when a
    // message CK is retreived from the user's server side spool.  Callers
    // MUST be prepared to receive multiple callbacks with the same
    // SURB ID and SURB ciphertext.  Calls to the callback that return
    // an error will be treated as a signal to tear down the connection.
    OnACKFn func(*[constants.SURBIDLength]byte, []byte) error

    // OnDocumentFn is the callback function taht will be called when a
    // new directory document is retreived for the current epoch.
    OnDocumentFn func(*cpki.Document)

    // DialContextFn is the optional alternative Dialer.DialContext function
    // to be used when creating outgoing network connections.
    DialContextFn func(ctx context.Context, network, address string) (net.Conn, error)

    // PreferedTransports is a list of the transports will be used to make
    // outgoing network connections, with the most prefered first.
    PreferedTransports []cpki.Transport

    // MessagePollInterval is the interval at which the server will be
    // polled for new messages if the queue is belived to be empty.
    // If left unset, an interval of 1 minute will be used.
    MessagePollInterval time.Duration

    // EnableTimeSync enables the use of skewed remote provider time
    // instead of system time when available.
    EnableTimeSync bool
}

ClientConfig is a client configuration.

type ConnectError Uses

type ConnectError struct {
    // Err is the original error that caused the connect attempt to fail.
    Err error
}

ConnectError is the error used to indicate that a connect attempt has failed.

func (*ConnectError) Error Uses

func (e *ConnectError) Error() string

Error implements the error interface.

type PKIError Uses

type PKIError struct {
    // Err is the original PKI error.
    Err error
}

PKIError is the error used to indicate PKI related failures.

func (*PKIError) Error Uses

func (e *PKIError) Error() string

Error implements the error interface.

type ProtocolError Uses

type ProtocolError struct {
    // Err is the original error that triggered connection termination.
    Err error
}

ProtocolError is the error used to indicate that the connection was closed due to wire protocol related reasons.

func (*ProtocolError) Error Uses

func (e *ProtocolError) Error() string

Error implements the error interface.

Directories

PathSynopsis
blockPackage block provides routines for manipulating End to End blocks.

Package minclient imports 22 packages (graph) and is imported by 2 packages. Updated 2019-04-24. Refresh now. Tools for package owners.