From 7fadc8d28dc9ce7c8f608f8f0f35c57d4a11b6fc Mon Sep 17 00:00:00 2001 From: ospab Date: Fri, 19 Jun 2026 15:44:55 +0300 Subject: [PATCH] Fix hot-reloader clearing access keys due to modular config migration --- ostp-flutter/pubspec.yaml | 2 +- ostp-gui/src-tauri/Cargo.lock | 6 +++--- ostp-gui/src-tauri/tauri.conf.json | 2 +- ostp-server/src/lib.rs | 20 +++++++++++++++++++- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/ostp-flutter/pubspec.yaml b/ostp-flutter/pubspec.yaml index 5269a02..b5d3d5a 100644 --- a/ostp-flutter/pubspec.yaml +++ b/ostp-flutter/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 0.3.9+22 +version: 0.3.10+23 environment: sdk: ^3.11.4 diff --git a/ostp-gui/src-tauri/Cargo.lock b/ostp-gui/src-tauri/Cargo.lock index f3567b4..2d6ff7b 100644 --- a/ostp-gui/src-tauri/Cargo.lock +++ b/ostp-gui/src-tauri/Cargo.lock @@ -2665,7 +2665,7 @@ dependencies = [ [[package]] name = "ostp-client" -version = "0.3.9" +version = "0.3.10" dependencies = [ "anyhow", "base64 0.22.1", @@ -2700,7 +2700,7 @@ dependencies = [ [[package]] name = "ostp-core" -version = "0.3.9" +version = "0.3.10" dependencies = [ "anyhow", "byteorder", @@ -2742,7 +2742,7 @@ dependencies = [ [[package]] name = "ostp-tun" -version = "0.3.9" +version = "0.3.10" dependencies = [ "anyhow", "libc", diff --git a/ostp-gui/src-tauri/tauri.conf.json b/ostp-gui/src-tauri/tauri.conf.json index a8bfde1..e21950f 100644 --- a/ostp-gui/src-tauri/tauri.conf.json +++ b/ostp-gui/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "ostp-gui", - "version": "0.3.9", + "version": "0.3.10", "identifier": "com.ospab.ostp", "build": { "frontendDist": "../src" diff --git a/ostp-server/src/lib.rs b/ostp-server/src/lib.rs index f6f4e01..d54aca6 100644 --- a/ostp-server/src/lib.rs +++ b/ostp-server/src/lib.rs @@ -167,6 +167,8 @@ pub async fn run_server( mode: String, #[serde(default)] access_keys: Vec, + #[serde(default)] + inbounds: Vec, } let mut stripped = json_comments::StripComments::new(content.as_bytes()); @@ -181,7 +183,23 @@ pub async fn run_server( Ok(cfg) => { if cfg.mode == "server" { let mut new_keys = HashMap::new(); - for uc in cfg.access_keys { + let mut all_users = cfg.access_keys; + + for inbound in cfg.inbounds { + if let Some(protocol) = inbound.get("protocol").and_then(|p| p.as_str()) { + if protocol == "ostp" { + if let Some(users) = inbound.get("users").and_then(|u| u.as_array()) { + for u in users { + if let Ok(ru) = serde_json::from_value::(u.clone()) { + all_users.push(ru); + } + } + } + } + } + } + + for uc in all_users { let (k, m) = match uc { ReloadUser::Detailed { access_key, name, limit_bytes } => (access_key, crate::api::UserMeta { name, limit_bytes }), ReloadUser::KeyOnly(k) => (k, crate::api::UserMeta { name: None, limit_bytes: None }),