mirror of
https://github.com/telemt/telemt.git
synced 2026-11-04 06:42:00 +03:00
WEB Debug + Trace
Co-Authored-By: brekotis <93345790+brekotis@users.noreply.github.com>
This commit is contained in:
@@ -89,6 +89,7 @@ pub struct HotFields {
|
||||
pub user_max_unique_ips_global_each: usize,
|
||||
pub user_max_unique_ips_mode: crate::config::UserMaxUniqueIpsMode,
|
||||
pub user_max_unique_ips_window_secs: u64,
|
||||
pub web_debug: WebDebugConfig,
|
||||
}
|
||||
|
||||
impl HotFields {
|
||||
@@ -218,6 +219,7 @@ impl HotFields {
|
||||
user_max_unique_ips_global_each: cfg.access.user_max_unique_ips_global_each,
|
||||
user_max_unique_ips_mode: cfg.access.user_max_unique_ips_mode,
|
||||
user_max_unique_ips_window_secs: cfg.access.user_max_unique_ips_window_secs,
|
||||
web_debug: cfg.web.debug.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -340,6 +342,9 @@ pub(super) fn overlay_hot_fields(old: &ProxyConfig, new: &ProxyConfig) -> ProxyC
|
||||
let process_limits = cfg.web.limits.clone();
|
||||
cfg.web = new.web.clone();
|
||||
cfg.web.limits = process_limits;
|
||||
if !web_debug_fits_limits(&cfg.web.debug, &cfg.web.limits) {
|
||||
cfg.web.debug = old.web.debug.clone();
|
||||
}
|
||||
if cfg.rebuild_runtime_user_auth().is_err() {
|
||||
cfg.runtime_user_auth = None;
|
||||
}
|
||||
|
||||
@@ -496,4 +496,13 @@ pub(super) fn log_changes(
|
||||
new_hot.user_max_unique_ips_window_secs
|
||||
);
|
||||
}
|
||||
if old_hot.web_debug != new_hot.web_debug {
|
||||
info!(
|
||||
"config reload: web.debug updated: enabled={} body_capture={:?} window={}..={}s",
|
||||
new_hot.web_debug.enabled,
|
||||
new_hot.web_debug.body_capture,
|
||||
new_hot.web_debug.default_window_secs,
|
||||
new_hot.web_debug.max_window_secs,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +85,42 @@ fn bind_stale_mode_is_hot() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn web_debug_policy_is_hot_while_debug_capacity_is_process_owned() {
|
||||
let old = sample_config();
|
||||
let mut new = old.clone();
|
||||
new.web.debug.enabled = true;
|
||||
new.web.debug.default_window_secs = 60;
|
||||
new.web.limits.debug_records_capacity += 1;
|
||||
|
||||
let applied = overlay_hot_fields(&old, &new);
|
||||
assert!(applied.web.debug.enabled);
|
||||
assert_eq!(applied.web.debug.default_window_secs, 60);
|
||||
assert_eq!(
|
||||
applied.web.limits.debug_records_capacity,
|
||||
old.web.limits.debug_records_capacity
|
||||
);
|
||||
assert_ne!(
|
||||
HotFields::from_config(&old),
|
||||
HotFields::from_config(&applied)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn web_debug_prefix_requiring_deferred_capacity_is_not_hot_applied() {
|
||||
let old = sample_config();
|
||||
let mut new = old.clone();
|
||||
new.web.limits.max_body_bytes = 4 * 1024 * 1024;
|
||||
new.web.debug.body_prefix_bytes = 3 * 1024 * 1024;
|
||||
|
||||
let applied = overlay_hot_fields(&old, &new);
|
||||
assert_eq!(applied.web.limits.max_body_bytes, old.web.limits.max_body_bytes);
|
||||
assert_eq!(
|
||||
applied.web.debug.body_prefix_bytes,
|
||||
old.web.debug.body_prefix_bytes
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn keepalive_is_not_hot() {
|
||||
let old = sample_config();
|
||||
|
||||
Reference in New Issue
Block a user