Fix clippy errors
This commit is contained in:
parent
18fbb7fa5f
commit
6605af7bed
@ -45,7 +45,7 @@ pub fn set_new_password(new_password: &str) -> Result<(), PeachError> {
|
|||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
Err(err) => {
|
Err(_err) => {
|
||||||
Err(PeachError::FailedToSetNewPassword { msg: "failed to save password hash".to_string() })
|
Err(PeachError::FailedToSetNewPassword { msg: "failed to save password hash".to_string() })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ pub fn set_new_temporary_password(new_password: &str) -> Result<(), PeachError>
|
|||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
Err(err) => {
|
Err(_err) => {
|
||||||
Err(PeachError::FailedToSetNewPassword { msg: "failed to save temporary password hash".to_string() })
|
Err(PeachError::FailedToSetNewPassword { msg: "failed to save temporary password hash".to_string() })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use log::{debug, info};
|
use log::{info};
|
||||||
use rocket::request::{FlashMessage};
|
use rocket::request::{FlashMessage};
|
||||||
use rocket::form::{Form, FromForm};
|
use rocket::form::{Form, FromForm};
|
||||||
use rocket::response::{Flash, Redirect};
|
use rocket::response::{Flash, Redirect};
|
||||||
@ -15,8 +15,8 @@ use crate::utils::{build_json_response, TemplateOrRedirect};
|
|||||||
use rocket::serde::json::Value;
|
use rocket::serde::json::Value;
|
||||||
use rocket::request::{self, FromRequest, Request};
|
use rocket::request::{self, FromRequest, Request};
|
||||||
use rocket::http::{Cookie, CookieJar, Status};
|
use rocket::http::{Cookie, CookieJar, Status};
|
||||||
use rocket::outcome::IntoOutcome;
|
|
||||||
use websocket::futures::future::Ok;
|
|
||||||
|
|
||||||
|
|
||||||
// HELPERS AND STRUCTS FOR AUTHENTICATION WITH COOKIES
|
// HELPERS AND STRUCTS FOR AUTHENTICATION WITH COOKIES
|
||||||
@ -47,7 +47,7 @@ impl<'r> FromRequest<'r> for Authenticated {
|
|||||||
.cookies()
|
.cookies()
|
||||||
.get_private(AUTH_COOKIE_KEY)
|
.get_private(AUTH_COOKIE_KEY)
|
||||||
.and_then(|cookie| cookie.value().parse().ok())
|
.and_then(|cookie| cookie.value().parse().ok())
|
||||||
.map(|value: String| { Authenticated { is_authenticated: true } });
|
.map(|_value: String| { Authenticated { is_authenticated: true } });
|
||||||
match authenticated {
|
match authenticated {
|
||||||
Some(auth) => {
|
Some(auth) => {
|
||||||
request::Outcome::Success(auth)
|
request::Outcome::Success(auth)
|
||||||
@ -373,7 +373,7 @@ pub fn save_password_form(password_form: PasswordForm) -> Result<(), PeachWebErr
|
|||||||
|
|
||||||
/// Change password request handler. This is used by a user who is already logged in.
|
/// Change password request handler. This is used by a user who is already logged in.
|
||||||
#[get("/settings/change_password")]
|
#[get("/settings/change_password")]
|
||||||
pub fn change_password(flash: Option<FlashMessage>, auth: Authenticated) -> Template {
|
pub fn change_password(flash: Option<FlashMessage>, _auth: Authenticated) -> Template {
|
||||||
let mut context = ChangePasswordContext::build();
|
let mut context = ChangePasswordContext::build();
|
||||||
// set back icon link to network route
|
// set back icon link to network route
|
||||||
context.back = Some("/network".to_string());
|
context.back = Some("/network".to_string());
|
||||||
@ -389,7 +389,7 @@ pub fn change_password(flash: Option<FlashMessage>, auth: Authenticated) -> Temp
|
|||||||
|
|
||||||
/// Change password form request handler. This route is used by a user who is already logged in.
|
/// Change password form request handler. This route is used by a user who is already logged in.
|
||||||
#[post("/settings/change_password", data = "<password_form>")]
|
#[post("/settings/change_password", data = "<password_form>")]
|
||||||
pub fn change_password_post(password_form: Form<PasswordForm>, auth: Authenticated) -> Template {
|
pub fn change_password_post(password_form: Form<PasswordForm>, _auth: Authenticated) -> Template {
|
||||||
let result = save_password_form(password_form.into_inner());
|
let result = save_password_form(password_form.into_inner());
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
@ -416,7 +416,7 @@ pub fn change_password_post(password_form: Form<PasswordForm>, auth: Authenticat
|
|||||||
|
|
||||||
/// JSON change password form request handler.
|
/// JSON change password form request handler.
|
||||||
#[post("/api/v1/settings/change_password", data = "<password_form>")]
|
#[post("/api/v1/settings/change_password", data = "<password_form>")]
|
||||||
pub fn save_password_form_endpoint(password_form: Json<PasswordForm>, auth: Authenticated) -> Value {
|
pub fn save_password_form_endpoint(password_form: Json<PasswordForm>, _auth: Authenticated) -> Value {
|
||||||
let result = save_password_form(password_form.into_inner());
|
let result = save_password_form(password_form.into_inner());
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
|
@ -151,7 +151,7 @@ impl DeviceContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/device")]
|
#[get("/device")]
|
||||||
pub fn device_stats(flash: Option<FlashMessage>, auth: Authenticated) -> Template {
|
pub fn device_stats(flash: Option<FlashMessage>, _auth: Authenticated) -> Template {
|
||||||
// assign context through context_builder call
|
// assign context through context_builder call
|
||||||
let mut context = DeviceContext::build();
|
let mut context = DeviceContext::build();
|
||||||
context.back = Some("/".to_string());
|
context.back = Some("/".to_string());
|
||||||
@ -182,7 +182,7 @@ pub fn reboot() -> io::Result<Output> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/device/reboot")]
|
#[get("/device/reboot")]
|
||||||
pub fn reboot_cmd(auth: Authenticated) -> Flash<Redirect> {
|
pub fn reboot_cmd(_auth: Authenticated) -> Flash<Redirect> {
|
||||||
match reboot() {
|
match reboot() {
|
||||||
Ok(_) => Flash::success(Redirect::to("/shutdown"), "Rebooting the device"),
|
Ok(_) => Flash::success(Redirect::to("/shutdown"), "Rebooting the device"),
|
||||||
Err(_) => Flash::error(Redirect::to("/shutdown"), "Failed to reboot the device"),
|
Err(_) => Flash::error(Redirect::to("/shutdown"), "Failed to reboot the device"),
|
||||||
@ -191,7 +191,7 @@ pub fn reboot_cmd(auth: Authenticated) -> Flash<Redirect> {
|
|||||||
|
|
||||||
/// JSON request handler for device reboot.
|
/// JSON request handler for device reboot.
|
||||||
#[post("/api/v1/device/reboot")]
|
#[post("/api/v1/device/reboot")]
|
||||||
pub fn reboot_device(auth: Authenticated) -> Value {
|
pub fn reboot_device(_auth: Authenticated) -> Value {
|
||||||
match reboot() {
|
match reboot() {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
debug!("Going down for reboot...");
|
debug!("Going down for reboot...");
|
||||||
@ -220,7 +220,7 @@ pub fn shutdown() -> io::Result<Output> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/device/shutdown")]
|
#[get("/device/shutdown")]
|
||||||
pub fn shutdown_cmd(auth: Authenticated) -> Flash<Redirect> {
|
pub fn shutdown_cmd(_auth: Authenticated) -> Flash<Redirect> {
|
||||||
match shutdown() {
|
match shutdown() {
|
||||||
Ok(_) => Flash::success(Redirect::to("/shutdown"), "Shutting down the device"),
|
Ok(_) => Flash::success(Redirect::to("/shutdown"), "Shutting down the device"),
|
||||||
Err(_) => Flash::error(Redirect::to("/shutdown"), "Failed to shutdown the device"),
|
Err(_) => Flash::error(Redirect::to("/shutdown"), "Failed to shutdown the device"),
|
||||||
@ -229,7 +229,7 @@ pub fn shutdown_cmd(auth: Authenticated) -> Flash<Redirect> {
|
|||||||
|
|
||||||
// shutdown the device
|
// shutdown the device
|
||||||
#[post("/api/v1/device/shutdown")]
|
#[post("/api/v1/device/shutdown")]
|
||||||
pub fn shutdown_device(auth: Authenticated) -> Value {
|
pub fn shutdown_device(_auth: Authenticated) -> Value {
|
||||||
match shutdown() {
|
match shutdown() {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
debug!("Going down for shutdown...");
|
debug!("Going down for shutdown...");
|
||||||
@ -268,7 +268,7 @@ impl ShutdownContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/shutdown")]
|
#[get("/shutdown")]
|
||||||
pub fn shutdown_menu(flash: Option<FlashMessage>, auth: Authenticated) -> Template {
|
pub fn shutdown_menu(flash: Option<FlashMessage>, _auth: Authenticated) -> Template {
|
||||||
let mut context = ShutdownContext::build();
|
let mut context = ShutdownContext::build();
|
||||||
context.back = Some("/".to_string());
|
context.back = Some("/".to_string());
|
||||||
context.title = Some("Shutdown Device".to_string());
|
context.title = Some("Shutdown Device".to_string());
|
||||||
|
@ -24,7 +24,7 @@ impl HomeContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
pub fn index(auth: Authenticated) -> Template {
|
pub fn index(_auth: Authenticated) -> Template {
|
||||||
let context = HomeContext {
|
let context = HomeContext {
|
||||||
flash_name: None,
|
flash_name: None,
|
||||||
flash_msg: None,
|
flash_msg: None,
|
||||||
|
@ -12,7 +12,7 @@ use crate::routes::authentication::Authenticated;
|
|||||||
|
|
||||||
/// Status route: useful for checking connectivity from web client.
|
/// Status route: useful for checking connectivity from web client.
|
||||||
#[get("/api/v1/ping")]
|
#[get("/api/v1/ping")]
|
||||||
pub fn ping_pong(auth: Authenticated) -> Value {
|
pub fn ping_pong(_auth: Authenticated) -> Value {
|
||||||
//pub fn ping_pong() -> Value {
|
//pub fn ping_pong() -> Value {
|
||||||
// ping pong
|
// ping pong
|
||||||
let status = "success".to_string();
|
let status = "success".to_string();
|
||||||
@ -22,7 +22,7 @@ pub fn ping_pong(auth: Authenticated) -> Value {
|
|||||||
|
|
||||||
/// Status route: check availability of `peach-network` microservice.
|
/// Status route: check availability of `peach-network` microservice.
|
||||||
#[get("/api/v1/ping/network")]
|
#[get("/api/v1/ping/network")]
|
||||||
pub fn ping_network(auth: Authenticated) -> Value {
|
pub fn ping_network(_auth: Authenticated) -> Value {
|
||||||
match network_client::ping() {
|
match network_client::ping() {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
debug!("peach-network responded successfully");
|
debug!("peach-network responded successfully");
|
||||||
@ -41,7 +41,7 @@ pub fn ping_network(auth: Authenticated) -> Value {
|
|||||||
|
|
||||||
/// Status route: check availability of `peach-oled` microservice.
|
/// Status route: check availability of `peach-oled` microservice.
|
||||||
#[get("/api/v1/ping/oled")]
|
#[get("/api/v1/ping/oled")]
|
||||||
pub fn ping_oled(auth: Authenticated) -> Value {
|
pub fn ping_oled(_auth: Authenticated) -> Value {
|
||||||
match oled_client::ping() {
|
match oled_client::ping() {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
debug!("peach-oled responded successfully");
|
debug!("peach-oled responded successfully");
|
||||||
@ -60,7 +60,7 @@ pub fn ping_oled(auth: Authenticated) -> Value {
|
|||||||
|
|
||||||
/// Status route: check availability of `peach-stats` microservice.
|
/// Status route: check availability of `peach-stats` microservice.
|
||||||
#[get("/api/v1/ping/stats")]
|
#[get("/api/v1/ping/stats")]
|
||||||
pub fn ping_stats(auth: Authenticated) -> Value {
|
pub fn ping_stats(_auth: Authenticated) -> Value {
|
||||||
match stats_client::ping() {
|
match stats_client::ping() {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
debug!("peach-stats responded successfully");
|
debug!("peach-stats responded successfully");
|
||||||
|
@ -28,7 +28,7 @@ impl MessageContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/messages")]
|
#[get("/messages")]
|
||||||
pub fn messages(flash: Option<FlashMessage>, auth: Authenticated) -> Template {
|
pub fn messages(flash: Option<FlashMessage>, _auth: Authenticated) -> Template {
|
||||||
let mut context = MessageContext::build();
|
let mut context = MessageContext::build();
|
||||||
context.back = Some("/".to_string());
|
context.back = Some("/".to_string());
|
||||||
context.title = Some("Private Messages".to_string());
|
context.title = Some("Private Messages".to_string());
|
||||||
@ -63,7 +63,7 @@ impl PeerContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/peers")]
|
#[get("/peers")]
|
||||||
pub fn peers(flash: Option<FlashMessage>, auth: Authenticated) -> Template {
|
pub fn peers(flash: Option<FlashMessage>, _auth: Authenticated) -> Template {
|
||||||
let mut context = PeerContext::build();
|
let mut context = PeerContext::build();
|
||||||
context.back = Some("/".to_string());
|
context.back = Some("/".to_string());
|
||||||
context.title = Some("Scuttlebutt Peers".to_string());
|
context.title = Some("Scuttlebutt Peers".to_string());
|
||||||
@ -98,7 +98,7 @@ impl ProfileContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/profile")]
|
#[get("/profile")]
|
||||||
pub fn profile(flash: Option<FlashMessage>, auth: Authenticated) -> Template {
|
pub fn profile(flash: Option<FlashMessage>, _auth: Authenticated) -> Template {
|
||||||
let mut context = ProfileContext::build();
|
let mut context = ProfileContext::build();
|
||||||
context.back = Some("/".to_string());
|
context.back = Some("/".to_string());
|
||||||
context.title = Some("Profile".to_string());
|
context.title = Some("Profile".to_string());
|
||||||
|
@ -41,7 +41,7 @@ impl ConfigureAdminContext {
|
|||||||
|
|
||||||
/// View and delete currently configured admin.
|
/// View and delete currently configured admin.
|
||||||
#[get("/settings/configure_admin")]
|
#[get("/settings/configure_admin")]
|
||||||
pub fn configure_admin(flash: Option<FlashMessage>, auth: Authenticated) -> Template {
|
pub fn configure_admin(flash: Option<FlashMessage>, _auth: Authenticated) -> Template {
|
||||||
let mut context = ConfigureAdminContext::build();
|
let mut context = ConfigureAdminContext::build();
|
||||||
// set back icon link to network route
|
// set back icon link to network route
|
||||||
context.back = Some("/network".to_string());
|
context.back = Some("/network".to_string());
|
||||||
@ -88,7 +88,7 @@ pub fn save_add_admin_form(admin_form: AddAdminForm) -> Result<(), PeachWebError
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/settings/admin/add")]
|
#[get("/settings/admin/add")]
|
||||||
pub fn add_admin(flash: Option<FlashMessage>, auth: Authenticated) -> Template {
|
pub fn add_admin(flash: Option<FlashMessage>, _auth: Authenticated) -> Template {
|
||||||
let mut context = AddAdminContext::build();
|
let mut context = AddAdminContext::build();
|
||||||
context.back = Some("/settings/configure_admin".to_string());
|
context.back = Some("/settings/configure_admin".to_string());
|
||||||
context.title = Some("Add Admin".to_string());
|
context.title = Some("Add Admin".to_string());
|
||||||
@ -103,7 +103,7 @@ pub fn add_admin(flash: Option<FlashMessage>, auth: Authenticated) -> Template {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[post("/settings/admin/add", data = "<add_admin_form>")]
|
#[post("/settings/admin/add", data = "<add_admin_form>")]
|
||||||
pub fn add_admin_post(add_admin_form: Form<AddAdminForm>, auth: Authenticated) -> Flash<Redirect> {
|
pub fn add_admin_post(add_admin_form: Form<AddAdminForm>, _auth: Authenticated) -> Flash<Redirect> {
|
||||||
let result = save_add_admin_form(add_admin_form.into_inner());
|
let result = save_add_admin_form(add_admin_form.into_inner());
|
||||||
let url = uri!(configure_admin);
|
let url = uri!(configure_admin);
|
||||||
match result {
|
match result {
|
||||||
@ -120,7 +120,7 @@ pub struct DeleteAdminForm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[post("/settings/admin/delete", data = "<delete_admin_form>")]
|
#[post("/settings/admin/delete", data = "<delete_admin_form>")]
|
||||||
pub fn delete_admin_post(delete_admin_form: Form<DeleteAdminForm>, auth: Authenticated) -> Flash<Redirect> {
|
pub fn delete_admin_post(delete_admin_form: Form<DeleteAdminForm>, _auth: Authenticated) -> Flash<Redirect> {
|
||||||
let result = config_manager::delete_ssb_admin_id(&delete_admin_form.ssb_id);
|
let result = config_manager::delete_ssb_admin_id(&delete_admin_form.ssb_id);
|
||||||
let url = uri!(configure_admin);
|
let url = uri!(configure_admin);
|
||||||
match result {
|
match result {
|
||||||
|
@ -114,7 +114,7 @@ impl ConfigureDNSContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/network/dns")]
|
#[get("/network/dns")]
|
||||||
pub fn configure_dns(flash: Option<FlashMessage>, auth: Authenticated) -> Template {
|
pub fn configure_dns(flash: Option<FlashMessage>, _auth: Authenticated) -> Template {
|
||||||
let mut context = ConfigureDNSContext::build();
|
let mut context = ConfigureDNSContext::build();
|
||||||
// set back icon link to network route
|
// set back icon link to network route
|
||||||
context.back = Some("/network".to_string());
|
context.back = Some("/network".to_string());
|
||||||
@ -129,7 +129,7 @@ pub fn configure_dns(flash: Option<FlashMessage>, auth: Authenticated) -> Templa
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[post("/network/dns", data = "<dns>")]
|
#[post("/network/dns", data = "<dns>")]
|
||||||
pub fn configure_dns_post(dns: Form<DnsForm>, auth: Authenticated) -> Template {
|
pub fn configure_dns_post(dns: Form<DnsForm>, _auth: Authenticated) -> Template {
|
||||||
let result = save_dns_configuration(dns.into_inner());
|
let result = save_dns_configuration(dns.into_inner());
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
@ -154,7 +154,7 @@ pub fn configure_dns_post(dns: Form<DnsForm>, auth: Authenticated) -> Template {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[post("/api/v1/dns/configure", data = "<dns_form>")]
|
#[post("/api/v1/dns/configure", data = "<dns_form>")]
|
||||||
pub fn save_dns_configuration_endpoint(dns_form: Json<DnsForm>, auth: Authenticated) -> Value {
|
pub fn save_dns_configuration_endpoint(dns_form: Json<DnsForm>, _auth: Authenticated) -> Value {
|
||||||
let result = save_dns_configuration(dns_form.into_inner());
|
let result = save_dns_configuration(dns_form.into_inner());
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
|
@ -39,7 +39,7 @@ pub struct WiFi {
|
|||||||
// HELPERS AND ROUTES FOR /network/wifi/usage/reset
|
// HELPERS AND ROUTES FOR /network/wifi/usage/reset
|
||||||
|
|
||||||
#[get("/network/wifi/usage/reset")]
|
#[get("/network/wifi/usage/reset")]
|
||||||
pub fn wifi_usage_reset(auth: Authenticated) -> Flash<Redirect> {
|
pub fn wifi_usage_reset(_auth: Authenticated) -> Flash<Redirect> {
|
||||||
let url = uri!(wifi_usage);
|
let url = uri!(wifi_usage);
|
||||||
match monitor::reset_data() {
|
match monitor::reset_data() {
|
||||||
Ok(_) => Flash::success(Redirect::to(url), "Reset stored network traffic total"),
|
Ok(_) => Flash::success(Redirect::to(url), "Reset stored network traffic total"),
|
||||||
@ -51,7 +51,7 @@ pub fn wifi_usage_reset(auth: Authenticated) -> Flash<Redirect> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[post("/network/wifi/connect", data = "<network>")]
|
#[post("/network/wifi/connect", data = "<network>")]
|
||||||
pub fn connect_wifi(network: Form<Ssid>, auth: Authenticated) -> Flash<Redirect> {
|
pub fn connect_wifi(network: Form<Ssid>, _auth: Authenticated) -> Flash<Redirect> {
|
||||||
let ssid = &network.ssid;
|
let ssid = &network.ssid;
|
||||||
let url = uri!(network_detail(ssid = ssid));
|
let url = uri!(network_detail(ssid = ssid));
|
||||||
match network_client::id("wlan0", ssid) {
|
match network_client::id("wlan0", ssid) {
|
||||||
@ -64,7 +64,7 @@ pub fn connect_wifi(network: Form<Ssid>, auth: Authenticated) -> Flash<Redirect>
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[post("/network/wifi/disconnect", data = "<network>")]
|
#[post("/network/wifi/disconnect", data = "<network>")]
|
||||||
pub fn disconnect_wifi(network: Form<Ssid>, auth: Authenticated) -> Flash<Redirect> {
|
pub fn disconnect_wifi(network: Form<Ssid>, _auth: Authenticated) -> Flash<Redirect> {
|
||||||
let ssid = &network.ssid;
|
let ssid = &network.ssid;
|
||||||
let url = uri!(network_home);
|
let url = uri!(network_home);
|
||||||
match network_client::disable("wlan0", ssid) {
|
match network_client::disable("wlan0", ssid) {
|
||||||
@ -74,7 +74,7 @@ pub fn disconnect_wifi(network: Form<Ssid>, auth: Authenticated) -> Flash<Redire
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[post("/network/wifi/forget", data = "<network>")]
|
#[post("/network/wifi/forget", data = "<network>")]
|
||||||
pub fn forget_wifi(network: Form<Ssid>, auth: Authenticated) -> Flash<Redirect> {
|
pub fn forget_wifi(network: Form<Ssid>, _auth: Authenticated) -> Flash<Redirect> {
|
||||||
let ssid = &network.ssid;
|
let ssid = &network.ssid;
|
||||||
let url = uri!(network_home);
|
let url = uri!(network_home);
|
||||||
match network_client::forget("wlan0", ssid) {
|
match network_client::forget("wlan0", ssid) {
|
||||||
@ -87,7 +87,7 @@ pub fn forget_wifi(network: Form<Ssid>, auth: Authenticated) -> Flash<Redirect>
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/network/wifi/modify?<ssid>")]
|
#[get("/network/wifi/modify?<ssid>")]
|
||||||
pub fn wifi_password(ssid: &str, flash: Option<FlashMessage>, auth: Authenticated) -> Template {
|
pub fn wifi_password(ssid: &str, flash: Option<FlashMessage>, _auth: Authenticated) -> Template {
|
||||||
let mut context = NetworkAddContext {
|
let mut context = NetworkAddContext {
|
||||||
back: Some("/network/wifi".to_string()),
|
back: Some("/network/wifi".to_string()),
|
||||||
flash_name: None,
|
flash_name: None,
|
||||||
@ -106,7 +106,7 @@ pub fn wifi_password(ssid: &str, flash: Option<FlashMessage>, auth: Authenticate
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[post("/network/wifi/modify", data = "<wifi>")]
|
#[post("/network/wifi/modify", data = "<wifi>")]
|
||||||
pub fn wifi_set_password(wifi: Form<WiFi>, auth: Authenticated) -> Flash<Redirect> {
|
pub fn wifi_set_password(wifi: Form<WiFi>, _auth: Authenticated) -> Flash<Redirect> {
|
||||||
let ssid = &wifi.ssid;
|
let ssid = &wifi.ssid;
|
||||||
let pass = &wifi.pass;
|
let pass = &wifi.pass;
|
||||||
let url = uri!(network_detail(ssid = ssid));
|
let url = uri!(network_detail(ssid = ssid));
|
||||||
@ -274,7 +274,7 @@ impl NetworkContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/network")]
|
#[get("/network")]
|
||||||
pub fn network_home(flash: Option<FlashMessage>, auth: Authenticated) -> Template {
|
pub fn network_home(flash: Option<FlashMessage>, _auth: Authenticated) -> Template {
|
||||||
// assign context through context_builder call
|
// assign context through context_builder call
|
||||||
let mut context = NetworkContext::build();
|
let mut context = NetworkContext::build();
|
||||||
// set back button (nav) url
|
// set back button (nav) url
|
||||||
@ -294,7 +294,7 @@ pub fn network_home(flash: Option<FlashMessage>, auth: Authenticated) -> Templat
|
|||||||
// HELPERS AND ROUTES FOR /network/ap/activate
|
// HELPERS AND ROUTES FOR /network/ap/activate
|
||||||
|
|
||||||
#[get("/network/ap/activate")]
|
#[get("/network/ap/activate")]
|
||||||
pub fn deploy_ap(auth: Authenticated) -> Flash<Redirect> {
|
pub fn deploy_ap(_auth: Authenticated) -> Flash<Redirect> {
|
||||||
// activate the wireless access point
|
// activate the wireless access point
|
||||||
debug!("Activating WiFi access point.");
|
debug!("Activating WiFi access point.");
|
||||||
match network_client::activate_ap() {
|
match network_client::activate_ap() {
|
||||||
@ -376,7 +376,7 @@ impl NetworkListContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/network/wifi")]
|
#[get("/network/wifi")]
|
||||||
pub fn wifi_list(flash: Option<FlashMessage>, auth: Authenticated) -> Template {
|
pub fn wifi_list(flash: Option<FlashMessage>, _auth: Authenticated) -> Template {
|
||||||
// assign context through context_builder call
|
// assign context through context_builder call
|
||||||
let mut context = NetworkListContext::build();
|
let mut context = NetworkListContext::build();
|
||||||
context.back = Some("/network".to_string());
|
context.back = Some("/network".to_string());
|
||||||
@ -541,7 +541,7 @@ impl NetworkDetailContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/network/wifi?<ssid>")]
|
#[get("/network/wifi?<ssid>")]
|
||||||
pub fn network_detail(ssid: &str, flash: Option<FlashMessage>, auth: Authenticated) -> Template {
|
pub fn network_detail(ssid: &str, flash: Option<FlashMessage>, _auth: Authenticated) -> Template {
|
||||||
// assign context through context_builder call
|
// assign context through context_builder call
|
||||||
let mut context = NetworkDetailContext::build();
|
let mut context = NetworkDetailContext::build();
|
||||||
context.back = Some("/network/wifi".to_string());
|
context.back = Some("/network/wifi".to_string());
|
||||||
@ -560,7 +560,7 @@ pub fn network_detail(ssid: &str, flash: Option<FlashMessage>, auth: Authenticat
|
|||||||
// HELPERS AND ROUTES FOR /network/wifi/activate
|
// HELPERS AND ROUTES FOR /network/wifi/activate
|
||||||
|
|
||||||
#[get("/network/wifi/activate")]
|
#[get("/network/wifi/activate")]
|
||||||
pub fn deploy_client(auth: Authenticated) -> Flash<Redirect> {
|
pub fn deploy_client(_auth: Authenticated) -> Flash<Redirect> {
|
||||||
// activate the wireless client
|
// activate the wireless client
|
||||||
debug!("Activating WiFi client mode.");
|
debug!("Activating WiFi client mode.");
|
||||||
match network_client::activate_client() {
|
match network_client::activate_client() {
|
||||||
@ -572,7 +572,7 @@ pub fn deploy_client(auth: Authenticated) -> Flash<Redirect> {
|
|||||||
// HELPERS AND ROUTES FOR /network/wifi/add
|
// HELPERS AND ROUTES FOR /network/wifi/add
|
||||||
|
|
||||||
#[get("/network/wifi/add")]
|
#[get("/network/wifi/add")]
|
||||||
pub fn network_add_wifi(flash: Option<FlashMessage>, auth: Authenticated) -> Template {
|
pub fn network_add_wifi(flash: Option<FlashMessage>, _auth: Authenticated) -> Template {
|
||||||
let mut context = NetworkContext::build();
|
let mut context = NetworkContext::build();
|
||||||
// set back icon link to network route
|
// set back icon link to network route
|
||||||
context.back = Some("/network".to_string());
|
context.back = Some("/network".to_string());
|
||||||
@ -610,7 +610,7 @@ impl NetworkAddContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/network/wifi/add?<ssid>")]
|
#[get("/network/wifi/add?<ssid>")]
|
||||||
pub fn network_add_ssid(ssid: &str, flash: Option<FlashMessage>, auth: Authenticated) -> Template {
|
pub fn network_add_ssid(ssid: &str, flash: Option<FlashMessage>, _auth: Authenticated) -> Template {
|
||||||
let mut context = NetworkAddContext::build();
|
let mut context = NetworkAddContext::build();
|
||||||
context.back = Some("/network/wifi".to_string());
|
context.back = Some("/network/wifi".to_string());
|
||||||
context.selected = Some(ssid.to_string());
|
context.selected = Some(ssid.to_string());
|
||||||
@ -626,7 +626,7 @@ pub fn network_add_ssid(ssid: &str, flash: Option<FlashMessage>, auth: Authentic
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[post("/network/wifi/add", data = "<wifi>")]
|
#[post("/network/wifi/add", data = "<wifi>")]
|
||||||
pub fn add_credentials(wifi: Form<WiFi>, auth: Authenticated) -> Template {
|
pub fn add_credentials(wifi: Form<WiFi>, _auth: Authenticated) -> Template {
|
||||||
// check if the credentials already exist for this access point
|
// check if the credentials already exist for this access point
|
||||||
// note: this is nicer but it's an unstable feature:
|
// note: this is nicer but it's an unstable feature:
|
||||||
// if check_saved_aps(&wifi.ssid).contains(true)
|
// if check_saved_aps(&wifi.ssid).contains(true)
|
||||||
@ -720,7 +720,7 @@ impl NetworkAlertContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/network/wifi/usage")]
|
#[get("/network/wifi/usage")]
|
||||||
pub fn wifi_usage(flash: Option<FlashMessage>, auth: Authenticated) -> Template {
|
pub fn wifi_usage(flash: Option<FlashMessage>, _auth: Authenticated) -> Template {
|
||||||
let mut context = NetworkAlertContext::build();
|
let mut context = NetworkAlertContext::build();
|
||||||
// set back icon link to network route
|
// set back icon link to network route
|
||||||
context.back = Some("/network".to_string());
|
context.back = Some("/network".to_string());
|
||||||
@ -736,7 +736,7 @@ pub fn wifi_usage(flash: Option<FlashMessage>, auth: Authenticated) -> Template
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[post("/network/wifi/usage", data = "<thresholds>")]
|
#[post("/network/wifi/usage", data = "<thresholds>")]
|
||||||
pub fn wifi_usage_alerts(thresholds: Form<Threshold>, auth: Authenticated) -> Flash<Redirect> {
|
pub fn wifi_usage_alerts(thresholds: Form<Threshold>, _auth: Authenticated) -> Flash<Redirect> {
|
||||||
match monitor::update_store(thresholds.into_inner()) {
|
match monitor::update_store(thresholds.into_inner()) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
debug!("WiFi data usage thresholds updated.");
|
debug!("WiFi data usage thresholds updated.");
|
||||||
@ -756,7 +756,7 @@ pub fn wifi_usage_alerts(thresholds: Form<Threshold>, auth: Authenticated) -> Fl
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[post("/api/v1/network/wifi/usage", data = "<thresholds>")]
|
#[post("/api/v1/network/wifi/usage", data = "<thresholds>")]
|
||||||
pub fn update_wifi_alerts(thresholds: Json<Threshold>, auth: Authenticated) -> Value {
|
pub fn update_wifi_alerts(thresholds: Json<Threshold>, _auth: Authenticated) -> Value {
|
||||||
match monitor::update_store(thresholds.into_inner()) {
|
match monitor::update_store(thresholds.into_inner()) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
debug!("WiFi data usage thresholds updated.");
|
debug!("WiFi data usage thresholds updated.");
|
||||||
@ -774,7 +774,7 @@ pub fn update_wifi_alerts(thresholds: Json<Threshold>, auth: Authenticated) -> V
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[post("/api/v1/network/wifi/usage/reset")]
|
#[post("/api/v1/network/wifi/usage/reset")]
|
||||||
pub fn reset_data_total(auth: Authenticated) -> Value {
|
pub fn reset_data_total(_auth: Authenticated) -> Value {
|
||||||
match monitor::reset_data() {
|
match monitor::reset_data() {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
debug!("Reset network data usage total.");
|
debug!("Reset network data usage total.");
|
||||||
@ -806,7 +806,7 @@ pub fn reset_data_total(auth: Authenticated) -> Value {
|
|||||||
// HELPERS AND ROUTES FOR ACCESS POINT ACTIVATION
|
// HELPERS AND ROUTES FOR ACCESS POINT ACTIVATION
|
||||||
|
|
||||||
#[post("/api/v1/network/activate_ap")]
|
#[post("/api/v1/network/activate_ap")]
|
||||||
pub fn activate_ap(auth: Authenticated) -> Value {
|
pub fn activate_ap(_auth: Authenticated) -> Value {
|
||||||
// activate the wireless access point
|
// activate the wireless access point
|
||||||
debug!("Activating WiFi access point.");
|
debug!("Activating WiFi access point.");
|
||||||
match network_client::activate_ap() {
|
match network_client::activate_ap() {
|
||||||
@ -825,7 +825,7 @@ pub fn activate_ap(auth: Authenticated) -> Value {
|
|||||||
// HELPERS AND ROUTES FOR WIFI CLIENT MANAGEMENT
|
// HELPERS AND ROUTES FOR WIFI CLIENT MANAGEMENT
|
||||||
|
|
||||||
#[post("/api/v1/network/activate_client")]
|
#[post("/api/v1/network/activate_client")]
|
||||||
pub fn activate_client(auth: Authenticated) -> Value {
|
pub fn activate_client(_auth: Authenticated) -> Value {
|
||||||
// activate the wireless client
|
// activate the wireless client
|
||||||
debug!("Activating WiFi client mode.");
|
debug!("Activating WiFi client mode.");
|
||||||
match network_client::activate_client() {
|
match network_client::activate_client() {
|
||||||
@ -842,7 +842,7 @@ pub fn activate_client(auth: Authenticated) -> Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[post("/api/v1/network/wifi", data = "<wifi>")]
|
#[post("/api/v1/network/wifi", data = "<wifi>")]
|
||||||
pub fn add_wifi(wifi: Json<WiFi>, auth: Authenticated) -> Value {
|
pub fn add_wifi(wifi: Json<WiFi>, _auth: Authenticated) -> Value {
|
||||||
// generate and write wifi config to wpa_supplicant
|
// generate and write wifi config to wpa_supplicant
|
||||||
match network_client::add(&wifi.ssid, &wifi.pass) {
|
match network_client::add(&wifi.ssid, &wifi.pass) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
@ -868,7 +868,7 @@ pub fn add_wifi(wifi: Json<WiFi>, auth: Authenticated) -> Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[post("/api/v1/network/wifi/connect", data = "<ssid>")]
|
#[post("/api/v1/network/wifi/connect", data = "<ssid>")]
|
||||||
pub fn connect_ap(ssid: Json<Ssid>, auth: Authenticated) -> Value {
|
pub fn connect_ap(ssid: Json<Ssid>, _auth: Authenticated) -> Value {
|
||||||
// retrieve the id for the given network ssid
|
// retrieve the id for the given network ssid
|
||||||
match network_client::id("wlan0", &ssid.ssid) {
|
match network_client::id("wlan0", &ssid.ssid) {
|
||||||
// attempt connection with the given network
|
// attempt connection with the given network
|
||||||
@ -893,7 +893,7 @@ pub fn connect_ap(ssid: Json<Ssid>, auth: Authenticated) -> Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[post("/api/v1/network/wifi/disconnect", data = "<ssid>")]
|
#[post("/api/v1/network/wifi/disconnect", data = "<ssid>")]
|
||||||
pub fn disconnect_ap(ssid: Json<Ssid>, auth: Authenticated) -> Value {
|
pub fn disconnect_ap(ssid: Json<Ssid>, _auth: Authenticated) -> Value {
|
||||||
// attempt to disable the current network for wlan0 interface
|
// attempt to disable the current network for wlan0 interface
|
||||||
match network_client::disable("wlan0", &ssid.ssid) {
|
match network_client::disable("wlan0", &ssid.ssid) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
@ -910,7 +910,7 @@ pub fn disconnect_ap(ssid: Json<Ssid>, auth: Authenticated) -> Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[post("/api/v1/network/wifi/forget", data = "<network>")]
|
#[post("/api/v1/network/wifi/forget", data = "<network>")]
|
||||||
pub fn forget_ap(network: Json<Ssid>, auth: Authenticated) -> Value {
|
pub fn forget_ap(network: Json<Ssid>, _auth: Authenticated) -> Value {
|
||||||
let ssid = &network.ssid;
|
let ssid = &network.ssid;
|
||||||
match network_client::forget("wlan0", ssid) {
|
match network_client::forget("wlan0", ssid) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
@ -929,7 +929,7 @@ pub fn forget_ap(network: Json<Ssid>, auth: Authenticated) -> Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[post("/api/v1/network/wifi/modify", data = "<wifi>")]
|
#[post("/api/v1/network/wifi/modify", data = "<wifi>")]
|
||||||
pub fn modify_password(wifi: Json<WiFi>, auth: Authenticated) -> Value {
|
pub fn modify_password(wifi: Json<WiFi>, _auth: Authenticated) -> Value {
|
||||||
let ssid = &wifi.ssid;
|
let ssid = &wifi.ssid;
|
||||||
let pass = &wifi.pass;
|
let pass = &wifi.pass;
|
||||||
// we are using a helper function (`update`) to delete the old
|
// we are using a helper function (`update`) to delete the old
|
||||||
@ -954,7 +954,7 @@ pub fn modify_password(wifi: Json<WiFi>, auth: Authenticated) -> Value {
|
|||||||
// HELPERS AND ROUTES FOR NETWORK STATE QUERIES
|
// HELPERS AND ROUTES FOR NETWORK STATE QUERIES
|
||||||
|
|
||||||
#[get("/api/v1/network/ip")]
|
#[get("/api/v1/network/ip")]
|
||||||
pub fn return_ip(auth: Authenticated) -> Value {
|
pub fn return_ip(_auth: Authenticated) -> Value {
|
||||||
// retrieve ip for wlan0 or set to x.x.x.x if not found
|
// retrieve ip for wlan0 or set to x.x.x.x if not found
|
||||||
let wlan_ip = match network_client::ip("wlan0") {
|
let wlan_ip = match network_client::ip("wlan0") {
|
||||||
Ok(ip) => ip,
|
Ok(ip) => ip,
|
||||||
@ -974,7 +974,7 @@ pub fn return_ip(auth: Authenticated) -> Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/api/v1/network/rssi")]
|
#[get("/api/v1/network/rssi")]
|
||||||
pub fn return_rssi(auth: Authenticated) -> Value {
|
pub fn return_rssi(_auth: Authenticated) -> Value {
|
||||||
// retrieve rssi for connected network
|
// retrieve rssi for connected network
|
||||||
match network_client::rssi("wlan0") {
|
match network_client::rssi("wlan0") {
|
||||||
Ok(rssi) => {
|
Ok(rssi) => {
|
||||||
@ -991,7 +991,7 @@ pub fn return_rssi(auth: Authenticated) -> Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/api/v1/network/ssid")]
|
#[get("/api/v1/network/ssid")]
|
||||||
pub fn return_ssid(auth: Authenticated) -> Value {
|
pub fn return_ssid(_auth: Authenticated) -> Value {
|
||||||
// retrieve ssid for connected network
|
// retrieve ssid for connected network
|
||||||
match network_client::ssid("wlan0") {
|
match network_client::ssid("wlan0") {
|
||||||
Ok(network) => {
|
Ok(network) => {
|
||||||
@ -1008,7 +1008,7 @@ pub fn return_ssid(auth: Authenticated) -> Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/api/v1/network/state")]
|
#[get("/api/v1/network/state")]
|
||||||
pub fn return_state(auth: Authenticated) -> Value {
|
pub fn return_state(_auth: Authenticated) -> Value {
|
||||||
// retrieve state of wlan0 or set to x.x.x.x if not found
|
// retrieve state of wlan0 or set to x.x.x.x if not found
|
||||||
let wlan_state = match network_client::state("wlan0") {
|
let wlan_state = match network_client::state("wlan0") {
|
||||||
Ok(state) => state,
|
Ok(state) => state,
|
||||||
@ -1028,7 +1028,7 @@ pub fn return_state(auth: Authenticated) -> Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/api/v1/network/status")]
|
#[get("/api/v1/network/status")]
|
||||||
pub fn return_status(auth: Authenticated) -> Value {
|
pub fn return_status(_auth: Authenticated) -> Value {
|
||||||
// retrieve status info for wlan0 interface
|
// retrieve status info for wlan0 interface
|
||||||
match network_client::status("wlan0") {
|
match network_client::status("wlan0") {
|
||||||
Ok(network) => {
|
Ok(network) => {
|
||||||
@ -1045,7 +1045,7 @@ pub fn return_status(auth: Authenticated) -> Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/api/v1/network/wifi")]
|
#[get("/api/v1/network/wifi")]
|
||||||
pub fn scan_networks(auth: Authenticated) -> Value {
|
pub fn scan_networks(_auth: Authenticated) -> Value {
|
||||||
// retrieve scan results for access-points within range of wlan0
|
// retrieve scan results for access-points within range of wlan0
|
||||||
match network_client::available_networks("wlan0") {
|
match network_client::available_networks("wlan0") {
|
||||||
Ok(networks) => {
|
Ok(networks) => {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
pub mod monitor;
|
pub mod monitor;
|
||||||
|
|
||||||
use rocket_dyn_templates::Template;
|
use rocket_dyn_templates::Template;
|
||||||
use rocket::request::Request;
|
|
||||||
use rocket::response::{Redirect, Responder};
|
use rocket::response::{Redirect, Responder};
|
||||||
use rocket::serde::json::{Value, json};
|
use rocket::serde::json::{Value, json};
|
||||||
use rocket::serde::{Serialize};
|
use rocket::serde::{Serialize};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user