about summary refs log tree commit diff
path: root/docs/man/spacecookie.json.5
blob: c00ae9a160ac7e159611471f7d95a6c54d37a905 (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
.Dd $Mdocdate$
.Dt SPACECOOKIE.JSON 5
.Os
.Sh NAME
.Nm spacecookie.json
.Nd configuration file for
.Xr spacecookie 1
.Sh DESCRIPTION
The
.Xr 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.
.Ss REQUIRED SETTINGS
The following settings must be part of every configuration file as there
is no default or fallback value for them.
.Bl -tag -width 2n -offset 0n
.It Sy hostname
Describes the public server name
.Xr spacecookie 1
is reachable through, i. e. the address clients will use to connect to it.
It will be used to populate gopher menus with the correct server name, so
follow up requests from clients actually reach the correct server.
For testing purposes, it can be useful to set it to
.Ql localhost .
.Pp
Type: string.
.It Sy root
Sets the the directory
.Xr spacecookie 1
should serve via gopher.
All gopher requests will be resolved to files or directories under that root.
Files and directories will be served to users if no component of the resolved
path starts with a dot and they are readable for the user
.Xr spacecookie 1
is running as.
.Pp
Type: string.
.El
.Ss OPTIONAL SETTINGS
The following settings are optional, meaning there is either a default value
or an obvious default behavior if they are not given.
.Bl -tag -width 2n -offset 0n
.It Sy listen
Describes the address and port
.Xr spacecookie 1
should listen on.
Both aspects can be controlled individually by the two optional fields
described below.
.Pp
Type: object.
.Bl -tag -offset 0n -width 2n
.It Sy port
Port to listen on.
The well-known port for gopher is
.Ms 70 .
.Pp
If
.Xr 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
.Xr 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
.Xr systemd 1
is doing.
.Pp
Type: number.
Default:
.Ql 70 .
.It Sy addr
Address to listen and accept gopher requests on.
In contrast to
.Sy hostname ,
this option controls the socket setup and not what is used in gopher menus.
This option is especially useful to limit the addresses
.Xr spacecookie 1
will listen on since it listens on all available addresses
for incoming requests by default, i. e.
.Sy INADDR_ANY .
For example,
.Ql ::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
.Xr tor 1
and want to avoid leaking the server's identity.
.Pp
When given,
.Xr getaddrinfo 3
is used to resolve the given hostname or parse the given IP address and
.Xr spacecookie 1
will only listen on the resulting address(es).
Note that
.Sy IPV6_V6ONLY
is always disabled, so, if possible, both the resulting v4 and v6 address will be used.
.Pp
If
.Xr systemd.socket 5
activation is used, this setting has no effect.
.Pp
Type: string.
.El
.It Sy user
The name of the user spacecookie should run as.
When this option is given and not
.Ql null ,
.Xr spacecookie 1
will call
.Xr setuid 2
and
.Xr 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
.Xr 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
.Xr systemd 1
socket activation.
See the
.Xr spacecookie 1
man page for details on setting this up.
.Pp
Type: string.
Default:
.Ql null .
.It Sy log
Allows to customize the logging output of
.Xr spacecookie 1
to
.Sy stderr .
.Pp
Type: object.
.Bl -tag -offset 0n -width 2n
.It Sy enable
Wether to enable logging.
.Pp
Type: bool.
Default:
.Ql true .
.It Sy hide-ips
Wether to hide IP addresses of clients in the log output.
If enabled,
.Ql [redacted]
is displayed instead of client's IP addresses to avoid writing personal
information to disk.
.Pp
Type: bool.
Default:
.Ql true .
.It Sy hide-time
If this is set to
.Ql true ,
.Xr 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
.Xr systemd 1 .
.Pp
Type: bool.
Default:
.Ql false .
.It Sy level
Controls verbosity of logging.
It is recommended to either use
.Qq warn
or
.Qq info
since
.Qq error
hides warnings that are indicative of configuration issues.
.Pp
Type: either
.Qq error ,
.Qq warn
or
.Qq info .
Default:
.Qq info .
.El
.El
.Ss DEPRECATED SETTINGS
The following settings are only supported for backwards compatibility
and should be replaced in existing configurations in the way described
for each respectively.
.Pp
.Bl -tag -width 2n -offset 0n
.It Sy port
The top level
.Sy port
is an alias for the setting of the same name inside the
.Sy listen
object and should be replaced by the latter.
.El
.Sh EXAMPLE
The following configuration equates to the default behavior of
.Xr spacecookie 1
for all optional settings, although it is much verboser than necessary.
.Bd -literal -offset Ds
{
  "hostname" : "localhost",
  "root" : "/srv/gopher",
  "listen" : {
    "addr" : "::",
    "port" : 70
  },
  "user" : null,
  "log" : {
    "enable" : true,
    "hide-ips" : true,
    "hide-time" : false,
    "level" : "info"
  }
}
.Ed
.Pp
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
.Xr tor 1
allows free mapping from local to exposed ports, so
.Xr spacecookie 1
can be started as a normal user.
.Bd -literal -offset Ds
{
  "hostname": "myonionservicehash.onion",
  "root": "/srv/onion-gopher",
  "listen": {
    "addr": "::1",
    "port": 7070
  },
  "log": {
    "enable": false
  }
}
.Ed
.Pp
If you are not using socket activation for running a gopher server on the
well-known port for gopher, a config like this is apporpriate, provided the
user
.Ql gopher
exists:
.Bd -literal -offset Ds
{
  "hostname": "example.org",
  "root": "/srv/gopher",
  "user": "gopher"
}
.Ed
.Pp
For a
.Xr systemd.socket 5
based setup, the
.Ql user
field should be omitted and
.Xr spacecookie 1
started as the target user directly in the
.Xr systemd.service 5
file.
.Sh SEE ALSO
.Xr spacecookie 1 .
.Sh AUTHORS
The
.Nm
documentation has been written by
.An sternenseemann ,
.Mt sterni-spacecookie@systemli.org .