]> Untitled Git - lemmy.git/commitdiff
Added option to enable/disable federation
authorFelix Ableitner <me@nutomic.com>
Thu, 19 Dec 2019 00:29:56 +0000 (01:29 +0100)
committerFelix Ableitner <me@nutomic.com>
Fri, 27 Dec 2019 16:30:45 +0000 (17:30 +0100)
server/config/defaults.hjson
server/src/main.rs
server/src/nodeinfo.rs
server/src/settings.rs

index e65bbcf430b87ac394c18295e0fc18030c3b2cea..ceb21db0ebff0c2a445183e6e09b474f874b9e49 100644 (file)
@@ -22,6 +22,9 @@
   port: 8536
   # json web token for authorization between server and client
   jwt_secret: "changeme"
+  # whether to enable activitypub federation. this feature is in alpha, do not enable in production, as might
+  # cause problems like remote instances fetching and permanently storing bad data.
+  federation_enabled: false
   # rate limits for various user actions, by user ip
   rate_limit: {
     # maximum number of messages created in interval
index 29f361ea37685d26710d0c4188e8b43e78fd9acf..398a6c39a6122494a793f3d029ed068b1520a34a 100644 (file)
@@ -198,7 +198,7 @@ fn main() {
 
   // Create Http server with websocket support
   HttpServer::new(move || {
-    App::new()
+    let app = App::new()
       .data(server.clone())
       // Front end routes
       .service(actix_files::Files::new("/static", front_end_dir()))
@@ -257,10 +257,17 @@ fn main() {
       .route(
         "/federation/u/{user_name}",
         web::get().to(apub::user::get_apub_user))
-      .route(
+      .route("/feeds/all.xml", web::get().to(feeds::get_all_feed));
+
+    // Federation
+    if Settings::get().federation_enabled {
+      app.route(
         ".well-known/webfinger",
         web::get().to(webfinger::get_webfinger_response),
       )
+    } else {
+      app
+    }
   })
   .bind((settings.bind, settings.port))
   .unwrap()
index f8135c7d003f34e68ef9a62d1f2abaff3245b889..65bd93700013d311853857515a703ee1c31e3756 100644 (file)
@@ -25,13 +25,18 @@ pub fn node_info() -> HttpResponse<Body> {
     Ok(site_view) => site_view,
     Err(_e) => return HttpResponse::InternalServerError().finish(),
   };
+  let protocols = if Settings::get().federation_enabled {
+    vec!["activitypub"]
+  } else {
+    vec![]
+  };
   let json = json!({
     "version": "2.0",
     "software": {
       "name": "lemmy",
       "version": version::VERSION,
     },
-    "protocols": [],
+    "protocols": protocols,
     "usage": {
       "users": {
         "total": site_view.number_of_users
index 4df2979e1945fddc05ddeea037b3ee6ffd603623..7da19c0f797d4d6a663d7f870b46c1b4648c0d81 100644 (file)
@@ -16,6 +16,7 @@ pub struct Settings {
   pub jwt_secret: String,
   pub rate_limit: RateLimitConfig,
   pub email: Option<EmailConfig>,
+  pub federation_enabled: bool,
 }
 
 #[derive(Debug, Deserialize)]