vw_small

Hardened fork of Vaultwarden (https://github.com/dani-garcia/vaultwarden) with fewer features.
git clone https://git.philomathiclife.com/repos/vw_small
Log | Files | Refs | README

commit d3773a433a6f40dc0675f63cd57184c11d88c07b
parent 0f0a87becf16506ad948073e4700014ac8b80332
Author: Daniel GarcĂ­a <dani-garcia@users.noreply.github.com>
Date:   Wed, 13 Feb 2019 00:03:16 +0100

Removed list of mounted routes at startup by default, with option to add it back. This would get annoying when starting the server frequently, because it printed ~130 lines of mostly useless info

Diffstat:
Msrc/config.rs | 2++
Msrc/main.rs | 29++++++++++++++++++++++++-----
Msrc/static/templates/admin/page.hbs | 2--
3 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/src/config.rs b/src/config.rs @@ -247,6 +247,8 @@ make_config! { /// Reload templates (Dev) |> When this is set to true, the templates get reloaded with every request. ONLY use this during development, as it can slow down the server reload_templates: bool, true, def, false; + /// Log routes at launch (Dev) + log_mounts: bool, true, def, false; /// Enable extended logging extended_logging: bool, false, def, true; /// Log file path diff --git a/src/main.rs b/src/main.rs @@ -39,18 +39,37 @@ mod util; pub use config::CONFIG; -fn init_rocket() -> Rocket { - rocket::ignite() +fn launch_rocket() { + // Create Rocket object, this stores current log level and sets it's own + let rocket = rocket::ignite(); + + // If we aren't logging the mounts, we force the logging level down + if !CONFIG.log_mounts() { + log::set_max_level(log::LevelFilter::Warn); + } + + let rocket = rocket .mount("/", api::web_routes()) .mount("/api", api::core_routes()) .mount("/admin", api::admin_routes()) .mount("/identity", api::identity_routes()) .mount("/icons", api::icons_routes()) - .mount("/notifications", api::notifications_routes()) + .mount("/notifications", api::notifications_routes()); + + // Force the level up for the fairings, managed state and lauch + if !CONFIG.log_mounts() { + log::set_max_level(log::LevelFilter::max()); + } + + let rocket = rocket .manage(db::init_pool()) .manage(api::start_notification_server()) .attach(util::AppHeaders()) - .attach(AdHoc::on_launch("Launch Info", launch_info)) + .attach(AdHoc::on_launch("Launch Info", launch_info)); + + // Launch and print error if there is one + // The launch will restore the original logging level + error!("Launch error {:#?}", rocket.launch()); } // Embed the migrations from the migrations folder into the application @@ -79,7 +98,7 @@ fn main() { check_web_vault(); migrations::run_migrations(); - init_rocket().launch(); + launch_rocket(); } fn init_logging() -> Result<(), fern::InitError> { diff --git a/src/static/templates/admin/page.hbs b/src/static/templates/admin/page.hbs @@ -89,9 +89,7 @@ <input class="form-check-input conf-{{type}}" type="checkbox" id="input_{{name}}" name="{{name}}" {{#if value}} checked {{/if}}> - {{#if default}} <label class="form-check-label" for="input_{{name}}"> Default: {{default}} </label> - {{/if}} </div> </div> {{/case}}