summaryrefslogtreecommitdiffstats
path: root/docs/architecture.md
blob: 12a83da4c9dacff37bc3f0d035ce25d67b28c4ec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# N2Usenet Architecture

## Components

- `cmd/n2usenet`: process entrypoint, lifecycle, HTTP server.
- `cmd/n2u-check`: SMTP diagnostic helper for direct or SOCKS5-routed checks.
- `internal/config`: environment-driven configuration.
- `internal/nymclient`: optional managed `nym-socks5-client` lifecycle.
- `internal/socks5`: minimal SOCKS5 dialer used for Nym transport.
- `internal/smtpclient`: SMTP + STARTTLS sender over an injected dialer.
- `internal/transporthealth`: cached background readiness state for the complete
  SOCKS, SMTP, TLS, and AUTH path.
- `internal/submit`: HTTP handlers, validation, message construction.
- `internal/storage`: replay cache for Hashcash tokens.
- `internal/assets/web`: embedded template and browser assets.

## Privacy Boundary

The HTTPS server necessarily receives browser connections. It should not persist
source IPs, user agents, raw posts, or submitted identities. Operational logs
must stay generic. Rate limiting uses an in-memory keyed hash of the source
address and resets on process restart. Hashcash replay protection is also
memory-only. The browser-side identity, signature inputs, and compose fields are
kept only in tab memory and cleared after successful send.

## Transport Boundary

The app never dials an SMTP target directly when `N2U_NYM_ENABLED=true`. All
SMTP traffic goes through `N2U_NYM_SOCKS`, normally provided by
`nym-socks5-client`. The MTA boundary uses STARTTLS plus SMTP AUTH. Credentials
are loaded from a root-managed file, not embedded in source or command-line
arguments. SMTP AUTH, the SMTP envelope sender, and the RFC 5322 `Sender:`
header use the fixed N2Usenet service account. The public RFC 5322 `From:`
header instead contains the complete profile identity, `username <email>`, so
Mail2News and newsreaders do not replace it with the transport account. This
profile address is a pseudonymous claim bound to the VFACE tuple and public
key, not verification that the author controls the address domain.

The intended posting chain is:

```text
Browser -> HTTPS n2usenet.virebent.art
N2Usenet -> Nym SOCKS5/requester
Nym requester -> 51.178.55.22:587 SMTP with STARTTLS + AUTH
                (TLS name mail.virebent.art)
mail.virebent.art Postfix -> SPF/DKIM/DMARC signing and relay
mail2news@mail2news.tcpreset.net -> Mail2News gateway
Mail2News -> Tor SOCKS
Mail2News -> peannyjkqwqfynd24p6dszvtchkq7hfkwymi5by5y332wmosy5dwfaqd.onion:119 NNTP
TCPReset INN -> news.tcpreset.net
```

Nym and Tor protect different transport segments. Nym carries the
N2Usenet-to-MTA SMTP connection, with STARTTLS providing authenticated TLS
inside that path. After Postfix relays the message to Mail2News, Mail2News uses
Tor for the final connection to the onion NNTP endpoint. The final Usenet
article is public.

## Deployment Boundary

The current onion PHP app remains deployed under Onion Newsreader `/compose/`.
This app is a separate HTTP service intended to be reverse-proxied by the
public HTTPS frontend for `https://n2usenet.virebent.art`, Apache on `pietro`
in the current production deployment.

Current production split:

- `victor` runs the dedicated Nym network requester and the authenticated
  Postfix submission endpoint.
- `pietro` runs the public HTTPS app and the local `nym-socks5-client`.

The SOCKS destination is the MTA's global IPv4 address because local hostname
resolution on `victor` also returns interface-local addresses that the Nym
requester correctly rejects. TLS identity verification still uses
`mail.virebent.art`.

## Operational Readiness

`/healthz` is a liveness endpoint and does not imply that Nym can deliver.
`/readyz` exposes only the cached result of a periodic transport probe. The
probe performs SOCKS connection, SMTP greeting, STARTTLS, TLS verification,
post-TLS EHLO, and SMTP AUTH, then quits before `MAIL FROM`; it never sends a
message. Keeping the probe out of the request path prevents public health
requests from consuming Nym bandwidth.

Nym gateway registrations are time-limited. The deployment timer runs once a
day and renews the active gateway only when it is within 24 hours of expiry.
The rotation is performed with the application and SOCKS services stopped,
backed up first, and accepted only after the same no-mail transport probe
succeeds.