···1+use allegedly::{
2+ Db, ExperimentalConf, ListenConf, bin::GlobalArgs, bin_init, pages_to_pg, poll_upstream, serve,
3+};
4use clap::Parser;
5use reqwest::Url;
6use std::{net::SocketAddr, path::PathBuf};
···41 #[arg(long, requires("acme_domain"), env = "ALLEGEDLY_ACME_DIRECTORY_URL")]
42 #[clap(default_value = "https://acme-v02.api.letsencrypt.org/directory")]
43 acme_directory_url: Url,
44+ /// try to listen for ipv6
45 #[arg(long, action, requires("acme_domain"), env = "ALLEGEDLY_ACME_IPV6")]
46 acme_ipv6: bool,
47+ /// only accept experimental requests at this hostname
48+ ///
49+ /// a cert will be provisioned for it from letsencrypt. if you're not using
50+ /// acme (eg., behind a tls-terminating reverse proxy), open a feature request.
51+ #[arg(
52+ long,
53+ requires("acme_domain"),
54+ env = "ALLEGEDLY_EXPERIMENTAL_ACME_DOMAIN"
55+ )]
56+ experimental_acme_domain: Option<String>,
57+ /// accept writes! by forwarding them upstream
58+ #[arg(long, action, env = "ALLEGEDLY_EXPERIMENTAL_WRITE_UPSTREAM")]
59+ experimental_write_upstream: bool,
60}
6162pub async fn run(
···70 acme_cache_path,
71 acme_directory_url,
72 acme_ipv6,
73+ experimental_acme_domain,
74+ experimental_write_upstream,
75 }: Args,
76) -> anyhow::Result<()> {
77 let db = Db::new(wrap_pg.as_str(), wrap_pg_cert).await?;
···96 }
97 (bind, true, None) => ListenConf::Bind(bind),
98 (_, _, _) => unreachable!(),
99+ };
100+101+ let experimental_conf = ExperimentalConf {
102+ acme_domain: experimental_acme_domain,
103+ write_upstream: experimental_write_upstream,
104 };
105106 let mut tasks = JoinSet::new();
···112113 tasks.spawn(poll_upstream(Some(latest), poll_url, send_page));
114 tasks.spawn(pages_to_pg(db.clone(), recv_page));
115+ tasks.spawn(serve(
116+ upstream,
117+ wrap,
118+ listen_conf,
119+ experimental_conf,
120+ db.clone(),
121+ ));
122123 while let Some(next) = tasks.join_next().await {
124 match next {
+2-2
src/lib.rs
···15pub use backfill::backfill;
16pub use cached_value::{CachedValue, Fetcher};
17pub use client::{CLIENT, UA};
18-pub use mirror::{ListenConf, serve};
19pub use plc_pg::{Db, backfill_to_pg, pages_to_pg};
20pub use poll::{PageBoundaryState, get_page, poll_upstream};
21-pub use ratelimit::GovernorMiddleware;
22pub use weekly::{BundleSource, FolderSource, HttpSource, Week, pages_to_weeks, week_to_pages};
2324pub type Dt = chrono::DateTime<chrono::Utc>;
···15pub use backfill::backfill;
16pub use cached_value::{CachedValue, Fetcher};
17pub use client::{CLIENT, UA};
18+pub use mirror::{ExperimentalConf, ListenConf, serve};
19pub use plc_pg::{Db, backfill_to_pg, pages_to_pg};
20pub use poll::{PageBoundaryState, get_page, poll_upstream};
21+pub use ratelimit::{CreatePlcOpLimiter, GovernorMiddleware, IpLimiters};
22pub use weekly::{BundleSource, FolderSource, HttpSource, Week, pages_to_weeks, week_to_pages};
2324pub type Dt = chrono::DateTime<chrono::Utc>;