snac.8 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989
  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. .El
  340. .Pp
  341. You must restart the server to make effective these changes.
  342. .Pp
  343. If a file named
  344. .Pa greeting.html
  345. is present in the server base directory, it will be returned whenever
  346. the base URL of the server is requested. Fill it with whatever
  347. information about the instance you want to supply to people
  348. visiting the server, like sign up requirements, site policies
  349. and such. The special %userlist% mark in the file will cause
  350. the list of users in this instance to be inserted.
  351. .Pp
  352. Users can change a bit of information about themselves from the
  353. web interface. See
  354. .Xr snac 1
  355. for details. Further, every user can have a private CSS file in their
  356. .Pa static/style.css
  357. that will be served instead of the server-wide one.
  358. It's not modifiable from the web interface to avoid users
  359. shooting themselves in the foot by destroying everything.
  360. .Ss Custom Emojis
  361. From version 2.51, support for customized Emojis in posts is available
  362. (previously, they were hardcoded). Emojis are read from the
  363. .Pa emojis.json
  364. file in the instance base directory, as a JSON object of key / value
  365. pairs (if this file does not exist, it will be created with
  366. the predefined set). Each key in the object contains the text to be found (e.g.,
  367. the :-) for a smiling face), and its associated value, the text string that
  368. will replace it (in this example case, the HTML entity for the Unicode codepoint
  369. for the smiley or the Emoji itself as text).
  370. .Pp
  371. Emoji values can also be URLs to image files; in this case, they will not be
  372. substituted in the post content, but added to the 'tag' array as an ActivityPub
  373. standard 'Emoji' object (it's recommendable that the Emoji key be enclosed in
  374. colons for maximum compatibility with other ActivityPub implementations, like
  375. e.g. :happydoggo:). These images can be served from an external source or from the
  376. .Pa static
  377. directory of the instance admin.
  378. .Pp
  379. If you want to disable any Emoji substitution, change the file to contain
  380. just an empty JSON object ({}).
  381. .Ss SPAM Mitigation
  382. There have been some SPAM attacks on the Fediverse and, as too many
  383. instances and server implementations out there still allow automatic
  384. account creation, it will only get worse.
  385. .Nm
  386. includes some (not very strong) tools for trying to survive the SPAM
  387. flood that will eventually happen.
  388. .Pp
  389. The
  390. .Ic min_account_age
  391. field in the main configuration file allows setting a minimum age (in
  392. seconds) to consider too recently created accounts suspicious of being
  393. a potential source of SPAM. This is a naïve assumption, because spammers
  394. can create accounts, let them dormant for a while and then start to use
  395. them. Also, some ActivityPub implementations don't even bother to return
  396. a creation date for their accounts, so this is not very useful.
  397. .Pp
  398. From version 2.50, post content can be filtered out by regular expressions.
  399. These weapons of mass destruction can be written into the
  400. .Ic filter_reject.txt
  401. file in the server base directory, one per line; if this file exists,
  402. all posts' content will be matched (after being stripped of HTML tags)
  403. against these regexes, one by one, and any match will make the post to
  404. be rejected. Use lower case, the regex will be case insensitive by default.
  405. If you don't know about regular expressions, don't use this
  406. option (or learn about them inw some tutorial, there are gazillions of
  407. them out there), as you and your users may start missing posts. Also,
  408. given that every regular expression implementation supports a different
  409. set of features, consider reading the documentation about the one
  410. implemented in your system.
  411. .Ss ActivityPub Support
  412. These are the following activities and objects that
  413. .Nm
  414. supports:
  415. .Bl -tag -width tenletters
  416. .It Vt Follow
  417. Complete support, on input and output.
  418. .It Vt Undo
  419. For
  420. .Vt Follow ,
  421. .Vt Like
  422. and
  423. .Vt Announce
  424. objects, on input and output.
  425. .It Vt Create
  426. For
  427. .Vt Note ,
  428. .Vt Question ,
  429. .Vt Page ,
  430. .Vt Article ,
  431. .Vt Event
  432. and
  433. .Vt Video
  434. objects on input, and for
  435. .Vt Note
  436. and
  437. .Vt Question
  438. on output.
  439. .It Vt Accept
  440. For
  441. .Vt Follow
  442. objects, on input and output.
  443. .It Vt Like
  444. For
  445. .Vt Note
  446. objects, on input and output.
  447. .It Vt EmojiReact
  448. For
  449. .Vt Note
  450. objects, on input and output.
  451. .It Vt Announce
  452. For
  453. .Vt Note
  454. objects, on input and output.
  455. .It Vt Update
  456. For
  457. .Vt Note ,
  458. .Vt Question ,
  459. .Vt Page ,
  460. .Vt Article ,
  461. .Vt Event
  462. and
  463. .Vt Video
  464. objects on input, and for
  465. .Vt Note
  466. on output.
  467. .It Vt Delete
  468. Supported for
  469. .Vt Note
  470. and
  471. .Vt Tomsbtone
  472. objects on input, and for
  473. .Vt Note
  474. objects on output.
  475. .It Vt Move
  476. For actor-like objects, for input and output.
  477. .El
  478. .Pp
  479. The rest of activities and objects are dropped on input.
  480. .Pp
  481. There is partial support for
  482. .Vt OrderedCollection
  483. objects in the
  484. .Pa /outbox
  485. (with the last 20 entries of the local timeline shown). No pagination
  486. is supported. Intentionally, the
  487. .Pa /followers
  488. and
  489. .Pa /following
  490. paths return empty lists.
  491. .Ss Migrating from snac to Mastodon
  492. Since version 2.60, you can migrate your
  493. .Nm
  494. account to other ActivityPub instances. What is described here is the process to do it from
  495. .Nm
  496. to Mastodon; on other software implementations, it will surely be somewhat different. All
  497. the steps regarding your
  498. .Nm
  499. account must be done from the command line. For the sake of the example, let's
  500. say that you want to migrate from an account named @origin@snac.example.org to
  501. another one named @destination@mastodon.example.com and that both of them
  502. already exist. I've used this very informative page as a guideline:
  503. .Pp
  504. .Lk https://fedi.tips/transferring-your-mastodon-account-to-another-server/
  505. .Pp
  506. 1. On your
  507. .Nm
  508. server, first export your data to CSV by running:
  509. .Bd -literal -offset indent
  510. snac export_csv $SNAC_BASEDIR origin
  511. .Ed
  512. .Pp
  513. You'll find the following CSV files in the
  514. .Pa export/
  515. subdirectory inside the user directory:
  516. .Pa bookmarks.csv ,
  517. .Pa blocked_accounts.csv ,
  518. .Pa lists.csv , and
  519. .Pa following_accounts.csv .
  520. .Pp
  521. 2. In the web interface of your new Mastodon account, click on
  522. .Vt Preferences
  523. >
  524. .Vt Import and Export
  525. >
  526. .Vt Import
  527. and upload the CSV files one at a time. You must specify the type of
  528. file you are uploading.
  529. .Pp
  530. 3. Still in the web interface of your new Mastodon account, click on
  531. .Vt Preferences
  532. >
  533. .Vt Account
  534. >
  535. .Vt Moving From a Different Account ,
  536. then click on
  537. .Vt Create an account alias
  538. and follow the instructions. (When it asks you to
  539. write your old account’s handle, it needs to include the @ at the start
  540. as well as the @ in the middle; as of our example, @origin@snac.example.org).
  541. It seems this step is not performed immediately, you must wait an unspecified
  542. number of minutes for this to be effective.
  543. .Pp
  544. 4. Meanwhile, you must tell
  545. .Nm
  546. about your new account by creating an alias from your current one.
  547. So, on your
  548. .Nm
  549. server, run
  550. .Bd -literal -offset indent
  551. snac alias $SNAC_BASEDIR origin "@destination@mastodon.example.com"
  552. .Ed
  553. .Pp
  554. 5. Finally, you must order
  555. .Nm
  556. to start the migration process, that will consist in iterating all the
  557. people that follows your account and sending them a
  558. .Vt Move
  559. message, that acts as a suggestion to unfollow your old account
  560. and follow the new one. The command is
  561. .Bd -literal -offset indent
  562. snac migrate $SNAC_BASEDIR origin
  563. .Ed
  564. .Pp
  565. This process can be very long and unreliable; any destination server may be down,
  566. too busy, disconnected or gone. I recommend you to read the document I linked
  567. above to know about all the sorrows awaiting.
  568. .Pp
  569. Also, please take note that the
  570. .Nm
  571. account you migrated from is not disabled nor changed in any way, so can still
  572. use it as it no migration was done. This behaviour may or may not match what other
  573. ActivityPub implementations do.
  574. .Pp
  575. .Ss Migrating from Mastodon to snac
  576. Since version 2.61, you can migrate accounts on other ActivityPub instances to your
  577. .Nm
  578. one. What is described here is the process to do it from
  579. Mastodon; on other software implementations, it will surely be somewhat different. All
  580. the steps regarding your
  581. .Nm
  582. account must be done from the command line. For the sake of the example, let's
  583. say that you want to migrate from an account named @origin@mastodon.example.com to
  584. another one named @destination@snac.example.org and that both of them
  585. already exist. I've used this very informative page as a guideline:
  586. .Pp
  587. .Lk https://fedi.tips/transferring-your-mastodon-account-to-another-server/
  588. .Pp
  589. 1. On the web interface of your origin Mastodon account, click on
  590. .Vt Preferences
  591. >
  592. .Vt Import and Export
  593. >
  594. .Vt Export
  595. and download the CSV files under the "Follows", "Lists", "You Block" and "Bookmarks"
  596. labels. After being downloaded, you should find the following files on your download
  597. directory:
  598. .Pa bookmarks.csv ,
  599. .Pa blocked_accounts.csv ,
  600. .Pa lists.csv , and
  601. .Pa following_accounts.csv .
  602. .Pp
  603. 2. Copy all those files to the
  604. .Pa import/
  605. subdirectory of the user's directory inside the server base directory, and run
  606. .Bd -literal -offset indent
  607. snac import_csv $SNAC_BASEDIR destination
  608. .Ed
  609. .Pp
  610. This process may take some time because it depends on the availability / responsiveness
  611. of all the ActivityPub servers involved (webfinger, accounts, posts, etc.). Some errors
  612. may be transient and retried later. Also, if
  613. .Nm
  614. complains that it can't find any of these files, please check that they are really
  615. stored in the
  616. .Pa import/
  617. subdirectory and that their names match exactly. Some of them may be
  618. empty (for example, if you didn't create any list) and that's fine.
  619. .Pp
  620. 3. Again on your
  621. .Nm
  622. server, run
  623. .Bd -literal -offset indent
  624. snac alias $SNAC_BASEDIR destination "@origin@mastodon.example.com"
  625. .Ed
  626. .Pp
  627. Check that no errors were shown. If they do, the origin Mastodon server may be
  628. busy or down; try again later.
  629. .Pp
  630. 4. Move back to the web interface of the origin Mastodon account, go to
  631. .Vt Preferences
  632. >
  633. .Vt Account
  634. >
  635. .Vt Move To A Different Account ,
  636. and follow the instructions there. Set the handle of the new account to your
  637. .Nm
  638. one; as of our example, @destination@snac.example.org. This will start the migration
  639. process: it's the duty of your old Mastodon instance to send an automatic
  640. .Vt Move
  641. message to every one of your followers. Eventually, you will start receiving follow notifications to your
  642. .Nm
  643. account from all accounts that followed the Mastodon one. According to the great document
  644. I linked above, this process may or may not start immediately, and its success may depend
  645. heavily on how all the servers involved behave. Just cross your fingers and hope for the best.
  646. .Pp
  647. .Ss Instance blocking
  648. Full instances can be blocked. This operation must be done from
  649. the command-line tool. See
  650. .Xr snac 1 .
  651. .Pp
  652. .Ss Bad login throttling
  653. Since version 2.67, a simple logic to avoid brute force attacks against user passwords
  654. has been implemented: if, from a given IP address, the number of failed logins reaches
  655. a given threshold, further tries from that IP address are never successful until a timer
  656. expires. The maximum number of retries can be configured in the
  657. .Pa server.json
  658. file by setting the
  659. .Ic badlogin_retries
  660. variable, and the number of seconds the IP address unlock timer expires, in
  661. .Ic badlogin_expire .
  662. Please take note that, for this system to work, you must setup your web server proxy
  663. to pass the remote connection address in the
  664. .Ic X-Forwarded-For
  665. HTTP header (unless you use the FastCGI interface; if that's the case, you don't have
  666. to do anything).
  667. .Pp
  668. .Ss Subscribing to Fediverse Relays
  669. Since version 2.69, a
  670. .Nm
  671. instance can subscribe to LitePub (Pleroma-style) Fediverse Relays. Doing this improves
  672. visibility and allows following hashtags. To do this, you must create a special user named
  673. relay and, from it, follow the relay actor(s) like you do with regular actor URLs. This
  674. special user will start receiving boosts from the relay server of posts from other instances
  675. also following it. If any other user of the same
  676. .Nm
  677. instance follows any of the hashtags included in these boosted posts coming from the relay,
  678. they will be received as if they were for them.
  679. .Pp
  680. Example:
  681. .Bd -literal -offset indent
  682. snac adduser $SNAC_BASEDIR relay # only needed once
  683. snac follow $SNAC_BASEDIR relay https://relay.example.com/actor
  684. .Ed
  685. .Pp
  686. Users on your instance do NOT need to follow the local relay user to benefit from following
  687. hashtags.
  688. .Pp
  689. Please take note that subscribing to relays can increase the traffic towards your instance
  690. significantly. In any case, lowering the "Maximum days to keep posts" value for the relay
  691. special user is recommended (e.g. setting to just 1 day).
  692. .Ss Web interface language
  693. Since version 2.73, the web UI can be localized via simple .po files (they are directly
  694. parsed, no support for gettext is needed).
  695. .Pp
  696. No language file is installed by default; the administrator must copy any desired .po files
  697. to the
  698. .Pa lang/
  699. subdirectory in the base directory. Once the server is restarted, users can select the
  700. new language from the user settings. The
  701. .Nm
  702. source distribution may include .po files in the
  703. .Pa po/
  704. subdirectory. You don't need to copy the English language one, as it's the default.
  705. .Pp
  706. To create new language files, create a copy of
  707. .Pa po/en.po ,
  708. rename it to a reasonable value like
  709. .Pa pl.po
  710. or
  711. .Pa pt_BR.po ,
  712. change the translator in the header to yourself and fill the msgstr strings with your
  713. translation. If you have any doubt on how to modify .po files, there are many tutorials
  714. out there. If you want your language file to be included in the standard
  715. .Nm
  716. distribution, please send me a link to it via the Fediverse to @grunfink@comam.es
  717. or make a PR via the Git repository.
  718. .Ss Number of open files on OpenBSD and login classes
  719. Being a file intensive application, even a small
  720. .Nm
  721. instance might open lots of files, especially when forwarding a new post to
  722. other instances.
  723. .Pp
  724. OpenBSD's daemon login class comes with a very low
  725. .Pa openfiles
  726. value, usually restricting the amount of open files to 128 (cur), 1024 (max).
  727. This can result in
  728. .Nm
  729. to stop working due to too many open files.
  730. .Pp
  731. To continue operation, a new
  732. .Pa snac
  733. login class can be created. Please consult
  734. .Xr login.conf 5
  735. and afterwards create a new login class as follows.
  736. .Bd -literal -offset indent
  737. snac:\\
  738. :openfiles=4096:\\
  739. :tc=daemon:
  740. .Ed
  741. .Pp
  742. After rebuilding the
  743. .Pa /etc/login.conf.db ,
  744. ensure that your snac user's login class is set to
  745. .Pa snac :
  746. .Bd -literal -offset indent
  747. # cap_mkdb /etc/login.conf
  748. # usermod -L snac SNACUSER
  749. .Ed
  750. .Pp
  751. One restart later, the daemon should run with increased
  752. .Pa openfiles .
  753. .Sh ENVIRONMENT
  754. .Bl -tag -width Ds
  755. .It Ev DEBUG
  756. Overrides the debugging level from the server 'dbglevel' configuration
  757. variable. Set it to an integer value. The higher, the deeper in meaningless
  758. verbiage you'll find yourself into.
  759. .El
  760. .Sh EXAMPLES
  761. You want to install the
  762. .Nm
  763. Fediverse daemon in the host example.com, that is correctly configured
  764. with a valid TLS certificate and running the nginx httpd server.
  765. The service will be installed under the
  766. .Pa fedi
  767. location. Two users, walter and jessie, will be hosted in the system.
  768. Their Fediverse presence addresses will be
  769. .Lk https://example.com/fedi/walter
  770. and
  771. .Lk https://example.com/fedi/jesse ,
  772. respectively. They will be known
  773. in the Fediverse as @walter@example.com and @jesse@example.com. The
  774. .Nm
  775. daemon will run as the user snacusr in the system and listen to the
  776. localhost:8001 network socket. All data will be stored in the
  777. .Pa /home/snacusr/fedidata
  778. directory.
  779. .Pp
  780. Log into the system as snacusr and execute:
  781. .Bd -literal -offset indent
  782. snac init /home/snacusr/fedidata
  783. .Ed
  784. .Pp
  785. Answer "example.com" to the host name question, "/fedi" to the path
  786. prefix question, "localhost" to the address and "8001" to the port.
  787. .Pp
  788. Create the users
  789. .Bd -literal -offset indent
  790. snac adduser /home/snacusr/fedidata walter
  791. snac adduser /home/snacusr/fedidata jesse
  792. .Ed
  793. .Pp
  794. Answer the questions with reasonable values.
  795. .Pp
  796. Execute the server:
  797. .Bd -literal -offset indent
  798. snac httpd /home/snacusr/fedidata
  799. .Ed
  800. .Pp
  801. Edit the nginx configuration and add the following snippet to the
  802. example.com server section:
  803. .Bd -literal -offset indent
  804. # nginx configuration example
  805. # main web access point
  806. location /fedi {
  807. proxy_pass http://localhost:8001;
  808. proxy_set_header Host $http_host;
  809. proxy_set_header X-Forwarded-For $remote_addr;
  810. }
  811. # webfinger
  812. location /.well-known/webfinger {
  813. proxy_pass http://localhost:8001;
  814. proxy_set_header Host $http_host;
  815. proxy_set_header X-Forwarded-For $remote_addr;
  816. }
  817. # Mastodon API (entry points)
  818. location /api/v1/ {
  819. proxy_pass http://localhost:8001;
  820. proxy_set_header Host $http_host;
  821. proxy_set_header X-Forwarded-For $remote_addr;
  822. }
  823. location /api/v2/ {
  824. proxy_pass http://localhost:8001;
  825. proxy_set_header Host $http_host;
  826. proxy_set_header X-Forwarded-For $remote_addr;
  827. }
  828. # Mastodon API (OAuth support)
  829. location /oauth {
  830. proxy_pass http://localhost:8001;
  831. proxy_set_header Host $http_host;
  832. proxy_set_header X-Forwarded-For $remote_addr;
  833. }
  834. # optional
  835. location /.well-known/nodeinfo {
  836. proxy_pass http://localhost:8001;
  837. proxy_set_header Host $http_host;
  838. proxy_set_header X-Forwarded-For $remote_addr;
  839. }
  840. # optional (needed by some Mastodon API clients)
  841. location /.well-known/host-meta {
  842. proxy_pass http://localhost:8001;
  843. proxy_set_header Host $http_host;
  844. proxy_set_header X-Forwarded-For $remote_addr;
  845. }
  846. # optional (Mastodon-like link share entrypoint)
  847. location /share {
  848. proxy_pass http://localhost:8001;
  849. proxy_set_header Host $http_host;
  850. proxy_set_header X-Forwarded-For $remote_addr;
  851. }
  852. # optional (Mastodon-like "authorize interaction" entrypoint)
  853. location /authorize_interaction {
  854. proxy_pass http://localhost:8001;
  855. proxy_set_header Host $http_host;
  856. proxy_set_header X-Forwarded-For $remote_addr;
  857. }
  858. .Ed
  859. .Pp
  860. Restart the nginx daemon and connect to
  861. .Lk https://example.com/fedi/walter .
  862. The empty, default screen will be shown. Enter the admin section with the
  863. credentials defined for this user. Search people, start following
  864. them, engage in arid discussions and generally enjoy the frustrating
  865. experience of Social Media.
  866. .Pp
  867. This is an example of a similar configuration for the Apache2 web server:
  868. .Bd -literal -offset indent
  869. # apache2 configuration example
  870. ProxyPreserveHost On
  871. # Main web access point
  872. <Location /fedi>
  873. ProxyPass http://127.0.0.1:8001/fedi
  874. </Location>
  875. # WebFinger
  876. <Location /.well-known/webfinger>
  877. ProxyPass http://127.0.0.1:8001/.well-known/webfinger
  878. </Location>
  879. # Mastodon API (entry points)
  880. <Location /api/v1/>
  881. ProxyPass http://127.0.0.1:8001/api/v1/
  882. </Location>
  883. <Location /api/v2/>
  884. ProxyPass http://127.0.0.1:8001/api/v2/
  885. </Location>
  886. # Mastodon API (OAuth support)
  887. <Location /oauth>
  888. ProxyPass http://127.0.0.1:8001/oauth
  889. </Location>
  890. # NodeInfo (optional)
  891. <Location /.well-known/nodeinfo>
  892. ProxyPass http://127.0.0.1:8001/.well-known/nodeinfo
  893. </Location>
  894. # host-meta (optional, needed for some Mastodon API clients)
  895. <Location /.well-known/host-meta>
  896. ProxyPass http://127.0.0.1:8001/.well-known/host-meta
  897. </Location>
  898. # optional (Mastodon-like link share entrypoint)
  899. <Location /share>
  900. ProxyPass http://127.0.0.1:8001/share
  901. </Location>
  902. # optional (Mastodon-like "authorize interaction" entrypoint)
  903. <Location /authorize_interaction>
  904. ProxyPass http://127.0.0.1:8001/authorize_interaction
  905. </Location>
  906. .Ed
  907. .Pp
  908. Since version 2.43,
  909. .Nm
  910. supports communicating from / to the front end http server using the FastCGI
  911. protocol. There is no special advantage in using this, only that some servers
  912. allow for simpler configuration. For example, in the case of nginx, you can
  913. replace the two 'proxy_pass' and 'proxy_set_header' lines in the example
  914. above with just
  915. .Bd -literal -offset indent
  916. fastcgi_pass localhost:8001;
  917. .Ed
  918. .Pp
  919. The only thing to change on
  920. .Nm
  921. is to the set 'fastcgi' value to true in
  922. .Pa server.json .
  923. .Pp
  924. Further, using the FastCGI interface allows a much simpler configuration
  925. under OpenBSD's native httpd, given that it's natively implemented there
  926. and you no longer need to configure the complicated relayd server. This is
  927. an example:
  928. .Bd -literal -offset indent
  929. # OpenBSD httpd configuration example
  930. # other server configuration
  931. [...]
  932. location "/fedi/*" {
  933. fastcgi socket tcp "127.0.0.1" 8001
  934. }
  935. location "/.well-known/webfinger" {
  936. fastcgi socket tcp "127.0.0.1" 8001
  937. }
  938. location "/oauth/*" {
  939. fastcgi socket tcp "127.0.0.1" 8001
  940. }
  941. location "/api/v1/*" {
  942. fastcgi socket tcp "127.0.0.1" 8001
  943. }
  944. location "/api/v2/*" {
  945. fastcgi socket tcp "127.0.0.1" 8001
  946. }
  947. location "/.well-known/nodeinfo" {
  948. fastcgi socket tcp "127.0.0.1" 8001
  949. }
  950. location "/.well-known/host-meta" {
  951. fastcgi socket tcp "127.0.0.1" 8001
  952. }
  953. location "/share" {
  954. fastcgi socket tcp "127.0.0.1" 8001
  955. }
  956. location "/authorize_interaction" {
  957. fastcgi socket tcp "127.0.0.1" 8001
  958. }
  959. .Ed
  960. .Sh SEE ALSO
  961. .Xr snac 1 ,
  962. .Xr snac 5
  963. .Sh AUTHORS
  964. .An grunfink Lk https://comam.es/snac/grunfink @grunfink@comam.es
  965. .Sh LICENSE
  966. See the LICENSE file for details.
  967. .Sh CAVEATS
  968. JSON files are fragile when modified by hand. Take care.