9

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
    }
  ]
}

[...]
you are viewing a single comment's thread
view the rest of the comments
[-] nmtake@lemm.ee 4 points 4 months ago

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.

[-] maegul@lemmy.ml 3 points 4 months ago

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.

[-] nmtake@lemm.ee 3 points 4 months ago

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.

[-] maegul@lemmy.ml 3 points 4 months ago

Agreed all around.

But if someone want to learn Web app deployment (TLS certs, hosting, etc.), your option would be a good idea.

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).

this post was submitted on 03 Feb 2024
9 points (100.0% liked)

Learning Rust and Lemmy

231 readers
2 users here now

Welcome

A collaborative space for people to work together on learning Rust, learning about the Lemmy code base, discussing whatever confusions or difficulties we're having in these endeavours, and solving problems, including, hopefully, some contributions back to the Lemmy code base.

Rules TL;DR: Be nice, constructive, and focus on learning and working together on understanding Rust and Lemmy.


Running Projects


Policies and Purposes

  1. This is a place to learn and work together.
  2. Questions and curiosity is welcome and encouraged.
  3. This isn't a technical support community. Those with technical knowledge and experienced aren't obliged to help, though such is very welcome. This is closer to a library of study groups than stackoverflow. Though, forming a repository of useful information would be a good side effect.
  4. This isn't an issue tracker for Lemmy (or Rust) or a place for suggestions. Instead, it's where the nature of an issue, what possible solutions might exist and how they could be or were implemented can be discussed, or, where the means by which a particular suggestion could be implemented is discussed.

See also:

Rules

  1. Lemmy.ml rule 2 applies strongly: "Be respectful, even when disagreeing. Everyone should feel welcome" (see Dessalines's post). This is a constructive space.
  2. Don't demean, intimidate or do anything that isn't constructive and encouraging to anyone trying to learn or understand. People should feel free to ask questions, be curious, and fill their gaps knowledge and understanding.
  3. Posts and comments should be (more or less) within scope (on which see Policies and Purposes above).
  4. See the Lemmy Code of Conduct
  5. Where applicable, rules should be interpreted in light of the Policies and Purposes.

Relevant links and Related Communities


Thumbnail and banner generated by ChatGPT.

founded 4 months ago
MODERATORS