aboutsummaryrefslogtreecommitdiff
path: root/src/proxy_config.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2023-11-30 16:53:04 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2023-11-30 16:53:04 +0100
commit753903ee021e7aac7c0914883ae8d547148b4d95 (patch)
tree0bd8ecb2297f07d5282a25f4a44f293b41f5766f /src/proxy_config.rs
parentca449ebff452345229953b6ba406acefb157385b (diff)
downloadtricot-753903ee021e7aac7c0914883ae8d547148b4d95.tar.gz
tricot-753903ee021e7aac7c0914883ae8d547148b4d95.zip
implement feature
Diffstat (limited to 'src/proxy_config.rs')
-rw-r--r--src/proxy_config.rs23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/proxy_config.rs b/src/proxy_config.rs
index 8381de2..7690f8a 100644
--- a/src/proxy_config.rs
+++ b/src/proxy_config.rs
@@ -108,6 +108,10 @@ pub struct ProxyEntry {
/// when matching this rule
pub redirects: Vec<(UrlPrefix, UrlPrefix, u16)>,
+ /// Wether or not the domain must be validated before asking a certificate
+ /// to let's encrypt (only for Glob patterns)
+ pub on_demand_tls_ask: Option<String>,
+
/// Number of calls in progress, used to deprioritize slow back-ends
pub calls_in_progress: atomic::AtomicI64,
/// Time of last call, used for round-robin selection
@@ -142,14 +146,14 @@ impl ProxyEntry {
let mut add_headers = vec![];
let mut redirects = vec![];
+ let mut on_demand_tls_ask: Option<String> = None;
for mid in middleware.into_iter() {
+ // LocalLb and GlobalLb are handled in the parent function
match mid {
ConfigTag::AddHeader(k, v) => add_headers.push((k.to_string(), v.clone())),
ConfigTag::AddRedirect(m, r, c) => redirects.push(((*m).clone(), (*r).clone(), *c)),
- ConfigTag::LocalLb | ConfigTag::GlobalLb => {
- /* handled in parent fx */
- ()
- }
+ ConfigTag::OnDemandTlsAsk(url) => on_demand_tls_ask = Some(url.to_string()),
+ ConfigTag::LocalLb | ConfigTag::GlobalLb => (),
};
}
@@ -166,6 +170,7 @@ impl ProxyEntry {
flags,
add_headers,
redirects,
+ on_demand_tls_ask,
// internal
last_call: atomic::AtomicI64::from(0),
calls_in_progress: atomic::AtomicI64::from(0),
@@ -247,6 +252,7 @@ enum MatchTag {
enum ConfigTag<'a> {
AddHeader(&'a str, String),
AddRedirect(UrlPrefix, UrlPrefix, u16),
+ OnDemandTlsAsk(&'a str),
GlobalLb,
LocalLb,
}
@@ -321,6 +327,9 @@ fn parse_tricot_tags(tag: &str) -> Option<ParsedTag> {
p_match, p_replace, http_code,
)))
}
+ ["tricot-on-demand-tls-ask", url, ..] => {
+ Some(ParsedTag::Middleware(ConfigTag::OnDemandTlsAsk(url)))
+ }
["tricot-global-lb", ..] => Some(ParsedTag::Middleware(ConfigTag::GlobalLb)),
["tricot-local-lb", ..] => Some(ParsedTag::Middleware(ConfigTag::LocalLb)),
_ => None,
@@ -369,13 +378,9 @@ fn parse_consul_service(
// some legacy processing that would need a refactor later
for mid in collected_middleware.iter() {
match mid {
- ConfigTag::AddHeader(_, _) | ConfigTag::AddRedirect(_, _, _) =>
- /* not handled here */
- {
- ()
- }
ConfigTag::GlobalLb => flags.global_lb = true,
ConfigTag::LocalLb => flags.site_lb = true,
+ _ => (),
};
}