feat: add unified Tauri desktop client and secure web access
This commit is contained in:
+17
-1
@@ -15,6 +15,9 @@ struct Args {
|
||||
/// 加载vnt配置路径,配置内容参考web端的配置格式
|
||||
#[clap(long)]
|
||||
conf: Option<PathBuf>,
|
||||
/// Web API 访问令牌;未指定时会生成随机令牌并输出到日志
|
||||
#[clap(long, env = "VNT_WEB_TOKEN")]
|
||||
token: Option<String>,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
@@ -31,6 +34,19 @@ async fn main0() -> anyhow::Result<()> {
|
||||
#[cfg(windows)]
|
||||
extract_wintun_dll::extract_wintun();
|
||||
let addr = args.addr.unwrap_or("127.0.0.1:19099".parse()?);
|
||||
vnt_web::run_http_server(addr, args.conf).await?;
|
||||
let token = args.token.unwrap_or_else(vnt_web::generate_access_token);
|
||||
let browser_host = if addr.ip().is_unspecified() {
|
||||
"127.0.0.1".to_string()
|
||||
} else {
|
||||
addr.ip().to_string()
|
||||
};
|
||||
log::info!("Web access token: {}", token);
|
||||
log::info!(
|
||||
"Web access URL: http://{}:{}/?token={}",
|
||||
browser_host,
|
||||
addr.port(),
|
||||
token
|
||||
);
|
||||
vnt_web::run_http_server(addr, args.conf, token).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user