aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: cadf76e9db489ac96812572906e115c8ef66b4d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# fuwuqi

Fuwuqi (fúwùqì or 服务器 means "server" in Chinese) is a useless C2S ActivityPub server for "extremely hardcore" ActivityPub enthusiasts. Craft your own exquisite WebFinger response! Customize your actor object exactly like you want! Hack and extend the (100+ε)-line Python server code! 100% guarenteed™ to federate with Mastodon! It's like [Honk](https://humungus.tedunangst.com/r/honk), but instead of politely refusing to hold your hand, it chucks you straight into the deep end of the pool.

## Configuration

You will need:
1. 1x server with a domain name and reverse proxy
2. 1x client device (can be same as server)
3. 2x Python, `cryptography`, `requests` on both server and client
3. 1x brain fluent in Python and ActivityPub
4. 1x pain tolerance

First, clone this repo on your server and your client device.

Now, generate an RSA keypair on your client device:
```bash
openssl genrsa -out private.pem 2048
openssl rsa -in private.pem -outform PEM -pubout -out public.pem
```

On the server, rename `users/test.jsonld` to your username and pop it open in your favorite text editor. You should change `0.exozy.me` to match your server's domain name, `test` to your username, and the `publicKeyPem` field to the public key you just generated.

Onward! Now open `.well-known/webfinger` in your editor, and modify it similarly. Finally, open `server.py` and update the domain, obviously.

That wasn't so bad, was it? (sobbing sounds)

## Usage

Alright, time for the real deal. Start up `python server.py` on your server, and reverse-proxy it so you actually have TLS. If you want to customize the port or whatever, just change the source code.

Now on your client device, open up your favorite C2S ActivityPub client... oh wait... there aren't any! Welp, you'll just have to settle for reading the [AP spec](https://www.w3.org/TR/activitypub/), writing some homemade JSON, and figuring out how `python client.py` works. That's rough, buddy. You'll have to learn how to manually write `Note`s, manually accept follow requests, and more! You can find some examples in this repo. HTTP signatures are generated client-side, for no good reason other than it works. If you want to view your unread messages, just `curl` your inbox and pipe it into `jq`. You can even use Git to keep track of which items in your inbox you're read since it's all just some simple plaintext. Easy as that. (screaming in pain sounds)

Enjoy your new "extremely hardcore" ActivityPub server!!! 🎉😎🚀🙃🥳

## Features

Since Fuwuqi's code is super duper easy to read and extend, the following features are left as an exercise to the reader:
- Multi-user support (hint: dynamically generate `.well-known/webfinger` instead of serving a static file)
- S2S processing for likes and announces
- Deleting posts
- JSON-LD (hint: don't do it, your brain will thank you)
- Lots of pain

## Resources

- https://www.w3.org/TR/activitypub/
- https://blog.joinmastodon.org/2018/06/how-to-implement-a-basic-activitypub-server/
- https://blog.joinmastodon.org/2018/07/how-to-make-friends-and-verify-requests/
- https://docs.joinmastodon.org/spec/
- https://socialhub.activitypub.rocks/t/python-mastodon-server-post-with-http-signature/2757
- https://socialhub.activitypub.rocks/t/activitypub-client-to-server-faq/1941
- https://codeberg.org/forgejo/forgejo/issues/59#contributing