mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-13 15:44:35 +01:00
Redirect more domains
This commit is contained in:
@@ -26,6 +26,7 @@ pub struct Configuration {
|
||||
pub horny_mode: Option<bool>,
|
||||
pub auto_mongodb: Option<bool>,
|
||||
pub un_elevated: Option<bool>,
|
||||
pub redirect_more: Option<bool>,
|
||||
}
|
||||
|
||||
pub fn config_path() -> PathBuf {
|
||||
|
||||
@@ -230,12 +230,11 @@ fn main() -> Result<(), ArgsError> {
|
||||
gamebanana::list_submissions,
|
||||
gamebanana::list_mods
|
||||
])
|
||||
.on_window_event(|event| match event.event() {
|
||||
tauri::WindowEvent::CloseRequested { api, .. } => {
|
||||
.on_window_event(|event| {
|
||||
if let tauri::WindowEvent::CloseRequested { .. } = event.event() {
|
||||
// Ensure all proxy stuff is handled
|
||||
disconnect();
|
||||
}
|
||||
_ => {}
|
||||
})
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* https://github.com/omjadas/hudsucker/blob/main/examples/log.rs
|
||||
*/
|
||||
|
||||
use crate::config::get_config;
|
||||
#[cfg(target_os = "linux")]
|
||||
use crate::system_helpers::run_command;
|
||||
|
||||
@@ -60,24 +61,86 @@ impl HttpHandler for ProxyHandler {
|
||||
) -> RequestOrResponse {
|
||||
let uri = req.uri().to_string();
|
||||
|
||||
if uri.contains("hoyoverse.com") || uri.contains("mihoyo.com") || uri.contains("yuanshen.com") {
|
||||
// Handle CONNECTs
|
||||
if req.method().as_str() == "CONNECT" {
|
||||
let builder = Response::builder()
|
||||
.header("DecryptEndpoint", "Created")
|
||||
.status(StatusCode::OK);
|
||||
let res = builder.body(()).unwrap();
|
||||
match get_config().redirect_more {
|
||||
Some(true) => {
|
||||
if uri.contains("hoyoverse.com")
|
||||
|| uri.contains("mihoyo.com")
|
||||
|| uri.contains("yuanshen.com")
|
||||
|| uri.contains("starrails.com")
|
||||
|| uri.contains("bhsr.com")
|
||||
|| uri.contains("bh3.com")
|
||||
|| uri.contains("honkaiimpact3.com")
|
||||
{
|
||||
// Handle CONNECTs
|
||||
if req.method().as_str() == "CONNECT" {
|
||||
let builder = Response::builder()
|
||||
.header("DecryptEndpoint", "Created")
|
||||
.status(StatusCode::OK);
|
||||
let res = builder.body(()).unwrap();
|
||||
|
||||
// Respond to CONNECT
|
||||
*res.body()
|
||||
} else {
|
||||
let uri_path_and_query = req.uri().path_and_query().unwrap().as_str();
|
||||
// Create new URI.
|
||||
let new_uri =
|
||||
Uri::from_str(format!("{}{}", SERVER.lock().unwrap(), uri_path_and_query).as_str())
|
||||
.unwrap();
|
||||
// Set request URI to the new one.
|
||||
*req.uri_mut() = new_uri;
|
||||
// Respond to CONNECT
|
||||
*res.body()
|
||||
} else {
|
||||
let uri_path_and_query = req.uri().path_and_query().unwrap().as_str();
|
||||
// Create new URI.
|
||||
let new_uri =
|
||||
Uri::from_str(format!("{}{}", SERVER.lock().unwrap(), uri_path_and_query).as_str())
|
||||
.unwrap();
|
||||
// Set request URI to the new one.
|
||||
*req.uri_mut() = new_uri;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(false) => {
|
||||
if uri.contains("hoyoverse.com")
|
||||
|| uri.contains("mihoyo.com")
|
||||
|| uri.contains("yuanshen.com")
|
||||
{
|
||||
// Handle CONNECTs
|
||||
if req.method().as_str() == "CONNECT" {
|
||||
let builder = Response::builder()
|
||||
.header("DecryptEndpoint", "Created")
|
||||
.status(StatusCode::OK);
|
||||
let res = builder.body(()).unwrap();
|
||||
|
||||
// Respond to CONNECT
|
||||
*res.body()
|
||||
} else {
|
||||
let uri_path_and_query = req.uri().path_and_query().unwrap().as_str();
|
||||
// Create new URI.
|
||||
let new_uri =
|
||||
Uri::from_str(format!("{}{}", SERVER.lock().unwrap(), uri_path_and_query).as_str())
|
||||
.unwrap();
|
||||
// Set request URI to the new one.
|
||||
*req.uri_mut() = new_uri;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Use default as fallback
|
||||
None => {
|
||||
if uri.contains("hoyoverse.com")
|
||||
|| uri.contains("mihoyo.com")
|
||||
|| uri.contains("yuanshen.com")
|
||||
{
|
||||
// Handle CONNECTs
|
||||
if req.method().as_str() == "CONNECT" {
|
||||
let builder = Response::builder()
|
||||
.header("DecryptEndpoint", "Created")
|
||||
.status(StatusCode::OK);
|
||||
let res = builder.body(()).unwrap();
|
||||
|
||||
// Respond to CONNECT
|
||||
*res.body()
|
||||
} else {
|
||||
let uri_path_and_query = req.uri().path_and_query().unwrap().as_str();
|
||||
// Create new URI.
|
||||
let new_uri =
|
||||
Uri::from_str(format!("{}{}", SERVER.lock().unwrap(), uri_path_and_query).as_str())
|
||||
.unwrap();
|
||||
// Set request URI to the new one.
|
||||
*req.uri_mut() = new_uri;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user