SPACECOOKIE.JSON(5) | File Formats Manual | SPACECOOKIE.JSON(5) |
spacecookie.json
—
configuration file for
spacecookie(1)
The spacecookie(1) config file is a JSON file which contains a single object. The allowed fields representing individual settings and their effect are explained below.
The following settings must be part of every configuration file as there is no default or fallback value for them.
localhost
’.
Type: string.
Type: string.
The following settings are optional, meaning there is either a default value or an obvious default behavior if they are not given.
Type: object.
If systemd.socket(5) activation is used, this setting will have no effect on the actual port the socket is bound to since this is done by systemd(1). It will then only be used to display the server's port in gopher menus for subsequent requests, so make sure whatever is set here matches what systemd(1) is doing.
Type: number. Default:
‘70
’.
::1
’ can be used
to listen on the link-local addresses only which comes in handy if you
are setting up a onion service using
tor(1)
and want to avoid leaking the server's identity.
When given, getaddrinfo(3) is used to resolve the given hostname or parse the given IP address and spacecookie(1) will only listen on the resulting address(es). Note that IPV6_V6ONLY is always disabled, so, if possible, both the resulting v4 and v6 address will be used.
If systemd.socket(5) activation is used, this setting has no effect.
Type: string.
null
’,
spacecookie(1) will call
setuid(2)
and
setgid(2)
after setting up its socket to switch to that user and their primary
group. Note that this is only necessary to set if
spacecookie(1) is started
with root privileges in the first place as the binary shouldn't have the
setuid bit set. An alternative to starting the daemon as root, so it can
bind its socket to a well-known port, is to use
systemd(1)
socket activation. See the
spacecookie(1) man page for
details on setting this up.
Type: string. Default:
‘null
’.
Type: object.
Type: bool. Default:
‘true
’.
[redacted]
’ is displayed
instead of client's IP addresses to avoid writing personal information
to disk.
Type: bool. Default:
‘true
’.
true
’,
spacecookie(1) will not
print timestamps at the beginning of every log line. This is useful if
you use an additional daemon or tool to take care of logs which
records timestamps automatically, like
systemd(1).
Type: bool. Default:
‘false
’.
Type: either "error", "warn" or "info". Default: "info".
The following settings are only supported for backwards compatibility and should be replaced in existing configurations in the way described for each respectively.
The following configuration equates to the default behavior of spacecookie(1) for all optional settings, although it is much verboser than necessary.
{ "hostname" : "localhost", "root" : "/srv/gopher", "listen" : { "addr" : "::", "port" : 70 }, "user" : null, "log" : { "enable" : true, "hide-ips" : true, "hide-time" : false, "level" : "info" } }
This configuration is suitable for running as an onion service: It disables logging completely to not collect any kind of meta data about users and only listens on the link-local address to avoid leaking its identity. We can also use a non-well-known port since tor(1) allows free mapping from local to exposed ports, so spacecookie(1) can be started as a normal user.
{ "hostname": "myonionservicehash.onion", "root": "/srv/onion-gopher", "listen": { "addr": "::1", "port": 7070 }, "log": { "enable": false } }
If you are not using socket activation for running a gopher server
on the well-known port for gopher, a config like this is appropriate,
provided the user ‘gopher
’ exists:
{ "hostname": "example.org", "root": "/srv/gopher", "user": "gopher" }
For a
systemd.socket(5)
based setup, the ‘user
’ field should
be omitted and spacecookie(1)
started as the target user directly in the
systemd.service(5)
file.
The spacecookie.json
documentation has
been written by sternenseemann,
sterni-spacecookie@systemli.org.
April 18, 2023 | Nixpkgs |