Browse code

WIP: Add implementation

Robert Cranston authored on 17/06/2023 18:12:27
Showing 1 changed files
... ...
@@ -6,6 +6,132 @@ Interact with [NearlyFreeSpeech.NET][]'s [API][] from the command line.
6 6
 [NearlyFreeSpeech.NET]: https://www.nearlyfreespeech.net
7 7
 [API]: https://en.wikipedia.org/wiki/API
8 8
 
9
+## Goals
10
+
11
+`nfsn-utils` has three main goals:
12
+
13
+1.  **Be portable** (even to things like [routers][]).
14
+
15
+    POSIX shell is used as glue for standard utilities. See
16
+    [dependencies](#dependencies).
17
+
18
+2.  **Be modular** where it makes sense.
19
+
20
+    [`nfsn-send`](#nfsn-send) is a general purpose [NearlyFreeSpeech.NET][]
21
+    [API][] wrapper. [`nfsn-dns-update`](#nfsn-dns-update) is a general purpose
22
+    [NearlyFreeSpeech.NET][] DNS update utility.
23
+
24
+3.  **Be opinionated with sane defaults** where it makes sense.
25
+
26
+    The smaller utilities assume things like that you want to use [standard
27
+    email addresses][].
28
+
29
+4.  **Be easily auditable**.
30
+
31
+    The scripts are well abstracted and no more than about 100 lines of code.
32
+
33
+[routers]: https://openwrt.org
34
+[standard email addresses]: https://www.ietf.org/rfc/rfc2142.txt
35
+
36
+## Prerequisites
37
+
38
+### API key
39
+
40
+As described in the [NearlyFreeSpeech.NET][] [documentation][], one needs to
41
+submit a [free assistance request][] to obtain an API key.
42
+
43
+Place the credentials in the environment variables `NFSN_LOGIN` and
44
+`NFSN_API_KEY` or in the file `./.nfsn-api` or `$HOME/.nfsn-api` (location
45
+overridable by the `NFSN_CREDENTIALS_PATH` environment variable). This file
46
+should be a JSON file consisting of an object with the keys `login` and
47
+`api-key`. (The file format and default location is compatible with
48
+[WebService::NFSN][] and [python-nfsn][].)
49
+
50
+[documentation]: https://members.nearlyfreespeech.net/wiki/API/Introduction
51
+[free assistance request]: https://members.nearlyfreespeech.net/support/assist?tag=apikey
52
+[WebService::NFSN]: https://metacpan.org/pod/WebService::NFSN#INTERFACE
53
+[python-nfsn]: https://github.com/ktdreyer/python-nfsn#authentication
54
+
55
+### Dependencies
56
+
57
+-  Unix-like environment (in particular, `/dev/urandom`).
58
+-  [POSIX utilities][] with `date` supporting `+%s` (such as GNU `date`).
59
+-  `sha1sum` (for instance, the one in `coreutils`).
60
+-  [curl][].
61
+-  [jq][].
62
+-  `certbot` (only needed for `nfsn-dns-certbot*`).
63
+
64
+[POSIX utilities]: http://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html
65
+[curl]: https://curl.haxx.se
66
+[jq]: https://github.com/stedolan/jq
67
+
68
+## Included programs
69
+
70
+Dependency graph:
71
+
72
+![included programs](doc/included-programs.dot.png)
73
+
74
+### `nfsn-send`
75
+
76
+Wraps the Requests, Responses and Authentication described in the
77
+[NearlyFreeSpeech.NET][] [documentation][].
78
+
79
+### `nfsn-dns-update`
80
+
81
+Updates several DNS records and outputs what data was actually changed.
82
+
83
+### `nfsn-dns-a`
84
+
85
+Updates DNS [A][] records, used to map hostnames to an IPv4 address.
86
+
87
+[A]: https://en.wikipedia.org/wiki/List_of_DNS_record_types#A
88
+
89
+### `nfsn-dns-spf`
90
+
91
+Updates DNS [SPF][] records, used for email authorization (specifying who is
92
+allowed to send mail from a domain).
93
+
94
+[SPF]: https://en.wikipedia.org/wiki/Sender_Policy_Framework
95
+
96
+### `nfsn-dns-dkim`
97
+
98
+Updates DNS [DKIM][] records, used for email authentication (using digital
99
+signatures).
100
+
101
+[DKIM]: https://en.wikipedia.org/wiki/DomainKeys_Identified_Mail
102
+
103
+### `nfsn-dns-dmarc`
104
+
105
+Updates DNS [DMARC][] records, extending [SPF][] and [DKIM][] by specifying
106
+failure policy and reporting.
107
+
108
+See also the [dmarc.org FAQ][].
109
+
110
+[DMARC]: https://en.wikipedia.org/wiki/DMARC
111
+[dmarc.org FAQ]: https://dmarc.org/wiki/FAQ#Sender_Questions
112
+
113
+### `nfsn-dns-certbot*`
114
+
115
+`nfsn-dns-certbot` calls [certbot][] (the [Electronic Frontier Foundation][]'s
116
+(EFF) [Let's Encrypt][] client, for getting HTTPS certificates) in [manual
117
+mode][] to make it use `nfsn-utils` to update DNS records in order to fullfill
118
+the [`dns-01` challenge][]. It does this by registering
119
+`nfsn-dns-certbot-{auth,cleanup}` as [hooks][].
120
+
121
+By default, the `auth` hook sleeps for 30 seconds to let the DNS records
122
+propagate. This can be overridden with the environment variable
123
+`NFSN_DNS_CERTBOT_AUTH_SLEEP`.
124
+
125
+Given that `nfsn-dns-certbot` has successfully run once, running `certbot
126
+renew` will suffice to renew the certificates.
127
+
128
+[certbot]: https://certbot.eff.org
129
+[Electronic Frontier Foundation]: https://www.eff.org
130
+[Let's Encrypt]: https://letsencrypt.org
131
+[manual mode]: https://certbot.eff.org/docs/using.html#manual
132
+[`dns-01` challenge]: https://tools.ietf.org/html/draft-ietf-acme-acme-03#section-7.4
133
+[hooks]: https://certbot.eff.org/docs/using.html#hooks
134
+
9 135
 ## License
10 136
 
11 137
 Licensed under the [ISC License][] unless otherwise noted, see the
Browse code

Add license

Robert Cranston authored on 17/06/2023 17:51:13
Showing 1 changed files
... ...
@@ -5,3 +5,11 @@ Interact with [NearlyFreeSpeech.NET][]'s [API][] from the command line.
5 5
 [`nfsn-utils`]: https://git.rcrnstn.net/rcrnstn/nfsn-utils
6 6
 [NearlyFreeSpeech.NET]: https://www.nearlyfreespeech.net
7 7
 [API]: https://en.wikipedia.org/wiki/API
8
+
9
+## License
10
+
11
+Licensed under the [ISC License][] unless otherwise noted, see the
12
+[`LICENSE`][] file.
13
+
14
+[ISC License]: https://choosealicense.com/licenses/isc
15
+[`LICENSE`]: LICENSE
Browse code

Add readme

Robert Cranston authored on 17/06/2023 17:51:04
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,7 @@
1
+# [`nfsn-utils`][]
2
+
3
+Interact with [NearlyFreeSpeech.NET][]'s [API][] from the command line.
4
+
5
+[`nfsn-utils`]: https://git.rcrnstn.net/rcrnstn/nfsn-utils
6
+[NearlyFreeSpeech.NET]: https://www.nearlyfreespeech.net
7
+[API]: https://en.wikipedia.org/wiki/API