Constellation, Spacedust, Slingshot, UFOs: atproto crates and services for microcosm

cache certs

Changed files
+17 -4
slingshot
+9
slingshot/src/main.rs
···
/// - TODO: a rate-limiter will be installed
#[arg(long)]
host: Option<String>,
}
#[tokio::main]
···
identity,
repo,
args.host,
server_shutdown,
)
.await?;
···
/// - TODO: a rate-limiter will be installed
#[arg(long)]
host: Option<String>,
+
/// a location to cache acme https certs
+
///
+
/// only used if --host is specified. omitting requires re-requesting certs
+
/// on every restart, and letsencrypt has rate limits that are easy to hit.
+
///
+
/// recommended in production, but mind the file permissions.
+
#[arg(long)]
+
certs: Option<PathBuf>,
}
#[tokio::main]
···
identity,
repo,
args.host,
+
args.certs,
server_shutdown,
)
.await?;
+8 -4
slingshot/src/server.rs
···
use atrium_api::types::string::{Cid, Did, Handle, Nsid, RecordKey};
use foyer::HybridCache;
use serde::Serialize;
use std::str::FromStr;
use std::sync::Arc;
use tokio_util::sync::CancellationToken;
···
identity: Identity,
repo: Repo,
host: Option<String>,
_shutdown: CancellationToken,
) -> Result<(), ServerError> {
let repo = Arc::new(repo);
···
app = app.at("/.well-known/did.json", get_did_doc(&host));
-
let auto_cert = AutoCert::builder()
.directory_url(LETS_ENCRYPT_PRODUCTION)
-
.domain(&host)
-
.build()
-
.map_err(ServerError::AcmeBuildError)?;
run(TcpListener::bind("0.0.0.0:443").acme(auto_cert), app).await
} else {
···
use atrium_api::types::string::{Cid, Did, Handle, Nsid, RecordKey};
use foyer::HybridCache;
use serde::Serialize;
+
use std::path::PathBuf;
use std::str::FromStr;
use std::sync::Arc;
use tokio_util::sync::CancellationToken;
···
identity: Identity,
repo: Repo,
host: Option<String>,
+
certs: Option<PathBuf>,
_shutdown: CancellationToken,
) -> Result<(), ServerError> {
let repo = Arc::new(repo);
···
app = app.at("/.well-known/did.json", get_did_doc(&host));
+
let mut auto_cert = AutoCert::builder()
.directory_url(LETS_ENCRYPT_PRODUCTION)
+
.domain(&host);
+
if let Some(certs) = certs {
+
auto_cert = auto_cert.cache_path(certs)
+
}
+
let auto_cert = auto_cert.build().map_err(ServerError::AcmeBuildError)?;
run(TcpListener::bind("0.0.0.0:443").acme(auto_cert), app).await
} else {