mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-29 19:30:34 +00:00
Added option to enable/disable federation
This commit is contained in:
parent
ae3fccf701
commit
a882fbea97
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
|
||||
# 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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)]
|
||||
|
|
Loading…
Reference in a new issue