mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-13 15:44: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",
|
"duct",
|
||||||
"file_diff",
|
"file_diff",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
|
"getopts",
|
||||||
"http",
|
"http",
|
||||||
"hudsucker",
|
"hudsucker",
|
||||||
"is_elevated",
|
"is_elevated",
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ tauri = { version = "1.0.7", features = ["api-all"] }
|
|||||||
|
|
||||||
# Arg parsing
|
# Arg parsing
|
||||||
args = "2.0"
|
args = "2.0"
|
||||||
|
getopts = "0.2"
|
||||||
|
|
||||||
# Access system process info.
|
# Access system process info.
|
||||||
sysinfo = "0.24.6"
|
sysinfo = "0.24.6"
|
||||||
|
|||||||
@@ -3,9 +3,12 @@
|
|||||||
windows_subsystem = "windows"
|
windows_subsystem = "windows"
|
||||||
)]
|
)]
|
||||||
|
|
||||||
|
use args::validations::{Order, OrderValidation};
|
||||||
use args::{Args, ArgsError};
|
use args::{Args, ArgsError};
|
||||||
use file_helpers::dir_exists;
|
use file_helpers::dir_exists;
|
||||||
|
use getopts;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
use proxy::set_proxy_addr;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::{collections::HashMap, sync::Mutex};
|
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("g", "no-gui", "Run in CLI mode");
|
||||||
args.flag("s", "server", "Launch the configured GC server");
|
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();
|
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")? {
|
if args.value_of("proxy")? {
|
||||||
println!("Starting proxy server...");
|
println!("Starting proxy server...");
|
||||||
let mut pathbuf = tauri::api::path::data_dir().unwrap();
|
let mut pathbuf = tauri::api::path::data_dir().unwrap();
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ pub fn set_proxy_addr(addr: String) {
|
|||||||
} else {
|
} else {
|
||||||
*SERVER.lock().unwrap() = addr;
|
*SERVER.lock().unwrap() = addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println!("Set server to {}", SERVER.lock().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
|||||||
Reference in New Issue
Block a user