snac.8 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993
  1. .Dd $Mdocdate$
  2. .Dt SNAC 8
  3. .Os
  4. .Sh NAME
  5. .Nm snac
  6. .Nd snac administration
  7. .Sh DESCRIPTION
  8. The
  9. .Nm
  10. daemon processes messages from other servers in the Fediverse
  11. using the ActivityPub protocol.
  12. .Pp
  13. This is the admin manual. For user operation, see
  14. .Xr snac 1 .
  15. For file and data formats, see
  16. .Xr snac 5 .
  17. .Ss Special cares about your snac you must know beforehand
  18. .Nm
  19. makes heavy use of hard links and link reference counts for its work, so
  20. don't even think of using it on a filesystem that doesn't support this
  21. feature. Most UNIX-like operating systems (Linux, the BSDs, the old DEC
  22. Ultrix machine in your grandfather basement, probably MacOS) support hard
  23. links on their native filesystems. Don't do fancy things like moving the
  24. subdirectories to different filesystems. Also, if you move your
  25. .Nm
  26. installation to another server, do it with a tool that keeps hard
  27. links, like
  28. .Xr tar 1
  29. or
  30. .Xr rsync 1
  31. with the -H switch. Remember:
  32. .Nm
  33. is a very UNIXy program that loves hard links.
  34. .Ss Building and Installation
  35. A C compiler must be installed in the system, as well as the development
  36. headers and libraries for OpenSSL (or compatible) and curl. To build
  37. .Nm ,
  38. run
  39. .Bd -literal -offset indent
  40. make
  41. .Ed
  42. .Pp
  43. And, after that, run as root
  44. .Bd -literal -offset indent
  45. make install
  46. .Ed
  47. .Pp
  48. This may be a bit different in some operating systems; please consult the
  49. .Pa README.md
  50. file for more information.
  51. .Ss Data storage Initialization
  52. Once
  53. .Nm
  54. is properly installed on the system, designate a directory where
  55. the server and user data are to be stored. This directory
  56. must not exist yet.
  57. .Nm
  58. must always be run as a regular user; you can create one for
  59. it or use your own. To initialize the data storage, execute
  60. .Bd -literal -offset indent
  61. snac init $HOME/snac-data
  62. .Ed
  63. .Pp
  64. A small set of questions will be asked regarding the installation,
  65. specially the host name it will run under, the local network address
  66. and port
  67. .Nm
  68. will listen to, the optional path prefix and possibly other things.
  69. .Pp
  70. Since version 2.57, if the 'network address' starts with /, it's
  71. assumed to be a UNIX-like socket (please take note that the http proxy
  72. must have full read and write access to this socket; this is a common
  73. pitfall. Permissions will break your heart).
  74. .Pp
  75. You can launch the
  76. .Nm
  77. process by running
  78. .Bd -literal -offset indent
  79. snac httpd $HOME/snac-data
  80. .Ed
  81. .Pp
  82. Log messages are sent to the standard error stream. By default, only
  83. relevant information is written there. You can increase the debugging
  84. level by editing the 'dbglevel' field in the
  85. .Pa server.json
  86. file or by setting a numeric value between 0 and 3 to the DEBUG
  87. environment variable, see below.
  88. .Pp
  89. If you operate a Linux systemd-enabled system, OpenBSD, FreeBSD or NetBSD, there are
  90. startup scripts and configuration data in the
  91. .Pa examples
  92. directory.
  93. For other operating systems, please read the appropriate documentation
  94. on how to install a daemon as a non-root service.
  95. .Ss Upgrading to a new version
  96. Sometimes, the data storage disk layout changes between versions. If there
  97. is such a change,
  98. .Nm
  99. will refuse to run and require an upgrade. Do this by running
  100. .Bd -literal -offset indent
  101. snac upgrade $HOME/snac-data
  102. .Ed
  103. .Pp
  104. Take special care to execute this upgrade operation without any
  105. .Nm
  106. processes serving on the same folder. You can break everything. I know
  107. this because Tyler knows this.
  108. .Pp
  109. .Ss Server Setup
  110. .Pp
  111. An http server with TLS and proxying support must already be
  112. installed and configured.
  113. .Nm
  114. runs as a daemon and listens on a TCP/IP socket, preferably
  115. on a local interface. It can serve the full domain or only
  116. a directory. The http server must be configured to route to the
  117. .Nm
  118. socket all related traffic and also the webfinger standard
  119. address. The Host header must be propagated.
  120. See the examples below.
  121. .Ss Adding Users
  122. .Pp
  123. Users must be created from the command line.
  124. You can do it by running
  125. .Bd -literal -offset indent
  126. snac adduser $HOME/snac-data
  127. .Ed
  128. .Pp
  129. All needed data will be prompted for. There is no artificial limit
  130. on the number of users that can be created.
  131. .Ss Customization
  132. The
  133. .Pa server.json
  134. configuration file allows some behaviour tuning:
  135. .Bl -tag -width tenletters
  136. .It Ic host
  137. The host name.
  138. .It Ic prefix
  139. The URL path prefix.
  140. .It Ic address
  141. The listen network address. If it starts with /, it's assumed to be
  142. a UNIX-like socket instead.
  143. .It Ic port
  144. The listen network port (unused if address is a UNIX socket).
  145. .It Ic dbglevel
  146. The debug level. An integer value, being 0 the less verbose (the default).
  147. .It Ic layout
  148. The disk storage layout version. Never touch this.
  149. .It Ic queue_retry_max
  150. Messages sent out are stored in a queue. If the posting of a messages fails,
  151. it's re-enqueued for later. This integer configures the maximum count of
  152. times the sending will be retried.
  153. .It Ic queue_retry_minutes
  154. The number of minutes to wait before the failed posting of a message is
  155. retried. This is not linear, but multiplied by the number of retries
  156. already done.
  157. .It Ic queue_timeout
  158. The maximum number of seconds to wait when sending a message from the queue.
  159. .It Ic queue_timeout_2
  160. The maximum number of seconds to wait when sending a message from the queue
  161. to those servers that went timeout in the previous retry. If you want to
  162. give slow servers a chance to receive your messages, you can increase this
  163. value (but also take into account that processing the queue will take longer
  164. while waiting for these molasses to respond).
  165. .It Ic def_timeline_entries
  166. This is the default timeline entries shown in the web interface.
  167. .It Ic max_timeline_entries
  168. This is the maximum timeline entries shown in the web interface.
  169. .It Ic timeline_purge_days
  170. Entries in the timeline older that this number of days are purged.
  171. If you don't want any timeline purging and enjoy your data drives
  172. fill up with old crap and finally burst in flames, you can disable
  173. purging by setting this to 0.
  174. .It Ic local_purge_days
  175. Same as before, but for the user-generated entries in the local timeline.
  176. .It Ic propagate_local_purge
  177. If this value is set to true, a Delete activity is generated for every
  178. purged local post and sent everywhere.
  179. .It Ic cssurls
  180. This is a list of URLs to CSS files that will be inserted, in this order,
  181. in the HTML before the user CSS. Use these files to configure the global
  182. site layout.
  183. .It Ic disable_cache
  184. If set to true, timeline caching is not done. This is only useful for
  185. debugging purposes; don't enable it unless you know what do you want, as
  186. it makes everything slower.
  187. .It Ic disable_openbsd_security
  188. If running under OpenBSD,
  189. .Nm
  190. makes use of the enhanced security functions
  191. .Xr unveil 2
  192. and
  193. .Xr pledge 2 .
  194. Setting this to true disables their usage. These functions limit severely
  195. what an intruder can do in case of a security vulnerability, so only enable
  196. this option if something is very broken.
  197. .It Ic num_threads
  198. By setting this value, you can specify the exact number of threads
  199. .Nm
  200. will use when processing connections. Values lesser than 4 will be ignored.
  201. .It Ic disable_email_notifications
  202. By setting this to true, no email notification will be sent for any user.
  203. .It Ic disable_inbox_collection
  204. By setting this to true, no inbox collection is done. Inbox collection helps
  205. being discovered from remote instances, but also increases network traffic.
  206. .It Ic http_headers
  207. If you need to add more HTTP response headers for whatever reason, you can
  208. fill this object with the required header/value pairs.
  209. .It Ic show_instance_timeline
  210. If this is set to true, the instance base URL will show a timeline with the latest
  211. user posts instead of the default greeting static page. If other information
  212. fields are set (see below), they are also shown.
  213. .It Ic admin_email
  214. The email address of the instance administrator (optional).
  215. .It Ic admin_account
  216. The user name of the instance administrator (optional).
  217. .It Ic title
  218. The name of the instance (optional).
  219. .It Ic short_description
  220. A textual short description about the instance (optional).
  221. .It Ic short_description_raw
  222. Whether to interpret short_descript as raw string or convert to HTML (optional).
  223. .It Ic fastcgi
  224. If set to true,
  225. .Nm
  226. will use the FastCGI interface to communicate with the upper level
  227. http server, that must be configured accordingly.
  228. .It Ic disable_history
  229. If set to true, history monthly snapshots are not served nor their links shown.
  230. .It Ic shared_inboxes
  231. This boolean value selects if shared inboxes are announced or not. Enabling
  232. shared inboxes helps (somewhat) in optimizing incoming traffic for instances
  233. with a large number of users.
  234. .It Ic min_account_age
  235. If this numeric value (in seconds) is set, any activity coming from an account
  236. that was created more recently than that will be rejected. This may be used
  237. to mitigate spam from automatically created accounts.
  238. .It Ic protocol
  239. This string value contains the protocol (schema) to be used in URLs. If not
  240. set, it defaults to "https". If you run
  241. .Nm
  242. as part of a hidden network like Tor or I2P that doesn't have a TLS /
  243. Certificate infrastructure, you need to set it to "http". Don't change it
  244. unless you know what you are doing.
  245. .It Ic hide_delete_post_button
  246. If set to true, the button to delete a post is not shown. It's not very
  247. useful and somewhat clutters the already crowded button space.
  248. .It Ic disable_block_notifications
  249. If set to true, notifications about 'Block' activities are never sent.
  250. .It Ic strict_public_timelines
  251. If set to true, public timelines only show posts and boosts originating
  252. from an account (no conversation trees).
  253. .It Ic proxy_media
  254. If set to true, links to all image, audio or video media from other accounts'
  255. posts will not be direct ones, but proxied by
  256. .Nm .
  257. This way, remote media servers will not see the user's IP, but the server one,
  258. improving privacy. Please take note that this will increase the server's incoming
  259. and outgoing traffic.
  260. .It Ic badlogin_retries
  261. If incorrect logins from a given IP address reach this count, subsequent attempts
  262. from it are rejected until the lock expires (default: 5 retries).
  263. .It Ic badlogin_expire
  264. The number of seconds a blocked IP address is ignored in login attempts
  265. (default: 300 seconds).
  266. .It Ic disable_sandbox
  267. This boolean toggle allows disabling Linux Landlock sandboxing. Confining a
  268. program in a sandbox limits the directories and resources it can use, so it's
  269. recommended for security. Support for Linux sandboxing must be compiled in, and you
  270. need at least a Linux kernel version 5.13.0.
  271. .It Ic max_public_entries
  272. The maximum number of entries (posts) to be returned in user RSS feeds and outboxes
  273. (default: 20).
  274. .It Ic max_attachments
  275. The maximum number of attachments per post (default: 4).
  276. .It Ic max_poll_options
  277. The maximum number of poll options in a poll (default: 8).
  278. .It Ic max_poll_option_length
  279. The maximum length of a single poll option (default: 60).
  280. .It Ic enable_svg
  281. Since version 2.73, SVG image attachments are hidden by default; you can enable
  282. them by setting this value to true.
  283. .It Ic smtp_url
  284. Since version 2.76, email notifications can be sent via direct connection to an
  285. SMTP server instead of the traditional behaviour of piping the message to
  286. .Pa /usr/sbin/sendmail .
  287. Set this value to the SMTP url to be used for sending email notifications
  288. (for example, smtp://localhost). It may include a port number if it's not running on
  289. the usual one, like in smtp://mail.example.com:587.
  290. .It Ic smtp_user
  291. .It Ic smtp_password
  292. To be filled if the SMTP server defined by the previous directive needs credentials.
  293. .It Ic rss_hashtag_poll_hours
  294. The periodic number of hours hashtag RSS are polled (default: 4). It has a minimum
  295. value of 1 to avoid hammering servers.
  296. .It Ic disable_notify_webhook
  297. Since version 2.78, users can set a webhook URL to receive notifications. Set this
  298. to true if you don't want your users to have this privilege.
  299. .It Ic favicon_url
  300. The URL to a favicon. If it's not set, the default one is used instead.
  301. .It Ic max_failing_days
  302. The maximum number of days an instance is considered down after continuous failed
  303. outgoing messages (default: 15). Anyway, whenever any incoming activity from a
  304. failed instance is detected, this counter is reset for it.
  305. .It Ic vkey
  306. Public vapid key. Used for notification on some client.
  307. .It Ic disable_emojireact
  308. If set to true, all EmojiReact support (for input and output) is disabled.
  309. .It Ic strip_exif
  310. If set to true, EXIF and other metadata will be stripped from uploaded images (jpg, png, webp, heic, avif, tiff, gif, bmp) and videos (mp4, m4v, mov, webm, mkv, avi). This requires the
  311. .Nm mogrify
  312. (from ImageMagick) and
  313. .Nm ffmpeg
  314. tools to be installed. If
  315. .Nm snac
  316. cannot find or execute these tools at startup, it will refuse to run.
  317. .Pp
  318. When enabled, registered users might pass arbitrary files to
  319. .Nm mogrify
  320. or
  321. .Nm ffmpeg .
  322. These commands are being executed outside the sandbox and have a huge
  323. attack surface. Exploits would be run as the
  324. .Nm
  325. system user. Reconsider enabling this on
  326. .Nm
  327. instances with unknown or untrusted users.
  328. .It Ic mogrify_path
  329. Overrides the default "mogrify" command name or path. Use this if the tool is not in the system PATH or has a different name.
  330. .It Ic ffmpeg_path
  331. Overrides the default "ffmpeg" command name or path. Use this if the tool is not in the system PATH or has a different name.
  332. .It Ic purge_static
  333. If set to true, user static directories are purged; any file stored in these subdirectories (usually images or other media) that is not attached to any post, not used as avatar, header or favicon, and not served as an emoji, is deleted from the filesystem. Don't enable this option if any of your users are serving other files (like, e.g., CSS assets) this way.
  334. .It Ic keep_replied_posts
  335. If set to true, when you reply to a remote post, the parent remote post will be added to local public timeline.
  336. .It Ic keep_replied_me
  337. If set to true, when a remote user replies to one of local posts, the
  338. remote reply will be added to local public timeline.
  339. .It Ic force_ipv6_requests
  340. If set to true, HTTP requests will use only IPv6. Enable this only if you know what you're doing.
  341. .It Ic mastodon_api
  342. If set to false, the Mastodon API is disabled (no need to compile it out).
  343. .El
  344. .Pp
  345. You must restart the server to make effective these changes.
  346. .Pp
  347. If a file named
  348. .Pa greeting.html
  349. is present in the server base directory, it will be returned whenever
  350. the base URL of the server is requested. Fill it with whatever
  351. information about the instance you want to supply to people
  352. visiting the server, like sign up requirements, site policies
  353. and such. The special %userlist% mark in the file will cause
  354. the list of users in this instance to be inserted.
  355. .Pp
  356. Users can change a bit of information about themselves from the
  357. web interface. See
  358. .Xr snac 1
  359. for details. Further, every user can have a private CSS file in their
  360. .Pa static/style.css
  361. that will be served instead of the server-wide one.
  362. It's not modifiable from the web interface to avoid users
  363. shooting themselves in the foot by destroying everything.
  364. .Ss Custom Emojis
  365. From version 2.51, support for customized Emojis in posts is available
  366. (previously, they were hardcoded). Emojis are read from the
  367. .Pa emojis.json
  368. file in the instance base directory, as a JSON object of key / value
  369. pairs (if this file does not exist, it will be created with
  370. the predefined set). Each key in the object contains the text to be found (e.g.,
  371. the :-) for a smiling face), and its associated value, the text string that
  372. will replace it (in this example case, the HTML entity for the Unicode codepoint
  373. for the smiley or the Emoji itself as text).
  374. .Pp
  375. Emoji values can also be URLs to image files; in this case, they will not be
  376. substituted in the post content, but added to the 'tag' array as an ActivityPub
  377. standard 'Emoji' object (it's recommendable that the Emoji key be enclosed in
  378. colons for maximum compatibility with other ActivityPub implementations, like
  379. e.g. :happydoggo:). These images can be served from an external source or from the
  380. .Pa static
  381. directory of the instance admin.
  382. .Pp
  383. If you want to disable any Emoji substitution, change the file to contain
  384. just an empty JSON object ({}).
  385. .Ss SPAM Mitigation
  386. There have been some SPAM attacks on the Fediverse and, as too many
  387. instances and server implementations out there still allow automatic
  388. account creation, it will only get worse.
  389. .Nm
  390. includes some (not very strong) tools for trying to survive the SPAM
  391. flood that will eventually happen.
  392. .Pp
  393. The
  394. .Ic min_account_age
  395. field in the main configuration file allows setting a minimum age (in
  396. seconds) to consider too recently created accounts suspicious of being
  397. a potential source of SPAM. This is a naïve assumption, because spammers
  398. can create accounts, let them dormant for a while and then start to use
  399. them. Also, some ActivityPub implementations don't even bother to return
  400. a creation date for their accounts, so this is not very useful.
  401. .Pp
  402. From version 2.50, post content can be filtered out by regular expressions.
  403. These weapons of mass destruction can be written into the
  404. .Ic filter_reject.txt
  405. file in the server base directory, one per line; if this file exists,
  406. all posts' content will be matched (after being stripped of HTML tags)
  407. against these regexes, one by one, and any match will make the post to
  408. be rejected. Use lower case, the regex will be case insensitive by default.
  409. If you don't know about regular expressions, don't use this
  410. option (or learn about them inw some tutorial, there are gazillions of
  411. them out there), as you and your users may start missing posts. Also,
  412. given that every regular expression implementation supports a different
  413. set of features, consider reading the documentation about the one
  414. implemented in your system.
  415. .Ss ActivityPub Support
  416. These are the following activities and objects that
  417. .Nm
  418. supports:
  419. .Bl -tag -width tenletters
  420. .It Vt Follow
  421. Complete support, on input and output.
  422. .It Vt Undo
  423. For
  424. .Vt Follow ,
  425. .Vt Like
  426. and
  427. .Vt Announce
  428. objects, on input and output.
  429. .It Vt Create
  430. For
  431. .Vt Note ,
  432. .Vt Question ,
  433. .Vt Page ,
  434. .Vt Article ,
  435. .Vt Event
  436. and
  437. .Vt Video
  438. objects on input, and for
  439. .Vt Note
  440. and
  441. .Vt Question
  442. on output.
  443. .It Vt Accept
  444. For
  445. .Vt Follow
  446. objects, on input and output.
  447. .It Vt Like
  448. For
  449. .Vt Note
  450. objects, on input and output.
  451. .It Vt EmojiReact
  452. For
  453. .Vt Note
  454. objects, on input and output.
  455. .It Vt Announce
  456. For
  457. .Vt Note
  458. objects, on input and output.
  459. .It Vt Update
  460. For
  461. .Vt Note ,
  462. .Vt Question ,
  463. .Vt Page ,
  464. .Vt Article ,
  465. .Vt Event
  466. and
  467. .Vt Video
  468. objects on input, and for
  469. .Vt Note
  470. on output.
  471. .It Vt Delete
  472. Supported for
  473. .Vt Note
  474. and
  475. .Vt Tomsbtone
  476. objects on input, and for
  477. .Vt Note
  478. objects on output.
  479. .It Vt Move
  480. For actor-like objects, for input and output.
  481. .El
  482. .Pp
  483. The rest of activities and objects are dropped on input.
  484. .Pp
  485. There is partial support for
  486. .Vt OrderedCollection
  487. objects in the
  488. .Pa /outbox
  489. (with the last 20 entries of the local timeline shown). No pagination
  490. is supported. Intentionally, the
  491. .Pa /followers
  492. and
  493. .Pa /following
  494. paths return empty lists.
  495. .Ss Migrating from snac to Mastodon
  496. Since version 2.60, you can migrate your
  497. .Nm
  498. account to other ActivityPub instances. What is described here is the process to do it from
  499. .Nm
  500. to Mastodon; on other software implementations, it will surely be somewhat different. All
  501. the steps regarding your
  502. .Nm
  503. account must be done from the command line. For the sake of the example, let's
  504. say that you want to migrate from an account named @origin@snac.example.org to
  505. another one named @destination@mastodon.example.com and that both of them
  506. already exist. I've used this very informative page as a guideline:
  507. .Pp
  508. .Lk https://fedi.tips/transferring-your-mastodon-account-to-another-server/
  509. .Pp
  510. 1. On your
  511. .Nm
  512. server, first export your data to CSV by running:
  513. .Bd -literal -offset indent
  514. snac export_csv $SNAC_BASEDIR origin
  515. .Ed
  516. .Pp
  517. You'll find the following CSV files in the
  518. .Pa export/
  519. subdirectory inside the user directory:
  520. .Pa bookmarks.csv ,
  521. .Pa blocked_accounts.csv ,
  522. .Pa lists.csv , and
  523. .Pa following_accounts.csv .
  524. .Pp
  525. 2. In the web interface of your new Mastodon account, click on
  526. .Vt Preferences
  527. >
  528. .Vt Import and Export
  529. >
  530. .Vt Import
  531. and upload the CSV files one at a time. You must specify the type of
  532. file you are uploading.
  533. .Pp
  534. 3. Still in the web interface of your new Mastodon account, click on
  535. .Vt Preferences
  536. >
  537. .Vt Account
  538. >
  539. .Vt Moving From a Different Account ,
  540. then click on
  541. .Vt Create an account alias
  542. and follow the instructions. (When it asks you to
  543. write your old account’s handle, it needs to include the @ at the start
  544. as well as the @ in the middle; as of our example, @origin@snac.example.org).
  545. It seems this step is not performed immediately, you must wait an unspecified
  546. number of minutes for this to be effective.
  547. .Pp
  548. 4. Meanwhile, you must tell
  549. .Nm
  550. about your new account by creating an alias from your current one.
  551. So, on your
  552. .Nm
  553. server, run
  554. .Bd -literal -offset indent
  555. snac alias $SNAC_BASEDIR origin "@destination@mastodon.example.com"
  556. .Ed
  557. .Pp
  558. 5. Finally, you must order
  559. .Nm
  560. to start the migration process, that will consist in iterating all the
  561. people that follows your account and sending them a
  562. .Vt Move
  563. message, that acts as a suggestion to unfollow your old account
  564. and follow the new one. The command is
  565. .Bd -literal -offset indent
  566. snac migrate $SNAC_BASEDIR origin
  567. .Ed
  568. .Pp
  569. This process can be very long and unreliable; any destination server may be down,
  570. too busy, disconnected or gone. I recommend you to read the document I linked
  571. above to know about all the sorrows awaiting.
  572. .Pp
  573. Also, please take note that the
  574. .Nm
  575. account you migrated from is not disabled nor changed in any way, so can still
  576. use it as it no migration was done. This behaviour may or may not match what other
  577. ActivityPub implementations do.
  578. .Pp
  579. .Ss Migrating from Mastodon to snac
  580. Since version 2.61, you can migrate accounts on other ActivityPub instances to your
  581. .Nm
  582. one. What is described here is the process to do it from
  583. Mastodon; on other software implementations, it will surely be somewhat different. All
  584. the steps regarding your
  585. .Nm
  586. account must be done from the command line. For the sake of the example, let's
  587. say that you want to migrate from an account named @origin@mastodon.example.com to
  588. another one named @destination@snac.example.org and that both of them
  589. already exist. I've used this very informative page as a guideline:
  590. .Pp
  591. .Lk https://fedi.tips/transferring-your-mastodon-account-to-another-server/
  592. .Pp
  593. 1. On the web interface of your origin Mastodon account, click on
  594. .Vt Preferences
  595. >
  596. .Vt Import and Export
  597. >
  598. .Vt Export
  599. and download the CSV files under the "Follows", "Lists", "You Block" and "Bookmarks"
  600. labels. After being downloaded, you should find the following files on your download
  601. directory:
  602. .Pa bookmarks.csv ,
  603. .Pa blocked_accounts.csv ,
  604. .Pa lists.csv , and
  605. .Pa following_accounts.csv .
  606. .Pp
  607. 2. Copy all those files to the
  608. .Pa import/
  609. subdirectory of the user's directory inside the server base directory, and run
  610. .Bd -literal -offset indent
  611. snac import_csv $SNAC_BASEDIR destination
  612. .Ed
  613. .Pp
  614. This process may take some time because it depends on the availability / responsiveness
  615. of all the ActivityPub servers involved (webfinger, accounts, posts, etc.). Some errors
  616. may be transient and retried later. Also, if
  617. .Nm
  618. complains that it can't find any of these files, please check that they are really
  619. stored in the
  620. .Pa import/
  621. subdirectory and that their names match exactly. Some of them may be
  622. empty (for example, if you didn't create any list) and that's fine.
  623. .Pp
  624. 3. Again on your
  625. .Nm
  626. server, run
  627. .Bd -literal -offset indent
  628. snac alias $SNAC_BASEDIR destination "@origin@mastodon.example.com"
  629. .Ed
  630. .Pp
  631. Check that no errors were shown. If they do, the origin Mastodon server may be
  632. busy or down; try again later.
  633. .Pp
  634. 4. Move back to the web interface of the origin Mastodon account, go to
  635. .Vt Preferences
  636. >
  637. .Vt Account
  638. >
  639. .Vt Move To A Different Account ,
  640. and follow the instructions there. Set the handle of the new account to your
  641. .Nm
  642. one; as of our example, @destination@snac.example.org. This will start the migration
  643. process: it's the duty of your old Mastodon instance to send an automatic
  644. .Vt Move
  645. message to every one of your followers. Eventually, you will start receiving follow notifications to your
  646. .Nm
  647. account from all accounts that followed the Mastodon one. According to the great document
  648. I linked above, this process may or may not start immediately, and its success may depend
  649. heavily on how all the servers involved behave. Just cross your fingers and hope for the best.
  650. .Pp
  651. .Ss Instance blocking
  652. Full instances can be blocked. This operation must be done from
  653. the command-line tool. See
  654. .Xr snac 1 .
  655. .Pp
  656. .Ss Bad login throttling
  657. Since version 2.67, a simple logic to avoid brute force attacks against user passwords
  658. has been implemented: if, from a given IP address, the number of failed logins reaches
  659. a given threshold, further tries from that IP address are never successful until a timer
  660. expires. The maximum number of retries can be configured in the
  661. .Pa server.json
  662. file by setting the
  663. .Ic badlogin_retries
  664. variable, and the number of seconds the IP address unlock timer expires, in
  665. .Ic badlogin_expire .
  666. Please take note that, for this system to work, you must setup your web server proxy
  667. to pass the remote connection address in the
  668. .Ic X-Forwarded-For
  669. HTTP header (unless you use the FastCGI interface; if that's the case, you don't have
  670. to do anything).
  671. .Pp
  672. .Ss Subscribing to Fediverse Relays
  673. Since version 2.69, a
  674. .Nm
  675. instance can subscribe to LitePub (Pleroma-style) Fediverse Relays. Doing this improves
  676. visibility and allows following hashtags. To do this, you must create a special user named
  677. relay and, from it, follow the relay actor(s) like you do with regular actor URLs. This
  678. special user will start receiving boosts from the relay server of posts from other instances
  679. also following it. If any other user of the same
  680. .Nm
  681. instance follows any of the hashtags included in these boosted posts coming from the relay,
  682. they will be received as if they were for them.
  683. .Pp
  684. Example:
  685. .Bd -literal -offset indent
  686. snac adduser $SNAC_BASEDIR relay # only needed once
  687. snac follow $SNAC_BASEDIR relay https://relay.example.com/actor
  688. .Ed
  689. .Pp
  690. Users on your instance do NOT need to follow the local relay user to benefit from following
  691. hashtags.
  692. .Pp
  693. Please take note that subscribing to relays can increase the traffic towards your instance
  694. significantly. In any case, lowering the "Maximum days to keep posts" value for the relay
  695. special user is recommended (e.g. setting to just 1 day).
  696. .Ss Web interface language
  697. Since version 2.73, the web UI can be localized via simple .po files (they are directly
  698. parsed, no support for gettext is needed).
  699. .Pp
  700. No language file is installed by default; the administrator must copy any desired .po files
  701. to the
  702. .Pa lang/
  703. subdirectory in the base directory. Once the server is restarted, users can select the
  704. new language from the user settings. The
  705. .Nm
  706. source distribution may include .po files in the
  707. .Pa po/
  708. subdirectory. You don't need to copy the English language one, as it's the default.
  709. .Pp
  710. To create new language files, create a copy of
  711. .Pa po/en.po ,
  712. rename it to a reasonable value like
  713. .Pa pl.po
  714. or
  715. .Pa pt_BR.po ,
  716. change the translator in the header to yourself and fill the msgstr strings with your
  717. translation. If you have any doubt on how to modify .po files, there are many tutorials
  718. out there. If you want your language file to be included in the standard
  719. .Nm
  720. distribution, please send me a link to it via the Fediverse to @grunfink@comam.es
  721. or make a PR via the Git repository.
  722. .Ss Number of open files on OpenBSD and login classes
  723. Being a file intensive application, even a small
  724. .Nm
  725. instance might open lots of files, especially when forwarding a new post to
  726. other instances.
  727. .Pp
  728. OpenBSD's daemon login class comes with a very low
  729. .Pa openfiles
  730. value, usually restricting the amount of open files to 128 (cur), 1024 (max).
  731. This can result in
  732. .Nm
  733. to stop working due to too many open files.
  734. .Pp
  735. To continue operation, a new
  736. .Pa snac
  737. login class can be created. Please consult
  738. .Xr login.conf 5
  739. and afterwards create a new login class as follows.
  740. .Bd -literal -offset indent
  741. snac:\\
  742. :openfiles=4096:\\
  743. :tc=daemon:
  744. .Ed
  745. .Pp
  746. After rebuilding the
  747. .Pa /etc/login.conf.db ,
  748. ensure that your snac user's login class is set to
  749. .Pa snac :
  750. .Bd -literal -offset indent
  751. # cap_mkdb /etc/login.conf
  752. # usermod -L snac SNACUSER
  753. .Ed
  754. .Pp
  755. One restart later, the daemon should run with increased
  756. .Pa openfiles .
  757. .Sh ENVIRONMENT
  758. .Bl -tag -width Ds
  759. .It Ev DEBUG
  760. Overrides the debugging level from the server 'dbglevel' configuration
  761. variable. Set it to an integer value. The higher, the deeper in meaningless
  762. verbiage you'll find yourself into.
  763. .El
  764. .Sh EXAMPLES
  765. You want to install the
  766. .Nm
  767. Fediverse daemon in the host example.com, that is correctly configured
  768. with a valid TLS certificate and running the nginx httpd server.
  769. The service will be installed under the
  770. .Pa fedi
  771. location. Two users, walter and jessie, will be hosted in the system.
  772. Their Fediverse presence addresses will be
  773. .Lk https://example.com/fedi/walter
  774. and
  775. .Lk https://example.com/fedi/jesse ,
  776. respectively. They will be known
  777. in the Fediverse as @walter@example.com and @jesse@example.com. The
  778. .Nm
  779. daemon will run as the user snacusr in the system and listen to the
  780. localhost:8001 network socket. All data will be stored in the
  781. .Pa /home/snacusr/fedidata
  782. directory.
  783. .Pp
  784. Log into the system as snacusr and execute:
  785. .Bd -literal -offset indent
  786. snac init /home/snacusr/fedidata
  787. .Ed
  788. .Pp
  789. Answer "example.com" to the host name question, "/fedi" to the path
  790. prefix question, "localhost" to the address and "8001" to the port.
  791. .Pp
  792. Create the users
  793. .Bd -literal -offset indent
  794. snac adduser /home/snacusr/fedidata walter
  795. snac adduser /home/snacusr/fedidata jesse
  796. .Ed
  797. .Pp
  798. Answer the questions with reasonable values.
  799. .Pp
  800. Execute the server:
  801. .Bd -literal -offset indent
  802. snac httpd /home/snacusr/fedidata
  803. .Ed
  804. .Pp
  805. Edit the nginx configuration and add the following snippet to the
  806. example.com server section:
  807. .Bd -literal -offset indent
  808. # nginx configuration example
  809. # main web access point
  810. location /fedi {
  811. proxy_pass http://localhost:8001;
  812. proxy_set_header Host $http_host;
  813. proxy_set_header X-Forwarded-For $remote_addr;
  814. }
  815. # webfinger
  816. location /.well-known/webfinger {
  817. proxy_pass http://localhost:8001;
  818. proxy_set_header Host $http_host;
  819. proxy_set_header X-Forwarded-For $remote_addr;
  820. }
  821. # Mastodon API (entry points)
  822. location /api/v1/ {
  823. proxy_pass http://localhost:8001;
  824. proxy_set_header Host $http_host;
  825. proxy_set_header X-Forwarded-For $remote_addr;
  826. }
  827. location /api/v2/ {
  828. proxy_pass http://localhost:8001;
  829. proxy_set_header Host $http_host;
  830. proxy_set_header X-Forwarded-For $remote_addr;
  831. }
  832. # Mastodon API (OAuth support)
  833. location /oauth {
  834. proxy_pass http://localhost:8001;
  835. proxy_set_header Host $http_host;
  836. proxy_set_header X-Forwarded-For $remote_addr;
  837. }
  838. # optional
  839. location /.well-known/nodeinfo {
  840. proxy_pass http://localhost:8001;
  841. proxy_set_header Host $http_host;
  842. proxy_set_header X-Forwarded-For $remote_addr;
  843. }
  844. # optional (needed by some Mastodon API clients)
  845. location /.well-known/host-meta {
  846. proxy_pass http://localhost:8001;
  847. proxy_set_header Host $http_host;
  848. proxy_set_header X-Forwarded-For $remote_addr;
  849. }
  850. # optional (Mastodon-like link share entrypoint)
  851. location /share {
  852. proxy_pass http://localhost:8001;
  853. proxy_set_header Host $http_host;
  854. proxy_set_header X-Forwarded-For $remote_addr;
  855. }
  856. # optional (Mastodon-like "authorize interaction" entrypoint)
  857. location /authorize_interaction {
  858. proxy_pass http://localhost:8001;
  859. proxy_set_header Host $http_host;
  860. proxy_set_header X-Forwarded-For $remote_addr;
  861. }
  862. .Ed
  863. .Pp
  864. Restart the nginx daemon and connect to
  865. .Lk https://example.com/fedi/walter .
  866. The empty, default screen will be shown. Enter the admin section with the
  867. credentials defined for this user. Search people, start following
  868. them, engage in arid discussions and generally enjoy the frustrating
  869. experience of Social Media.
  870. .Pp
  871. This is an example of a similar configuration for the Apache2 web server:
  872. .Bd -literal -offset indent
  873. # apache2 configuration example
  874. ProxyPreserveHost On
  875. # Main web access point
  876. <Location /fedi>
  877. ProxyPass http://127.0.0.1:8001/fedi
  878. </Location>
  879. # WebFinger
  880. <Location /.well-known/webfinger>
  881. ProxyPass http://127.0.0.1:8001/.well-known/webfinger
  882. </Location>
  883. # Mastodon API (entry points)
  884. <Location /api/v1/>
  885. ProxyPass http://127.0.0.1:8001/api/v1/
  886. </Location>
  887. <Location /api/v2/>
  888. ProxyPass http://127.0.0.1:8001/api/v2/
  889. </Location>
  890. # Mastodon API (OAuth support)
  891. <Location /oauth>
  892. ProxyPass http://127.0.0.1:8001/oauth
  893. </Location>
  894. # NodeInfo (optional)
  895. <Location /.well-known/nodeinfo>
  896. ProxyPass http://127.0.0.1:8001/.well-known/nodeinfo
  897. </Location>
  898. # host-meta (optional, needed for some Mastodon API clients)
  899. <Location /.well-known/host-meta>
  900. ProxyPass http://127.0.0.1:8001/.well-known/host-meta
  901. </Location>
  902. # optional (Mastodon-like link share entrypoint)
  903. <Location /share>
  904. ProxyPass http://127.0.0.1:8001/share
  905. </Location>
  906. # optional (Mastodon-like "authorize interaction" entrypoint)
  907. <Location /authorize_interaction>
  908. ProxyPass http://127.0.0.1:8001/authorize_interaction
  909. </Location>
  910. .Ed
  911. .Pp
  912. Since version 2.43,
  913. .Nm
  914. supports communicating from / to the front end http server using the FastCGI
  915. protocol. There is no special advantage in using this, only that some servers
  916. allow for simpler configuration. For example, in the case of nginx, you can
  917. replace the two 'proxy_pass' and 'proxy_set_header' lines in the example
  918. above with just
  919. .Bd -literal -offset indent
  920. fastcgi_pass localhost:8001;
  921. .Ed
  922. .Pp
  923. The only thing to change on
  924. .Nm
  925. is to the set 'fastcgi' value to true in
  926. .Pa server.json .
  927. .Pp
  928. Further, using the FastCGI interface allows a much simpler configuration
  929. under OpenBSD's native httpd, given that it's natively implemented there
  930. and you no longer need to configure the complicated relayd server. This is
  931. an example:
  932. .Bd -literal -offset indent
  933. # OpenBSD httpd configuration example
  934. # other server configuration
  935. [...]
  936. location "/fedi/*" {
  937. fastcgi socket tcp "127.0.0.1" 8001
  938. }
  939. location "/.well-known/webfinger" {
  940. fastcgi socket tcp "127.0.0.1" 8001
  941. }
  942. location "/oauth/*" {
  943. fastcgi socket tcp "127.0.0.1" 8001
  944. }
  945. location "/api/v1/*" {
  946. fastcgi socket tcp "127.0.0.1" 8001
  947. }
  948. location "/api/v2/*" {
  949. fastcgi socket tcp "127.0.0.1" 8001
  950. }
  951. location "/.well-known/nodeinfo" {
  952. fastcgi socket tcp "127.0.0.1" 8001
  953. }
  954. location "/.well-known/host-meta" {
  955. fastcgi socket tcp "127.0.0.1" 8001
  956. }
  957. location "/share" {
  958. fastcgi socket tcp "127.0.0.1" 8001
  959. }
  960. location "/authorize_interaction" {
  961. fastcgi socket tcp "127.0.0.1" 8001
  962. }
  963. .Ed
  964. .Sh SEE ALSO
  965. .Xr snac 1 ,
  966. .Xr snac 5
  967. .Sh AUTHORS
  968. .An grunfink Lk https://comam.es/snac/grunfink @grunfink@comam.es
  969. .Sh LICENSE
  970. See the LICENSE file for details.
  971. .Sh CAVEATS
  972. JSON files are fragile when modified by hand. Take care.