- cross-posted to:
- rust@lemmy.ml
- cross-posted to:
- rust@lemmy.ml
The library has a nice guide
and two working examples, so I tried the local_federation
example. To build the example, you need Rust compiler, cargo package manager, and git:
$ git clone https://github.com/LemmyNet/activitypub-federation-rust
$ cd activitypub-federation-rust
$ cargo run --example local_federation axum
[INFO local_federation] Start with parameter `axum` or `actix-web` to select the webserver
[INFO local_federation::axum::http] Listening with axum on localhost:8001
[INFO local_federation::axum::http] Listening with axum on localhost:8002
[INFO local_federation] Local instances started
[INFO local_federation] Alpha user follows beta user via webfinger
[INFO activitypub_federation::fetch] Fetching remote object http://localhost:8002/.well-known/webfinger?resource=acct:beta@localhost:8002
[INFO activitypub_federation::fetch] Fetching remote object http://localhost:8002/beta
[INFO activitypub_federation::fetch] Fetching remote object http://localhost:8001/alpha
[INFO local_federation] Follow was successful
[INFO local_federation] Beta sends a post to its followers
[INFO local_federation] Alpha received post: Hello world!
[INFO local_federation] Test completed
You may want to use network analizyer (e.g, wireshark) to see how it works under the hood.
GET /.well-known/webfinger?resource=acct:beta@localhost:8002 HTTP/1.1
accept: application/jrd+json
digest: SHA-256=[redacted]
signature: keyId="http://localhost:8001/#main-key",algorithm="hs2019",[...]
host: localhost:8002
HTTP/1.1 200 OK
content-type: application/json
content-length: 269
date: Sat, 03 Feb 2024 23:05:19 GMT
{
"subject": "acct:beta@localhost:8002",
"links": [
{
"rel": "http://webfinger.net/rel/profile-page",
"type": "text/html",
"href": "http://localhost:8002/beta",
"template": null
},
{
"rel": "self",
"type": "application/activity+json",
"href": "http://localhost:8002/beta",
"template": null
}
]
}
[...]
For learning real Lemmy stuff, I’d run multiple Lemmy instances on LAN without internet connection to ensure the testing won’t pollute the fediverse.
As I said in a sibling comment, we could run our test instances in a closed federation of their own.
See docs on allowlist federation: https://join-lemmy.org/docs/administration/federation_getting_started.html?highlight=allowlist#federation
So if there are enough people interested, we could have a running list of domains for each of us running an instance to add to our allowlists.
Hosting Lemmy instances on a localhost has these advantages: 1) no TLS required (right?), 2) can sniff the network traffic between the instances, 3) can change codes and settings of the all instances without asking to anyone, and more importantly, 4) no maintance cost. But if someone want to learn Web app deployment (TLS certs, hosting, etc.), your option would be a good idea.
Agreed all around.
I think for some they’d just get a real kick out of seeing their own thing federate. Actually “seeing it” happen might be motivation enough. Which I get completely, so I figure facilitating that for people, as well as running through the other web app stuff as you say (which again is worth “seeing happen” if you haven’t gone through it before).