mirror of https://github.com/ospab/ostp.git
Fix hot-reloader clearing access keys due to modular config migration
This commit is contained in:
parent
3efbfd75cc
commit
7fadc8d28d
|
|
@ -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
|
# 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
|
# 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.
|
# 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:
|
environment:
|
||||||
sdk: ^3.11.4
|
sdk: ^3.11.4
|
||||||
|
|
|
||||||
|
|
@ -2665,7 +2665,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ostp-client"
|
name = "ostp-client"
|
||||||
version = "0.3.9"
|
version = "0.3.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
|
|
@ -2700,7 +2700,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ostp-core"
|
name = "ostp-core"
|
||||||
version = "0.3.9"
|
version = "0.3.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
|
|
@ -2742,7 +2742,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ostp-tun"
|
name = "ostp-tun"
|
||||||
version = "0.3.9"
|
version = "0.3.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"libc",
|
"libc",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "ostp-gui",
|
"productName": "ostp-gui",
|
||||||
"version": "0.3.9",
|
"version": "0.3.10",
|
||||||
"identifier": "com.ospab.ostp",
|
"identifier": "com.ospab.ostp",
|
||||||
"build": {
|
"build": {
|
||||||
"frontendDist": "../src"
|
"frontendDist": "../src"
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,8 @@ pub async fn run_server(
|
||||||
mode: String,
|
mode: String,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
access_keys: Vec<ReloadUser>,
|
access_keys: Vec<ReloadUser>,
|
||||||
|
#[serde(default)]
|
||||||
|
inbounds: Vec<serde_json::Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut stripped = json_comments::StripComments::new(content.as_bytes());
|
let mut stripped = json_comments::StripComments::new(content.as_bytes());
|
||||||
|
|
@ -181,7 +183,23 @@ pub async fn run_server(
|
||||||
Ok(cfg) => {
|
Ok(cfg) => {
|
||||||
if cfg.mode == "server" {
|
if cfg.mode == "server" {
|
||||||
let mut new_keys = HashMap::new();
|
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::<ReloadUser>(u.clone()) {
|
||||||
|
all_users.push(ru);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for uc in all_users {
|
||||||
let (k, m) = match uc {
|
let (k, m) = match uc {
|
||||||
ReloadUser::Detailed { access_key, name, limit_bytes } => (access_key, crate::api::UserMeta { name, limit_bytes }),
|
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 }),
|
ReloadUser::KeyOnly(k) => (k, crate::api::UserMeta { name: None, limit_bytes: None }),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue