a (hacky, wip) multi-tenant oidc-terminating reverse proxy, written in anger on top of pingora

fix case where setting one pingora setting removed defaults

now try to merge all settings with the corresponding defaults, instead
of using the settings wholesale, since zero-values are not what we want
as defaults for stuff like `threads`.

+32 -20
+22 -10
src/config.rs
··· 17 17 18 18 impl From<&Pingora> for pingora::server::configuration::ServerConf { 19 19 fn from(raw: &Pingora) -> Self { 20 + let default = pingora::server::configuration::ServerConf::default(); 20 21 Self { 21 - version: raw.version as usize, 22 - daemon: raw.daemon, 22 + version: raw.version.map(|v| v as usize).unwrap_or(default.version), 23 + daemon: raw.daemon.unwrap_or(default.daemon), 23 24 error_log: raw.error_log.clone(), 24 - pid_file: raw.pid_file.clone(), 25 - upgrade_sock: raw.upgrade_sock.clone(), 25 + pid_file: raw.pid_file.clone().unwrap_or(default.pid_file), 26 + upgrade_sock: raw.upgrade_sock.clone().unwrap_or(default.upgrade_sock), 26 27 user: raw.user.clone(), 27 28 group: raw.group.clone(), 28 - threads: raw.threads as usize, 29 - listener_tasks_per_fd: raw.listener_tasks_per_fd as usize, 30 - work_stealing: raw.work_stealing, 29 + threads: raw.threads.map(|t| t as usize).unwrap_or(default.threads), 30 + listener_tasks_per_fd: raw 31 + .listener_tasks_per_fd 32 + .map(|t| t as usize) 33 + .unwrap_or(default.listener_tasks_per_fd), 34 + work_stealing: raw.work_stealing.unwrap_or(default.work_stealing), 31 35 ca_file: raw.ca_file.clone(), 32 36 grace_period_seconds: raw.grace_period_seconds, 33 37 graceful_shutdown_timeout_seconds: raw.graceful_shutdown_timeout_seconds, 34 38 client_bind_to_ipv4: raw.client_bind_to_ipv4.clone(), 35 39 client_bind_to_ipv6: raw.client_bind_to_ipv6.clone(), 36 - upstream_keepalive_pool_size: raw.upstream_keepalive_pool_size as usize, 40 + upstream_keepalive_pool_size: raw 41 + .upstream_keepalive_pool_size 42 + .map(|s| s as usize) 43 + .unwrap_or(default.upstream_keepalive_pool_size), 37 44 upstream_connect_offload_threadpools: raw 38 45 .upstream_connect_offload_threadpools 39 46 .map(|x| x as usize), 40 47 upstream_connect_offload_thread_per_pool: raw 41 48 .upstream_connect_offload_thread_per_pool 42 49 .map(|x| x as usize), 43 - upstream_debug_ssl_keylog: raw.upstream_debug_ssl_keylog, 44 - max_retries: raw.max_retries as usize, 50 + upstream_debug_ssl_keylog: raw 51 + .upstream_debug_ssl_keylog 52 + .unwrap_or(default.upstream_debug_ssl_keylog), 53 + max_retries: raw 54 + .max_retries 55 + .map(|r| r as usize) 56 + .unwrap_or(default.max_retries), 45 57 upgrade_sock_connect_accept_max_retries: raw 46 58 .upgrade_sock_connect_accept_max_retries 47 59 .map(|x| x as usize),
+10 -10
src/config/format.proto
··· 186 186 // See [pingora](https://docs.rs/pingora/latest/pingora/server/configuration/struct.ServerConf.html) 187 187 // for details on what these do 188 188 message Pingora { 189 - uint64 version = 1; 190 - bool daemon = 2; 189 + optional uint64 version = 1; 190 + optional bool daemon = 2; 191 191 optional string error_log = 3; 192 - string pid_file = 4; 193 - string upgrade_sock = 5; 192 + optional string pid_file = 4; 193 + optional string upgrade_sock = 5; 194 194 optional string user = 6; 195 195 optional string group = 7; 196 - uint64 threads = 8; 197 - uint64 listener_tasks_per_fd = 9; 198 - bool work_stealing = 10; 196 + optional uint64 threads = 8; 197 + optional uint64 listener_tasks_per_fd = 9; 198 + optional bool work_stealing = 10; 199 199 optional string ca_file = 11; 200 200 optional uint64 grace_period_seconds = 12; 201 201 optional uint64 graceful_shutdown_timeout_seconds = 13; 202 202 repeated string client_bind_to_ipv4 = 14; 203 203 repeated string client_bind_to_ipv6 = 15; 204 - uint64 upstream_keepalive_pool_size = 16; 204 + optional uint64 upstream_keepalive_pool_size = 16; 205 205 optional uint64 upstream_connect_offload_threadpools = 17; 206 206 optional uint64 upstream_connect_offload_thread_per_pool = 18; 207 - bool upstream_debug_ssl_keylog = 19; 208 - uint64 max_retries = 20; 207 + optional bool upstream_debug_ssl_keylog = 19; 208 + optional uint64 max_retries = 20; 209 209 optional uint64 upgrade_sock_connect_accept_max_retries = 21; 210 210 211 211 }