From c0ad84a491f61e869c55c04903316c86ce8494ad Mon Sep 17 00:00:00 2001
From: GyDi <segydi@foxmail.com>
Date: Tue, 8 Mar 2022 01:45:46 +0800
Subject: [PATCH] fix: limit enhanced profile range

---
 src-tauri/src/core/clash.rs | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/src-tauri/src/core/clash.rs b/src-tauri/src/core/clash.rs
index dad2ab7..6e200d0 100644
--- a/src-tauri/src/core/clash.rs
+++ b/src-tauri/src/core/clash.rs
@@ -320,9 +320,28 @@ impl Clash {
         let result: PrfEnhancedResult = serde_json::from_str(result).unwrap();
 
         if let Some(data) = result.data {
+          // all of these can not be revised by script
+          // http/https/socks port should be under control
+          let not_allow: Vec<Value> = vec![
+            "port",
+            "socks-port",
+            "mixed-port",
+            "allow-lan",
+            "mode",
+            "external-controller",
+            "secret",
+            "log-level",
+          ]
+          .iter()
+          .map(|&i| Value::from(i))
+          .collect();
+
           for (key, value) in data.into_iter() {
-            config.insert(key, value);
+            if not_allow.iter().find(|&i| i == &key).is_none() {
+              config.insert(key, value);
+            }
           }
+
           Self::_activate(info, config).unwrap();
         }
 
-- 
GitLab