mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-12 15:14:35 +01:00
set host
This commit is contained in:
1
src-tauri/Cargo.lock
generated
1
src-tauri/Cargo.lock
generated
@@ -796,6 +796,7 @@ dependencies = [
|
||||
"duct",
|
||||
"file_diff",
|
||||
"futures-util",
|
||||
"getopts",
|
||||
"http",
|
||||
"hudsucker",
|
||||
"is_elevated",
|
||||
|
||||
@@ -28,6 +28,7 @@ tauri = { version = "1.0.7", features = ["api-all"] }
|
||||
|
||||
# Arg parsing
|
||||
args = "2.0"
|
||||
getopts = "0.2"
|
||||
|
||||
# Access system process info.
|
||||
sysinfo = "0.24.6"
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
windows_subsystem = "windows"
|
||||
)]
|
||||
|
||||
use args::validations::{Order, OrderValidation};
|
||||
use args::{Args, ArgsError};
|
||||
use file_helpers::dir_exists;
|
||||
use getopts;
|
||||
use once_cell::sync::Lazy;
|
||||
use proxy::set_proxy_addr;
|
||||
use std::fs;
|
||||
use std::io::Write;
|
||||
use std::{collections::HashMap, sync::Mutex};
|
||||
@@ -53,6 +56,14 @@ async fn parse_args(inp: &Vec<String>) -> Result<Args, ArgsError> {
|
||||
);
|
||||
args.flag("g", "no-gui", "Run in CLI mode");
|
||||
args.flag("s", "server", "Launch the configured GC server");
|
||||
args.option(
|
||||
"H",
|
||||
"host",
|
||||
"Host to connect to (eg. 'localhost:443' or 'my.awesomeserver.com:6969)",
|
||||
"SERVER_HOST",
|
||||
getopts::Occur::Optional,
|
||||
None,
|
||||
);
|
||||
|
||||
args.parse(inp).unwrap();
|
||||
|
||||
@@ -82,6 +93,11 @@ async fn parse_args(inp: &Vec<String>) -> Result<Args, ArgsError> {
|
||||
);
|
||||
}
|
||||
|
||||
if !args.value_of::<String>("host")?.is_empty() {
|
||||
let host = args.value_of::<String>("host")?;
|
||||
set_proxy_addr(host);
|
||||
}
|
||||
|
||||
if args.value_of("proxy")? {
|
||||
println!("Starting proxy server...");
|
||||
let mut pathbuf = tauri::api::path::data_dir().unwrap();
|
||||
|
||||
@@ -47,6 +47,8 @@ pub fn set_proxy_addr(addr: String) {
|
||||
} else {
|
||||
*SERVER.lock().unwrap() = addr;
|
||||
}
|
||||
|
||||
println!("Set server to {}", SERVER.lock().unwrap());
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
|
||||
Reference in New Issue
Block a user