mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 08:45:41 +08:00
fix: dynamically modify pac content (#5468)
* fix: dynamically modify pac content * docs: update Changelog.md
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
- macOS service 启动项显示名称(试验性修改)
|
||||
- macOS 非预期 Tproxy 端口设置
|
||||
- 流量图缩放异常
|
||||
- PAC 自动代理脚本内容无法动态调整
|
||||
|
||||
<details>
|
||||
<summary><strong> ✨ 新增功能 </strong></summary>
|
||||
|
||||
@@ -73,7 +73,6 @@ pub fn embed_server() {
|
||||
.expect("failed to set shutdown signal for embedded server");
|
||||
let port = IVerge::get_singleton_port();
|
||||
|
||||
AsyncHandler::spawn(move || async move {
|
||||
let visible = warp::path!("commands" / "visible").and_then(|| async {
|
||||
logging!(info, Type::Window, "检测到从单例模式恢复应用窗口");
|
||||
if !lightweight::exit_lightweight_mode().await {
|
||||
@@ -87,6 +86,7 @@ pub fn embed_server() {
|
||||
))
|
||||
});
|
||||
|
||||
let pac = warp::path!("commands" / "pac").and_then(|| async move {
|
||||
let verge_config = Config::verge().await;
|
||||
let clash_config = Config::clash().await;
|
||||
|
||||
@@ -100,13 +100,13 @@ pub fn embed_server() {
|
||||
.data_arc()
|
||||
.verge_mixed_port
|
||||
.unwrap_or_else(|| clash_config.data_arc().get_mixed_port());
|
||||
|
||||
let pac = warp::path!("commands" / "pac").map(move || {
|
||||
let processed_content = pac_content.replace("%mixed-port%", &format!("{pac_port}"));
|
||||
Ok::<_, warp::Rejection>(
|
||||
warp::http::Response::builder()
|
||||
.header("Content-Type", "application/x-ns-proxy-autoconfig")
|
||||
.body(processed_content)
|
||||
.unwrap_or_default()
|
||||
.unwrap_or_default(),
|
||||
)
|
||||
});
|
||||
|
||||
// Use map instead of and_then to avoid Send issues
|
||||
@@ -123,6 +123,8 @@ pub fn embed_server() {
|
||||
});
|
||||
|
||||
let commands = visible.or(scheme).or(pac);
|
||||
|
||||
AsyncHandler::spawn(move || async move {
|
||||
warp::serve(commands)
|
||||
.bind(([127, 0, 0, 1], port))
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user