log ips of post requests
All checks were successful
Build .deb on release / Build-Deb (push) Successful in 1m53s
All checks were successful
Build .deb on release / Build-Deb (push) Successful in 1m53s
This commit is contained in:
parent
dc234260c7
commit
a817e1b5f7
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -2633,7 +2633,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tesla-charge-controller"
|
||||
version = "1.0.23"
|
||||
version = "1.0.24"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"clap 4.4.11",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "tesla-charge-controller"
|
||||
version = "1.0.23"
|
||||
version = "1.0.24"
|
||||
edition = "2021"
|
||||
license = "MITNFA"
|
||||
description = "Controls Tesla charge rate based on solar charge data"
|
||||
|
|
|
@ -50,7 +50,6 @@ impl ConfigWatcher {
|
|||
loop {
|
||||
match rx.recv().await {
|
||||
Some(Ok(_event)) => {
|
||||
log::warn!("Reloading config");
|
||||
let mut config = Config::load(&config_path);
|
||||
config.validate();
|
||||
if let Some(mut c) = CONFIG.get().and_then(|v| v.write().ok()) {
|
||||
|
@ -99,7 +98,6 @@ impl<'a> DerefMut for ConfigHandle<'a> {
|
|||
|
||||
impl<'a> Drop for ConfigHandle<'a> {
|
||||
fn drop(&mut self) {
|
||||
log::warn!("saving config...");
|
||||
let _ = self.save().some_or_print_with("saving config");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,12 +116,14 @@ async fn control_state(state: &State<ServerState>) -> Result<Json<ControlState>,
|
|||
}
|
||||
|
||||
#[post("/flash")]
|
||||
async fn flash(state: &State<ServerState>) {
|
||||
async fn flash(state: &State<ServerState>, remote_addr: std::net::SocketAddr) {
|
||||
log::warn!("flash requested: {remote_addr:?}");
|
||||
let _ = state.api_requests.send(InterfaceRequest::FlashLights);
|
||||
}
|
||||
|
||||
#[post("/disable-control")]
|
||||
async fn disable_control(state: &State<ServerState>) {
|
||||
async fn disable_control(state: &State<ServerState>, remote_addr: std::net::SocketAddr) {
|
||||
log::warn!("disabling control: {remote_addr:?}");
|
||||
match state
|
||||
.tcrc_requests
|
||||
.send(TcrcRequest::DisableAutomaticControl)
|
||||
|
@ -132,7 +134,8 @@ async fn disable_control(state: &State<ServerState>) {
|
|||
}
|
||||
|
||||
#[post("/enable-control")]
|
||||
async fn enable_control(state: &State<ServerState>) {
|
||||
async fn enable_control(state: &State<ServerState>, remote_addr: std::net::SocketAddr) {
|
||||
log::warn!("enabling control: {remote_addr:?}");
|
||||
match state
|
||||
.tcrc_requests
|
||||
.send(TcrcRequest::EnableAutomaticControl)
|
||||
|
@ -143,35 +146,35 @@ async fn enable_control(state: &State<ServerState>) {
|
|||
}
|
||||
|
||||
#[post("/set-max/<limit>")]
|
||||
async fn set_max(limit: i64) -> String {
|
||||
async fn set_max(limit: i64, remote_addr: std::net::SocketAddr) {
|
||||
log::warn!("setting max: {remote_addr:?}");
|
||||
let limit = limit.clamp(access_config().min_rate, 15);
|
||||
write_to_config().max_rate = limit;
|
||||
format!("set upper limit to {limit}")
|
||||
}
|
||||
|
||||
#[post("/set-min/<limit>")]
|
||||
async fn set_min(limit: i64) -> String {
|
||||
async fn set_min(limit: i64, remote_addr: std::net::SocketAddr) {
|
||||
log::warn!("setting min: {remote_addr:?}");
|
||||
let limit = limit.clamp(3, access_config().max_rate);
|
||||
write_to_config().min_rate = limit;
|
||||
format!("set lower limit to {limit}")
|
||||
}
|
||||
|
||||
#[post("/pid-settings/proportional/<gain>")]
|
||||
async fn set_proportional_gain(gain: f64) -> String {
|
||||
async fn set_proportional_gain(gain: f64, remote_addr: std::net::SocketAddr) {
|
||||
log::warn!("setting proportional gain: {remote_addr:?}");
|
||||
write_to_config().pid_controls.proportional_gain = gain;
|
||||
format!("set proportional gain to {gain}")
|
||||
}
|
||||
|
||||
#[post("/pid-settings/derivative/<gain>")]
|
||||
async fn set_derivative_gain(gain: f64) -> String {
|
||||
async fn set_derivative_gain(gain: f64, remote_addr: std::net::SocketAddr) {
|
||||
log::warn!("setting derivative gain: {remote_addr:?}");
|
||||
write_to_config().pid_controls.derivative_gain = gain;
|
||||
format!("set derivative gain to {gain}")
|
||||
}
|
||||
|
||||
#[post("/pid-settings/loop_time_seconds/<time>")]
|
||||
async fn set_pid_loop_length(time: u64) -> String {
|
||||
async fn set_pid_loop_length(time: u64, remote_addr: std::net::SocketAddr) {
|
||||
log::warn!("setting pid loop interval: {remote_addr:?}");
|
||||
write_to_config().pid_controls.loop_time_seconds = time;
|
||||
format!("set pid loop length to {time} seconds")
|
||||
}
|
||||
|
||||
#[get("/pid-settings/status")]
|
||||
|
|
Loading…
Reference in a new issue