Added option to enable/disable federation
This commit is contained in:
parent
3d9f7d28d6
commit
cdbf260803
4 changed files with 19 additions and 3 deletions
3
server/config/defaults.hjson
vendored
3
server/config/defaults.hjson
vendored
|
@ -22,6 +22,9 @@
|
||||||
port: 8536
|
port: 8536
|
||||||
# json web token for authorization between server and client
|
# json web token for authorization between server and client
|
||||||
jwt_secret: "changeme"
|
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 limits for various user actions, by user ip
|
||||||
rate_limit: {
|
rate_limit: {
|
||||||
# maximum number of messages created in interval
|
# maximum number of messages created in interval
|
||||||
|
|
|
@ -198,7 +198,7 @@ fn main() {
|
||||||
|
|
||||||
// Create Http server with websocket support
|
// Create Http server with websocket support
|
||||||
HttpServer::new(move || {
|
HttpServer::new(move || {
|
||||||
App::new()
|
let app = App::new()
|
||||||
.data(server.clone())
|
.data(server.clone())
|
||||||
// Front end routes
|
// Front end routes
|
||||||
.service(actix_files::Files::new("/static", front_end_dir()))
|
.service(actix_files::Files::new("/static", front_end_dir()))
|
||||||
|
@ -257,10 +257,17 @@ fn main() {
|
||||||
.route(
|
.route(
|
||||||
"/federation/u/{user_name}",
|
"/federation/u/{user_name}",
|
||||||
web::get().to(apub::user::get_apub_user))
|
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",
|
".well-known/webfinger",
|
||||||
web::get().to(webfinger::get_webfinger_response),
|
web::get().to(webfinger::get_webfinger_response),
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
app
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.bind((settings.bind, settings.port))
|
.bind((settings.bind, settings.port))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|
|
@ -25,13 +25,18 @@ pub fn node_info() -> HttpResponse<Body> {
|
||||||
Ok(site_view) => site_view,
|
Ok(site_view) => site_view,
|
||||||
Err(_e) => return HttpResponse::InternalServerError().finish(),
|
Err(_e) => return HttpResponse::InternalServerError().finish(),
|
||||||
};
|
};
|
||||||
|
let protocols = if Settings::get().federation_enabled {
|
||||||
|
vec!["activitypub"]
|
||||||
|
} else {
|
||||||
|
vec![]
|
||||||
|
};
|
||||||
let json = json!({
|
let json = json!({
|
||||||
"version": "2.0",
|
"version": "2.0",
|
||||||
"software": {
|
"software": {
|
||||||
"name": "lemmy",
|
"name": "lemmy",
|
||||||
"version": version::VERSION,
|
"version": version::VERSION,
|
||||||
},
|
},
|
||||||
"protocols": [],
|
"protocols": protocols,
|
||||||
"usage": {
|
"usage": {
|
||||||
"users": {
|
"users": {
|
||||||
"total": site_view.number_of_users
|
"total": site_view.number_of_users
|
||||||
|
|
|
@ -16,6 +16,7 @@ pub struct Settings {
|
||||||
pub jwt_secret: String,
|
pub jwt_secret: String,
|
||||||
pub rate_limit: RateLimitConfig,
|
pub rate_limit: RateLimitConfig,
|
||||||
pub email: Option<EmailConfig>,
|
pub email: Option<EmailConfig>,
|
||||||
|
pub federation_enabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
|
|
Loading…
Reference in a new issue