status-go/mailserver
Andrea Maria Piana cef7f367ab Add topic negotiation
This commit add topic negotiation to the protocol.

On receiving a message from a client with version >= 1, we will generate
a shared key using Diffie-Hellman. We will record also which
installationID has sent us a message.

This key will be passed back to the above layer, which will then use to
start listening to a whisper topic (the `chat` namespace has no
knowledge of whisper).

When sending a message to a set of InstallationIDs, we check whether we
have agreed on a topic with all of them, and if so, we will send on this
separate topic, otherwise we fallback on discovery.

This change is backward compatible, as long as there is no downgrade of
the app on the other side.

A few changes:

* Factored out the DB in a separate namespace as now it is
being used by multiple services (TopicService and EncryptionService).

* Factored out multidevice management in a separate namespace

* Moved all the test to test the whole protoocl rather than just the encryption service

* Moved all the filter management in status-go
2019-06-19 17:38:45 +02:00
..
migrations Add topic negotiation 2019-06-19 17:38:45 +02:00
registry Add network incentivisation service (#1452) 2019-04-29 14:05:49 +02:00
README.md add README for mailserver syncing (#1377) 2019-02-19 19:09:55 +01:00
cleaner.go Add postgres 2019-05-15 11:01:34 +02:00
cleaner_test.go Add postgres 2019-05-15 11:01:34 +02:00
db_key.go Publish rlp.RawValue instead of envelope (#1459) 2019-05-09 12:58:02 +02:00
db_key_test.go Publish rlp.RawValue instead of envelope (#1459) 2019-05-09 12:58:02 +02:00
limiter.go mailserver: refactor mailserver's rate limiter (#1341) 2019-01-10 17:07:16 +01:00
limiter_test.go mailserver: refactor mailserver's rate limiter (#1341) 2019-01-10 17:07:16 +01:00
mailserver.go Add postgres 2019-05-15 11:01:34 +02:00
mailserver_db.go Add postgres 2019-05-15 11:01:34 +02:00
mailserver_db_leveldb.go Add postgres 2019-05-15 11:01:34 +02:00
mailserver_db_postgres.go migrate to go 1.12 and go modules 2019-06-12 13:12:00 +02:00
mailserver_test.go Add postgres 2019-05-15 11:01:34 +02:00
metrics.go expose more logs and metrics in DeliverMail (#1398) 2019-02-27 15:30:08 +01:00
request.go Fix cursor encoding (#1308) 2018-12-11 11:23:47 +01:00

README.md

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=[]