A simple, minimalistic ActivityPub instance written in portable C
Find a file
Giacomo Tesio b6107c8777 Makefile: enable static compilation with musl
Assuming a Debian GNU/Linux system with wget, tar, git, make
and musl-gcc

```
mkdir build
cd build
export BUILD_TARGET=$PWD
export CC="musl-gcc"

echo download and build zlib
wget http://zlib.net/current/zlib.tar.gz
tar xvf zlib.tar.gz
cd zlib-1.3.1/
./configure --prefix=$BUILD_TARGET --static
make
make install
cd ..

echo download and build openssl
wget https://github.com/openssl/openssl/releases/download/openssl-3.4.0/openssl-3.4.0.tar.gz
tar xvf openssl-3.4.0.tar.gz
cd openssl-3.4.0
CC="musl-gcc -fPIE -pie -static -idirafter /usr/include/ -idirafter /usr/include/x86_64-linux-gnu/" ./Configure no-shared no-async --prefix=$BUILD_TARGET --openssldir=$BUILD_TARGET/ssl linux-x86_64
make depend
make
make install
cd ..

echo download and build curl
wget https://curl.se/download/curl-7.88.1.tar.gz
tar xvf curl-7.88.1.tar.gz
cd curl-7.88.1
./configure --disable-shared --enable-static --disable-silent-rules --disable-debug --disable-warnings --disable-werror --disable-curldebug --disable-symbol-hiding --disable-ares --disable-rt --disable-ech --disable-dependency-tracking --disable-libtool-lock --enable-http --disable-ftp --disable-file --disable-ldap --disable-ldaps --disable-rtsp --disable-proxy --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb --disable-smtp --disable-gopher --disable-mqtt --disable-manual --disable-libcurl-option --disable-ipv6 --disable-openssl-auto-load-config --disable-versioned-symbols --disable-verbose --disable-sspi --disable-crypto-auth --disable-ntlm --disable-ntlm-wb --disable-tls-srp --enable-unix-sockets --disable-cookies --disable-socketpair --disable-http-auth --disable-doh --disable-mime --disable-dateparse --disable-netrc --disable-progress-meter --disable-dnsshuffle --disable-get-easy-options --disable-alt-svc --disable-websockets --without-brotli --without-zstd --without-libpsl --without-libgsasl --without-librtmp --without-winidn --with-openssl=$BUILD_TARGET/ --disable-threaded-resolver --with-zlib=$BUILD_TARGET/ --prefix=$BUILD_TARGET/
make
make install
cd ..

echo download and build snac2
git clone https://codeberg.org/grunfink/snac2.git
cd snac2 # assuming this commit in master
make CFLAGS="-g -Wall -Wextra -pedantic -static -DWITHOUT_SHM" PREFIX=$BUILD_TARGET LDFLAGS="-L$BUILD_TARGET/lib64 -lcurl -lssl -lcrypto -lz"
make install PREFIX=$BUILD_TARGET
cd ..

echo a statically linked snac is ready at $BUILD_TARGET/bin
```
2024-11-20 21:51:43 +01:00
artwork Moved avatars to artwork/. 2023-08-04 19:16:09 +02:00
doc Updated documentation. 2024-11-13 20:19:14 +01:00
examples Updated FreeBSD rc script 2024-11-08 08:01:53 +00:00
.gitignore [.gitignore] new file. 2022-09-27 09:06:03 +02:00
activitypub.c Omit the 'image' field if there are any attachment. 2024-11-07 20:04:02 +01:00
data.c The proxy token seed is created on startup and never stored. 2024-11-12 09:01:30 +01:00
docker-compose.yaml Add docker-compose support, so a working development server with HTTPS can be started with: 2022-12-12 10:26:38 +00:00
Dockerfile Improve Docker image generation 2022-12-14 11:46:16 +01:00
format.c Fixed processing of URLs with two @ inside. 2024-11-03 15:13:31 +01:00
html.c Minor tweak to proxy code (some URLs were not correctly formed). 2024-11-14 16:21:14 +01:00
http.c Added more const. 2024-05-23 10:01:37 +02:00
http_codes.h More or less smaller fixes :) 2024-05-27 23:55:51 +02:00
httpd.c Propagate 'last-modified' and 'etag' fields while proxying. 2024-11-07 19:42:02 +01:00
LICENSE Updated copyright year. 2024-01-04 09:22:03 +01:00
main.c New command line action 'insert'. 2024-10-27 08:53:10 +01:00
Makefile Makefile: enable static compilation with musl 2024-11-20 21:51:43 +01:00
Makefile.NetBSD Updated dependencies. 2024-11-12 10:36:07 +01:00
mastoapi.c mastoapi: a lot of proxy code. 2024-11-12 06:35:00 +01:00
README.md Fixed URL in README.md. 2024-10-03 16:42:52 +02:00
RELEASE_NOTES.md Updated RELEASE_NOTES. 2024-11-14 15:17:14 +01:00
snac.c The proxy token seed is created on startup and never stored. 2024-11-12 09:01:30 +01:00
snac.h Version 2.63 RELEASED. 2024-11-14 15:18:11 +01:00
TODO.md Updated TODO. 2024-11-11 19:42:19 +01:00
upgrade.c Added more const. 2024-05-23 10:01:37 +02:00
utils.c Also import lists.csv. 2024-10-19 21:22:52 +02:00
webfinger.c Log fake uids in webfinger_request_fake(). 2024-09-19 15:02:00 +02:00
xs.h Added -pedantic compilation flag. 2024-10-08 07:45:17 +02:00
xs_curl.h Backport from xs. 2024-08-30 19:10:26 +02:00
xs_fcgi.h Use the raw_path for proxying (as some media may include ? arguments). 2024-11-07 20:47:37 +01:00
xs_glob.h Minor xs tweak. 2024-11-05 16:48:11 +01:00
xs_hex.h Updated copyright year. 2024-01-04 09:22:03 +01:00
xs_html.h Added const everywhere. 2024-05-21 14:12:15 +02:00
xs_httpd.h Use the raw_path for proxying (as some media may include ? arguments). 2024-11-07 20:47:37 +01:00
xs_io.h Updated copyright year. 2024-01-04 09:22:03 +01:00
xs_json.h Minor code cleaning. 2024-09-14 18:59:49 +02:00
xs_match.h Updated copyright year. 2024-01-04 09:22:03 +01:00
xs_mime.h More migration work. 2024-09-20 10:47:14 +02:00
xs_openssl.h Updated copyright year. 2024-01-04 09:22:03 +01:00
xs_random.h Added -pedantic compilation flag. 2024-10-08 07:45:17 +02:00
xs_regex.h Backport from xs. 2024-08-30 19:10:26 +02:00
xs_set.h More migration work. 2024-09-20 10:47:14 +02:00
xs_socket.h Added support for listening on unix sockets. 2024-08-05 06:01:21 +02:00
xs_time.h Minor xs tweak. 2024-11-05 16:48:11 +01:00
xs_unicode.h More migration work. 2024-09-20 10:47:14 +02:00
xs_unicode_tbl.h Searches are now case-insensitive for all alphabets. 2024-08-23 20:27:07 +02:00
xs_unix_socket.h Variable renaming in xs_unix_socket, because it collides in Illumos. 2024-08-12 16:09:47 +02:00
xs_url.h Fixed crash in xs_multipart_form_data() (from the tooot application). 2024-11-11 19:41:43 +01:00
xs_version.h Minor xs tweak. 2024-11-05 16:48:11 +01:00

snac

A simple, minimalistic ActivityPub instance

Features

  • Lightweight, minimal dependencies
  • Extensive support of ActivityPub operations, e.g. write public notes, follow users, be followed, reply to the notes of others, admire wonderful content (like or boost), write private messages...
  • Multiuser
  • Mastodon API support, so Mastodon-compatible apps can be used
  • Simple but effective web interface
  • Easily-accessed MUTE button to silence morons
  • Tested interoperability with related software
  • No database needed
  • Totally JavaScript-free
  • No cookies either
  • Not much bullshit

About

This program runs as a daemon (proxied by a TLS-enabled real httpd server) and provides the basic services for a Fediverse / ActivityPub instance (sharing messages and stuff from/to other systems like Mastodon, Pleroma, Friendica, etc.).

This is not the manual; man pages snac(1) (user manual), snac(5) (formats) and snac(8) (administrator manual) are what you are looking for.

snac stands for Social Networks Are Crap.

Building and installation

This program is written in highly portable C. The only external dependencies are openssl and curl.

On Debian/Ubuntu, you can satisfy these requirements by running

apt install libssl-dev libcurl4-openssl-dev

On OpenBSD you just need to install curl:

pkg_add curl

On FreeBSD, to install curl just type:

pkg install curl

On NetBSD, to install curl just type:

pkgin install curl

The source code is available here.

Run make and then make install as root.

If you're compiling on NetBSD, you should use the specific provided Makefile and run make -f Makefile.NetBSD and then make -f Makefile.NetBSD install as root.

From version 2.27, snac includes support for the Mastodon API; if you are not interested on it, you can compile it out by running

make CFLAGS=-DNO_MASTODON_API

If your compilation process complains about undefined references to shm_open() and shm_unlink() (it happens, for example, on Ubuntu 20.04.6 LTS), run it as:

make LDFLAGS=-lrt

If it still gives compilation errors (because your system does not implement the shared memory functions), you can fix it with

make CFLAGS=-DWITHOUT_SHM

See the administrator manual on how to proceed from here.

Testing via Docker

A docker-compose file is provided for development and testing. To start snac with an nginx HTTPS frontend, run:

docker-compose build && docker-compose up

This will:

  • Start snac, storing data in data/
  • Configure snac to listen on port 8001 with a server name of localhost (see examples/docker-entrypoint.sh)
  • Create a new user testuser and print the user's generated password on the console (see examples/docker-entrypoint.sh)
  • Start nginx to handle HTTPS, using the certificate pair from nginx-alpine-ssl/nginx-selfsigned.* (see examples/nginx-alpine-ssl/entrypoint.sh)

Incredibly awesome CSS themes for snac

License

See the LICENSE file for details.

Author

grunfink @grunfink@comam.es with the help of others.

Buy grunfink a coffee: https://ko-fi.com/grunfink