mailserver

package
v0.26.0-alpha.19 Latest Latest
Warning

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

Go to latest
Published: May 25, 2019 License: MPL-2.0 Imports: 23 Imported by: 0

README

MailServer

This document is meant to collect various information about our MailServer implementation.

Syncing between mail servers

It might happen that one mail server is behind other due to various reasons like a machine being down for a few minutes etc.

There is an option to fix such a mail server:

  1. SSH to a machine where this broken mail server runs,
  2. Add a mail server from which you want to sync:
# sudo might be not needed in your setup
$ echo '{"jsonrpc":"2.0","method":"admin_addPeer", "params": ["enode://c42f368a23fa98ee546fd247220759062323249ef657d26d357a777443aec04db1b29a3a22ef3e7c548e18493ddaf51a31b0aed6079bd6ebe5ae838fcfaf3a49@206.189.243.162:30504"], "id":1}' | \
    sudo socat -d -d - UNIX-CONNECT:/docker/statusd-mail/data/geth.ipc
  1. Mark it as a trusted peer:
# sudo might be not needed in your setup
$ echo '{"jsonrpc":"2.0","method":"shh_markTrustedPeer", "params": ["enode://c42f368a23fa98ee546fd247220759062323249ef657d26d357a777443aec04db1b29a3a22ef3e7c548e18493ddaf51a31b0aed6079bd6ebe5ae838fcfaf3a49@206.189.243.162:30504"], "id":1}' | \
    sudo socat -d -d - UNIX-CONNECT:/docker/statusd-mail/data/geth.ipc
  1. Finally, trigger the sync command:
# sudo might be not needed in your setup
$ echo '{"jsonrpc":"2.0","method":"shhext_syncMessages","params":[{"mailServerPeer":"enode://c42f368a23fa98ee546fd247220759062323249ef657d26d357a777443aec04db1b29a3a22ef3e7c548e18493ddaf51a31b0aed6079bd6ebe5ae838fcfaf3a49@206.189.243.162:30504", "to": 1550479953, "from": 1550393583}],"id":1}' | \
    sudo socat -d -d - UNIX-CONNECT:/docker/statusd-mail/data/geth.ipc
Debugging

To verify that your mail server received any responses, watch logs and seek for logs like this:

INFO [02-18|09:08:54.257] received sync response count=217 final=false err= cursor=[]

And it should finish with:

INFO [02-18|09:08:54.431] received sync response count=0 final=true err= cursor=[]

Documentation

Index

Constants

View Source
const (
	// DBKeyLength is a size of the envelope key.
	DBKeyLength  = common.HashLength + timestampLength + whisper.TopicLength
	CursorLength = common.HashLength + timestampLength
)

Variables

View Source
var (
	// ErrInvalidByteSize is returned when DBKey can't be created
	// from a byte slice because it has invalid length.
	ErrInvalidByteSize = errors.New("byte slice has invalid length")
)

Functions

This section is empty.

Types

type CursorQuery

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

type DB

type DB interface {
	Close() error
	// SaveEnvelope stores an envelope
	SaveEnvelope(*whisper.Envelope) error
	// GetEnvelope returns an rlp encoded envelope from the datastore
	GetEnvelope(*DBKey) ([]byte, error)
	// Prune removes envelopes older than time
	Prune(time.Time, int) (int, error)
	// BuildIterator returns an iterator over envelopes
	BuildIterator(query CursorQuery) (Iterator, error)
}

DB is an interface to abstract interactions with the db so that the mailserver is agnostic to the underlaying technology used

type DBKey

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

DBKey key to be stored in a db.

func NewDBKey

func NewDBKey(timestamp uint32, topic whisper.TopicType, h common.Hash) *DBKey

NewDBKey creates a new DBKey with the given values.

func (*DBKey) Bytes

func (k *DBKey) Bytes() []byte

Bytes returns a bytes representation of the DBKey.

func (*DBKey) Cursor

func (k *DBKey) Cursor() []byte

func (*DBKey) EnvelopeHash

func (k *DBKey) EnvelopeHash() common.Hash

func (*DBKey) Topic

func (k *DBKey) Topic() whisper.TopicType

type Iterator

type Iterator interface {
	Next() bool
	DBKey() (*DBKey, error)
	Release()
	Error() error
	GetEnvelope(bloom []byte) ([]byte, error)
}

type LevelDB

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

func NewLevelDB

func NewLevelDB(config *params.WhisperConfig) (*LevelDB, error)

func (*LevelDB) BuildIterator

func (db *LevelDB) BuildIterator(query CursorQuery) (Iterator, error)

Build iterator returns an iterator given a start/end and a cursor

func (*LevelDB) Close

func (db *LevelDB) Close() error

func (*LevelDB) GetEnvelope

func (db *LevelDB) GetEnvelope(key *DBKey) ([]byte, error)

GetEnvelope get an envelope by its key

func (*LevelDB) Prune

func (db *LevelDB) Prune(t time.Time, batchSize int) (int, error)

Prune removes envelopes older than time

func (*LevelDB) SaveEnvelope

func (db *LevelDB) SaveEnvelope(env *whisper.Envelope) error

SaveEnvelope stores an envelope in leveldb and increments the metrics

type LevelDBIterator

type LevelDBIterator struct {
	iterator.Iterator
}

func (*LevelDBIterator) DBKey

func (i *LevelDBIterator) DBKey() (*DBKey, error)

func (*LevelDBIterator) GetEnvelope

func (i *LevelDBIterator) GetEnvelope(bloom []byte) ([]byte, error)

type MessagesRequestPayload

type MessagesRequestPayload struct {
	// Lower is a lower bound of time range for which messages are requested.
	Lower uint32
	// Upper is a lower bound of time range for which messages are requested.
	Upper uint32
	// Bloom is a bloom filter to filter envelopes.
	Bloom []byte
	// Limit is the max number of envelopes to return.
	Limit uint32
	// Cursor is used for pagination of the results.
	Cursor []byte
	// Batch set to true indicates that the client supports batched response.
	Batch bool
}

MessagesRequestPayload is a payload sent to the Mail Server.

type PostgresDB

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

func NewPostgresDB

func NewPostgresDB(config *params.WhisperConfig) (*PostgresDB, error)

func (*PostgresDB) BuildIterator

func (i *PostgresDB) BuildIterator(query CursorQuery) (Iterator, error)

func (*PostgresDB) Close

func (i *PostgresDB) Close() error

func (*PostgresDB) GetEnvelope

func (i *PostgresDB) GetEnvelope(key *DBKey) ([]byte, error)

func (*PostgresDB) Prune

func (i *PostgresDB) Prune(t time.Time, batch int) (int, error)

func (*PostgresDB) SaveEnvelope

func (i *PostgresDB) SaveEnvelope(env *whisper.Envelope) error

type WMailServer

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

WMailServer whisper mailserver.

func (*WMailServer) Archive

func (s *WMailServer) Archive(env *whisper.Envelope)

Archive a whisper envelope.

func (*WMailServer) Close

func (s *WMailServer) Close()

Close the mailserver and its associated db connection.

func (*WMailServer) DeliverMail

func (s *WMailServer) DeliverMail(peer *whisper.Peer, request *whisper.Envelope)

DeliverMail sends mail to specified whisper peer.

func (*WMailServer) Init

func (s *WMailServer) Init(shh *whisper.Whisper, config *params.WhisperConfig) error

Init initializes mailServer.

func (*WMailServer) SyncMail

func (s *WMailServer) SyncMail(peer *whisper.Peer, request whisper.SyncMailRequest) error

SyncMail syncs mail servers between two Mail Servers.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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