Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
5HT committed Aug 12, 2023
1 parent 553de49 commit a852872
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 243 deletions.
48 changes: 27 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
MAIL: Message Delivery System
=============================

TL;DR UNIX mail done right.
SYNRC ✉️ MAIL
=============

Open source lightweight Messaging Handling Service (MHS X.419)
and Interpersonal Messaging System (IPMS X.420).
MHS was a very open system, it was popular in the
early 1990s as a glue between proprietary
email systems, competing standards-based SMTP and X.400.
However, by 1996 it was clear that SMTP over the Internet
would take over this role. However MHS/IPMS is a faster
and has more telecomunication flavour than SMTP track of standards.
Now MHS is used in avionics and in Military Message Handling
System (MMHS, RFC 6477).

Features
--------

* Usage Example of N2O and KVS
* RocksDB support out of the box
* 150 LOC
* Databases: MNESIA, ROCKSDB
* Pub/Sub GPROC, SYN
* Formatters BASE64, BERT, BER/DER/PER [ASN.1]

Prerequisites
-------------
Intro
-----

* cmake (rocksdb)
MAIL is an QoS=1 example of messaging system built on top of:

Run
---
* SYN for publish subscribe message queue;
* N2O for protocols;
* KVS for data storage;
* ASN1 for encoding.

Before running, [fullchain.pem](./priv/ssl/fullchain.pem) certificate has to be added into a system.
It also contains simple textual WebSocket protocol for debugging purposes.
You can freely use this example with your favourite formatter for user terminal protocol.

```shell
```
$ mix deps.get
$ mix compile
$ iex -S mix
```

Then run `wscat --no-check -c https://localhost:8042/ws`

Credits
-------

* Maxim Sokhatsky [5HT](https://github.com/5HT)
* Vlad Ki [proger](https://github.com/proger)
* Maxim Sokhatsky

OM A HUM
12 changes: 6 additions & 6 deletions config/config.exs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use Mix.Config

config :n2o,
port: 8042,
proto: CHAT.Server,
port: 8043,
proto: MAIL.Server,
ws_services: [:chat,:crm],
mqtt_services: [],
pickler: :n2o_secret,
mq: :n2o_syn,
upload: "./priv/static",
protocols: [:n2o_heart, CHAT.TXT]
protocols: [:n2o_heart, MAIL.TXT]

config :kvs,
dba: :kvs_rocks,
dba_st: :kvs_st,
schema: [:kvs, :kvs_stream, CHAT]
dba: :kvs_mnesia,
dba_st: :kvs_stream,
schema: [:kvs, :kvs_stream]
129 changes: 38 additions & 91 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,122 +5,69 @@
<link rel="stylesheet" href="https://n2o.dev/zima.css" />
<link rel="stylesheet" href="https://n2o.dev/pro/pro.css" />
</head><body><nav>
<a href="https://erp.uno/en/">ERP</a>
<a href="https://mail.erp.uno" style="background:#ededed;">MAIL</a>
<a href="https://erp.uno">DEV</a>
<a href="https://mail.n2o.dev" style="background:#ededed;">MAIL</a>
</nav><header>
<a href="https://github.com/synrc/mail"><img src="https://openmoji.org/data/color/svg/2709.svg" /></a>
<h1>MAIL</h1>
</header><aside>
<article>
<section>
<h3>SYNOPSIS</h3>
<div>MAIL is a simple mailbox delivery system consists of:</div>
<div>
<ul><li>SYN for publish-subscribe message queue;
</li><li>N2O for protocols;</li><li>KVX for data storage;</li><li>and COWBOY for the web server.</li></ul></div>
<div>
MAIL uses WebSocket server and BER/BERT/TXT channel formatters.</div><br/>

<div>Open source lightweight Messaging Handling Service (MHS X.419)
and Interpersonal Messaging System (IPMS X.420).
MHS was a very open system, it was popular in the
early 1990s as a glue between proprietary
email systems, competing standards-based SMTP and X.400.
However, by 1996 it was clear that SMTP over the Internet
would take over this role. However MHS/IPMS is a faster
and has more telecomunication flavour than SMTP track of standards.
Now MHS is used in avionics and in Military Message Handling
System (MMHS, RFC 6477).</div><br>

<figure>
<code> $ wscat -c wss://n2o.im</code>
<code> $ mail-x420 mail.erp.uno</code>
</figure>
</section>
<section>
<h3><a href="https://n2o.dev">MODULES</a></h3>
<div><ul><li><a href="man/mail_txt.htm">TXT</a></li><li><a href="man/mail_ber.htm">BER</a></li><li><a href="man/mail.htm">mail</a></li><li><a href="man/mail_server.htm">SERVER</a></li><li><a href="man/csr.htm">CSR</a></li></ul></div>
<h3>SERVERS</h3>
<div><ul><li><a href="man/ms.htm">MS</a></li>
<li><a href="man/mts.htm">MTS</a></li>
<li><a href="man/mta.htm">MTA</a></li>
<li><a href="man/mail.htm">MAIL</a></li>
<li><a href="man/ipms.htm">IPMS</a></li></ul></div>
<br />
<div>
APR 2019 © <a href="https://github.com/5HT">5HT</a>
<a href="https://github.com/proger">proger</a> ISC<br />
VER 3.4
VER 7.8.1 2023 © <a href="https://github.com/5HT">5HT</a> DHARMA<br />
</div>
</section>
<section>
</section>
</article>
</aside><main>
<section>

<h3>TXT PROTO</h3>
<p>The implementation of TXT mail protocol is trying to be informative but
not excessive, it should take care of run-time edge
cases but not too stable. TXT protocol is dedicated
for demo purposes and doesn't support file upload and voice calls.
</p>
<figure><code>
$ wscat --no-check -c wss://mail-2.n2o.dev:8042/ws
> HELP
&lt; AUTH &lt;user&gt;
| SEND &lt;user&gt; &lt;msg&gt;
| BOX
| CUT &lt;id&gt;.
> AUTH maxim
&lt; USER maxim
> SEND vlad HELO
&lt; ERROR user doesn't exist.
> AUTH vlad
&lt; USER vlad
> SEND maxim OK
&lt; NOTIFY vlad:maxim:1556151953113322286:OK
&lt; ACK "1556151953113322286"
> AUTH maxim
&lt; USER maxim
> BOX
&lt; LIST
vlad:maxim:1556151953113322286:OK
> SEND maxim this is me
&lt; NOTIFY maxim:maxim:1556152151055371152:this is me
&lt; ACK "1556152151055371152"
> SEND maxim back again
&lt; NOTIFY maxim:maxim:1556152157283311935:back again
&lt; ACK "1556152157283311935"
> BOX
&lt; LIST
vlad:maxim:1556151953113322286:OK
maxim:maxim:1556152151055371152:this is me
maxim:maxim:1556152157283311935:back again
> CUT 1556152157283311935
&lt; ERASED 3
> BOX
&lt; LIST
>
</code></figure>
<h3>MTA</h3>
<h4>MTSE</h4>
<h4>RTSE</h4>
<h4>ACSE</h4>
</section>
<section>
<h3>BER ASN.1 PROTO</h3>
<figure><code>
ROSTER DEFINITIONS IMPLICIT TAGS ::= BEGIN

P2P ::= SEQUENCE { dst OCTET STRING }
MUC ::= SEQUENCE { dst OCTET STRING }
Adr ::= SEQUENCE { src OCTET STRING,
dst CHOICE { muc [0] MUC,
p2p [1] P2P } }
Pub ::= SEQUENCE { key OCTET STRING, adr Adr,
tag OCTET STRING, bin OCTET STRING }
Sub ::= SEQUENCE { key OCTET STRING, adr Adr }
Cut ::= SEQUENCE { id OCTET STRING }
N2O ::= SEQUENCE { tok OCTET STRING }
Ack ::= SEQUENCE { lex OCTET STRING }
Nak ::= SEQUENCE { key OCTET STRING }
Msg ::= CHOICE { n2o [0] N2O,
ack [1] Ack,
nak [2] Nak,
pub [3] Pub,
sub [4] Sub,
cut [5] Cut }
END
</code></figure>
<p>mail is written in Erlang/OTP and supports <a href="https://rocksdb.org">RocksDB</a> or
<a href="http://erlang.org/doc/man/mnesia.html">Mnesia</a> databases.</p>
<h3>MS</h3>
<h4>MSSE</h4>
<h4>MRSE</h4>
<h4>MASE</h4>
</section>
<section>
<h3>MTS</h3>
<h4>MSSE</h4>
<h4>MDSE-94</h4>
<h4>MASE-94</h4>
</section>
<section>
<h3>APP SPEC</h3>
<p><table cellspacing="10" valign="center"><tbody><tr><td>
<img src="https://n2o.dev/img/pdf.jpg" width="35" style="margin-bottom:-12px;margin-right:10px;" />
<a href="https://mail.n2o.dev/priv/doc/GUI.pdf">GUI.PDF</a></td></tr></tbody></table>
<br />
</p>
<h3>IPMS</h3>
<h4>IPMS</h4>
<h4>MAO</h4>
</section>
</main><footer>
Made with <span class="heart"></span> to N2O
Expand Down
2 changes: 2 additions & 0 deletions lib/MAIL.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ defmodule MAIL do
end
)

def init([]), do: {:ok, {{:one_for_one, 5, 10}, [ ] }}

def metainfo() do
KVS.schema(
name: :roster,
Expand Down
27 changes: 3 additions & 24 deletions lib/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,9 @@ defmodule MAIL.Application do
use N2O

def start(_, _) do
initialize()
Supervisor.start_link([], strategy: :one_for_one, name: MAIL.Supervisor)
:kvs.join
:n2o.start_ws
:supervisor.start_link({:local,MAIL},MAIL,[])
end

def env(_app) do
[
{:port, :application.get_env(:n2o, :port, 8042)}
]
end

def points() do
:cowboy_router.compile([
{:_,
[
{'/ws/[...]', :n2o_cowboy, []},
{'/bin/[...]', :cowboy_static, {:dir, "priv/storage", []}},
{'/app/[...]', :cowboy_static, {:dir, "priv/static", []}}
]}
])
end

def initialize() do
:cowboy.start_clear(:http, env(:mail), %{env: %{dispatch: points()}})
:kvs.join
:n2o.start_ws
end
end
73 changes: 0 additions & 73 deletions man/csr.htm

This file was deleted.

Loading

0 comments on commit a852872

Please sign in to comment.