2018-03-05 12:19:04 +00:00
|
|
|
# Crockery design
|
|
|
|
|
2018-03-05 22:29:31 +00:00
|
|
|
## Overview
|
|
|
|
|
2018-03-05 12:19:04 +00:00
|
|
|
We need:
|
|
|
|
|
|
|
|
* SMTP server
|
|
|
|
* Receive emails -> middlewares -> storage
|
|
|
|
* https://github.com/emersion/go-smtp ?
|
|
|
|
* IMAP server
|
|
|
|
* Receive logins
|
|
|
|
* HTTP server
|
|
|
|
* Serve autodiscovery bumpf
|
|
|
|
* ActiveSync protocol
|
|
|
|
* Storage
|
2018-06-25 21:28:51 +01:00
|
|
|
* Give it a home directory. Stores Maildirs + settings DB + TLS
|
2018-03-05 12:19:04 +00:00
|
|
|
* Accounts
|
|
|
|
* Passwords!
|
|
|
|
* Emails
|
|
|
|
* TLS keys + certificates
|
2018-06-25 21:28:51 +01:00
|
|
|
* Emails go into Maildirs
|
|
|
|
* Search emails - some sort of inverted index necessary. One per maildir?
|
2018-03-05 12:19:04 +00:00
|
|
|
* https://github.com/blevesearch/bleve ?
|
2018-06-25 21:28:51 +01:00
|
|
|
* Settings DB should be a simple K-V store for accounts, passwords, etc. BoltDB?
|
2018-03-05 22:29:31 +00:00
|
|
|
* https://github.com/coreos/bbolt
|
|
|
|
* https://github.com/asdine/storm
|
|
|
|
|
|
|
|
## Database structure
|
|
|
|
|
2018-03-06 00:32:49 +00:00
|
|
|
I'm not sure what storm does under the hood. It seems clever. We have the
|
|
|
|
following, though:
|
|
|
|
|
|
|
|
* K-V store
|
|
|
|
* `config/domain`
|
|
|
|
* `domains/<domain>/config/cert`
|
|
|
|
* `domains/<domain>/config/key`
|
|
|
|
* ORM
|
|
|
|
* `Account`
|
|
|
|
* `Username`
|
|
|
|
* `Admin`
|
2018-03-06 01:06:47 +00:00
|
|
|
* `Wildcard`
|
2018-03-06 00:32:49 +00:00
|
|
|
* `PasswordHash`
|
2018-03-08 01:39:24 +00:00
|
|
|
* `Message`
|
|
|
|
* `ID`
|
|
|
|
* `Username`
|
|
|
|
* `Mailbox`
|
|
|
|
* `Header`
|
|
|
|
* `Body`
|
|
|
|
|
|
|
|
I don't seem to be able to get accounts for a list of usernames very easily, or
|
|
|
|
indexed-ly.
|
|
|
|
|
|
|
|
The message body is being stored inefficiently (json []byte, so base64-encoded)
|
|
|
|
|
|
|
|
Message username and mailbox are indexed, but is that good enough? Perhaps we
|
|
|
|
should have a bucket per mailbox or something?
|
2018-06-25 21:28:51 +01:00
|
|
|
|
|
|
|
TODO: rewrite this (and the code) to make Maildir into a thing
|