diff --git a/.env.example b/.env.example
index 96998ca..38665a1 100644
--- a/.env.example
+++ b/.env.example
@@ -1,4 +1,4 @@
-# Example .env file for Linspirer MITM Server
+# Example .env file for My Linspirer MITM Server
# Copy this to .env and fill in your values
# Required: AES-128 encryption key (16 characters)
diff --git a/frontend/src/components/RulesList.tsx b/frontend/src/components/RulesList.tsx
index 00ce596..f576159 100644
--- a/frontend/src/components/RulesList.tsx
+++ b/frontend/src/components/RulesList.tsx
@@ -26,6 +26,9 @@ const RulesList: Component = () => {
if (!confirm('Are you sure you want to delete this rule?')) return;
try {
+ if (id === editingId()) {
+ setShowEditor(false);
+ }
await rulesApi.delete(id);
refetch();
} catch (err) {
@@ -126,28 +129,13 @@ const RulesList: Component = () => {
- setEditingMethod(e.currentTarget.value)}
- class="w-full border border-gray-300 rounded-md px-3 py-2"
- placeholder="com.linspirer.method.name"
- />
- }
- >
-
-
+ setEditingMethod(e.currentTarget.value)}
+ class="w-full border border-gray-300 rounded-md px-3 py-2"
+ placeholder="com.linspirer.method.name"
+ />
@@ -190,74 +178,71 @@ const RulesList: Component = () => {
-
-
-
- |
- Method Name
- |
-
- Action
- |
-
- Status
- |
-
- Actions
- |
-
-
-
- Loading... |
- }>
-
- {(rule) => (
-
- |
- {rule.method_name}
- |
-
-
- {rule.action}
-
- |
-
-
- |
-
-
-
- |
-
- )}
-
-
-
-
+
+
+
+
+ |
+ Method Name
+ |
+
+ Action
+ |
+
+ Status
+ |
+
+ Actions
+ |
+
+
+
+ Loading... |
+ }>
+
+ {(rule) => (
+
+ |
+ {rule.method_name}
+ |
+
+
+ {rule.action}
+
+ |
+
+
+ |
+
+
+
+ |
+
+ )}
+
+
+
+
+
);
diff --git a/src/jsonrpc/tactics.rs b/src/jsonrpc/tactics.rs
index 164921b..c52279d 100644
--- a/src/jsonrpc/tactics.rs
+++ b/src/jsonrpc/tactics.rs
@@ -21,7 +21,6 @@ pub struct Tactics {
pub name: String,
#[serde_as(as = "BoolFromInt")]
pub release_control: bool,
- // TODO: std::time::Instant
pub updated_at: String,
#[serde(rename = "usergroup")]
pub user_group: u32,
@@ -42,7 +41,6 @@ pub struct AppTactics {
pub struct App {
#[serde(rename = "canuninstall")]
can_uninstall: bool,
- // TODO: std::time::Instant
created_at: String,
#[serde(rename = "devicetype")]
device_type: String,
@@ -67,7 +65,6 @@ pub struct App {
sort_weight: i32,
status: i32,
target_sdk_version: i32,
- // TODO: std::time::Instant
updated_at: String,
#[serde(rename = "versioncode")]
version_code: i32,
diff --git a/src/main.rs b/src/main.rs
index 472a9e9..9aea8ec 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,7 +1,7 @@
use std::{net::SocketAddr, sync::Arc};
use anyhow::Context;
-use axum::Router;
+use axum::{Router, routing::any};
use axum::handler::Handler;
use dotenvy::dotenv;
use tower_http::compression::CompressionLayer;
@@ -80,15 +80,15 @@ async fn main() -> anyhow::Result<()> {
commands: Default::default(),
});
- let log_middleware =
- axum::middleware::from_fn_with_state(state.clone(), middleware::log_middleware);
+ let proxy_middleware =
+ axum::middleware::from_fn_with_state(state.clone(), middleware::middleware);
// Build our application
let app = Router::new()
// Admin routes
.nest("/admin", admin::routes::admin_routes(state.clone()))
- // Proxy all other routes (fallback)
- .fallback(proxy::proxy_handler.layer(log_middleware))
+ // Proxy Linspirer APIs
+ .route("/public-interface.php", any(proxy::proxy_handler.layer(proxy_middleware)))
.layer(CompressionLayer::new().gzip(true))
.with_state(state);
diff --git a/src/middleware.rs b/src/middleware.rs
index c0e5380..7802e1e 100644
--- a/src/middleware.rs
+++ b/src/middleware.rs
@@ -18,7 +18,7 @@ enum ResponseBody {
Modified(Value),
}
-pub async fn log_middleware(
+pub async fn middleware(
State(state): State>,
OriginalUri(uri): OriginalUri,
req: Request,
@@ -39,7 +39,7 @@ pub async fn log_middleware(
let path = uri.path();
- let (decrypted_request_log, method) = match str::from_utf8(&body_bytes)
+ let (decrypted_request_for_log, method) = match str::from_utf8(&body_bytes)
.map_err(anyhow::Error::from)
.and_then(|body| process_and_log_request(body, &state.key, &state.iv))
{
@@ -125,7 +125,7 @@ pub async fn log_middleware(
debug!(
"{}\nRequest:\n{}\nResponse:\n{}\n{}",
path,
- serde_json::to_string_pretty(&decrypted_request_log).unwrap_or_default(),
+ serde_json::to_string_pretty(&decrypted_request_for_log).unwrap_or_default(),
decrypted_response_for_log,
"-".repeat(80),
);