Skip to content

LordOS — a free, fast and secure GNU/Linux distribution based on Debian, with its own desktop environment: display server and Wayland compositor in C, a React UI engine on QuickJS, and private native apps.

1.6 KB
Raw Blame
/* proto.h — channel between lord-server and lord-maild (see docs/MAIL.md).
 *
 * The same framing as lord-doc (doc/wire.h): a SOCK_SEQPACKET socketpair on fd 3, each message a
 * DocHdr + JSON (+ up to DOC_MAX_FDS-1 descriptors via SCM_RIGHTS; large JSON goes in a sealed
 * memfd). Requests carry an id; replies use the same id; events use id 0.
 *
 * lord-maild has no way to open a socket (seccomp). To reach a server it sends MR_CONNECT
 * {"host","port"}; lord-server answers MQ_SOCK with a connected TCP socket, but only if that
 * endpoint is one of the configured accounts (or a remote-image host the user just allowed). */
#ifndef LORD_MAIL_PROTO_H
#define LORD_MAIL_PROTO_H

/* lord-server → lord-maild */
enum {
    MQ_INIT = 1,        /* {"config":{…},"zone":"Europe/Madrid","lang":"es"} + fd of the cache folder */
    MQ_REQ,             /* {"op":…} (+ fds of files to attach / photos) */
    MQ_SOCK,            /* reply to MR_CONNECT: 1 fd, or {"error":"denied"|"dns"|"connect"} */
    MQ_CONFIG,          /* the accounts file changed: {"config":{…}} */
};

/* lord-maild → lord-server */
enum {
    MR_DONE = 1,        /* request finished: JSON result */
    MR_ERR,             /* request failed: {"error":"code","detail":"…"} */
    MR_EVT,             /* event (id 0): {"ev":"new"|"sync"|"changed"|"need-auth"|"cert"|"error"|…} */
    MR_CONNECT,         /* {"host","port"}: please connect me (id = connect id) */
    MR_IMG,             /* request finished with an image: {"w","h"} + sealed memfd of w*h ARGB32 */
};

#define MAIL_MAX_ACCOUNTS 32
#define MAIL_CONFIG_MAX   (512 * 1024)

#endif