[edge] Reload and share links: in-process config swap with self-reverting trials, admin socket with health and certificate status, share-link cookies, visitor pages and throttle
This commit is contained in:
@@ -19,10 +19,10 @@ use pingora::server::ShutdownWatch;
|
||||
use crate::acme::Challenges;
|
||||
use crate::logging::{AccessRecord, now_secs, truncate_ip};
|
||||
use crate::proxy::{host_header, hostname};
|
||||
use crate::runtime::Runtime;
|
||||
use crate::shared::Shared;
|
||||
|
||||
pub struct HttpApp {
|
||||
pub rt: Arc<Runtime>,
|
||||
pub shared: Arc<Shared>,
|
||||
pub challenges: Arc<Challenges>,
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@ impl HttpServerApp for HttpApp {
|
||||
impl HttpApp {
|
||||
async fn response(&self, session: &mut ServerSession) -> Response<Vec<u8>> {
|
||||
let start = Instant::now();
|
||||
let rt = self.shared.current();
|
||||
let req = session.req_header();
|
||||
let hh = host_header(req);
|
||||
let name = hostname(&hh);
|
||||
@@ -92,11 +93,11 @@ impl HttpApp {
|
||||
return r;
|
||||
}
|
||||
|
||||
let Some(host) = self.rt.host(&name) else {
|
||||
let Some(host) = rt.host(&name) else {
|
||||
return empty(StatusCode::NOT_FOUND);
|
||||
};
|
||||
let uri = req.uri.path_and_query().map_or("/", |p| p.as_str());
|
||||
let port = self.rt.cfg.https_port;
|
||||
let port = rt.cfg.https_port;
|
||||
let location = if port == 443 {
|
||||
format!("https://{name}{uri}")
|
||||
} else {
|
||||
@@ -110,7 +111,7 @@ impl HttpApp {
|
||||
Err(_) => return empty(StatusCode::BAD_REQUEST),
|
||||
}
|
||||
if host.cfg.access_log
|
||||
&& let Some(log) = &self.rt.access_log
|
||||
&& let Some(log) = &rt.access_log
|
||||
{
|
||||
log.write(&AccessRecord {
|
||||
ts: now_secs(),
|
||||
|
||||
Reference in New Issue
Block a user