mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-13 07:34:36 +01:00
Redirect more domains
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
"port_placeholder": "Port...",
|
"port_placeholder": "Port...",
|
||||||
"files_downloading": "Files Downloading: ",
|
"files_downloading": "Files Downloading: ",
|
||||||
"files_extracting": "Files Extracting: ",
|
"files_extracting": "Files Extracting: ",
|
||||||
"game_path_notify": "Game path not found, remember to set it in !"
|
"game_path_notify": "Game path not found, remember to set it in settings!"
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"enabled": "Enabled",
|
"enabled": "Enabled",
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ pub struct Configuration {
|
|||||||
pub horny_mode: Option<bool>,
|
pub horny_mode: Option<bool>,
|
||||||
pub auto_mongodb: Option<bool>,
|
pub auto_mongodb: Option<bool>,
|
||||||
pub un_elevated: Option<bool>,
|
pub un_elevated: Option<bool>,
|
||||||
|
pub redirect_more: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn config_path() -> PathBuf {
|
pub fn config_path() -> PathBuf {
|
||||||
|
|||||||
@@ -230,12 +230,11 @@ fn main() -> Result<(), ArgsError> {
|
|||||||
gamebanana::list_submissions,
|
gamebanana::list_submissions,
|
||||||
gamebanana::list_mods
|
gamebanana::list_mods
|
||||||
])
|
])
|
||||||
.on_window_event(|event| match event.event() {
|
.on_window_event(|event| {
|
||||||
tauri::WindowEvent::CloseRequested { api, .. } => {
|
if let tauri::WindowEvent::CloseRequested { .. } = event.event() {
|
||||||
// Ensure all proxy stuff is handled
|
// Ensure all proxy stuff is handled
|
||||||
disconnect();
|
disconnect();
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
})
|
})
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
* https://github.com/omjadas/hudsucker/blob/main/examples/log.rs
|
* https://github.com/omjadas/hudsucker/blob/main/examples/log.rs
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use crate::config::get_config;
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
use crate::system_helpers::run_command;
|
use crate::system_helpers::run_command;
|
||||||
|
|
||||||
@@ -60,24 +61,86 @@ impl HttpHandler for ProxyHandler {
|
|||||||
) -> RequestOrResponse {
|
) -> RequestOrResponse {
|
||||||
let uri = req.uri().to_string();
|
let uri = req.uri().to_string();
|
||||||
|
|
||||||
if uri.contains("hoyoverse.com") || uri.contains("mihoyo.com") || uri.contains("yuanshen.com") {
|
match get_config().redirect_more {
|
||||||
// Handle CONNECTs
|
Some(true) => {
|
||||||
if req.method().as_str() == "CONNECT" {
|
if uri.contains("hoyoverse.com")
|
||||||
let builder = Response::builder()
|
|| uri.contains("mihoyo.com")
|
||||||
.header("DecryptEndpoint", "Created")
|
|| uri.contains("yuanshen.com")
|
||||||
.status(StatusCode::OK);
|
|| uri.contains("starrails.com")
|
||||||
let res = builder.body(()).unwrap();
|
|| 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
|
// Respond to CONNECT
|
||||||
*res.body()
|
*res.body()
|
||||||
} else {
|
} else {
|
||||||
let uri_path_and_query = req.uri().path_and_query().unwrap().as_str();
|
let uri_path_and_query = req.uri().path_and_query().unwrap().as_str();
|
||||||
// Create new URI.
|
// Create new URI.
|
||||||
let new_uri =
|
let new_uri =
|
||||||
Uri::from_str(format!("{}{}", SERVER.lock().unwrap(), uri_path_and_query).as_str())
|
Uri::from_str(format!("{}{}", SERVER.lock().unwrap(), uri_path_and_query).as_str())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
// Set request URI to the new one.
|
// Set request URI to the new one.
|
||||||
*req.uri_mut() = new_uri;
|
*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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ interface IState {
|
|||||||
swag: boolean
|
swag: boolean
|
||||||
platform: string
|
platform: string
|
||||||
un_elevated: boolean
|
un_elevated: boolean
|
||||||
|
redirect_more: boolean
|
||||||
|
|
||||||
// Swag stuff
|
// Swag stuff
|
||||||
akebi_path: string
|
akebi_path: string
|
||||||
@@ -72,6 +73,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
auto_mongodb: false,
|
auto_mongodb: false,
|
||||||
platform: '',
|
platform: '',
|
||||||
un_elevated: false,
|
un_elevated: false,
|
||||||
|
redirect_more: false,
|
||||||
|
|
||||||
// Swag stuff
|
// Swag stuff
|
||||||
akebi_path: '',
|
akebi_path: '',
|
||||||
@@ -123,6 +125,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
auto_mongodb: config.auto_mongodb || false,
|
auto_mongodb: config.auto_mongodb || false,
|
||||||
platform,
|
platform,
|
||||||
un_elevated: config.un_elevated || false,
|
un_elevated: config.un_elevated || false,
|
||||||
|
redirect_more: config.redirect_more || false,
|
||||||
|
|
||||||
// Swag stuff
|
// Swag stuff
|
||||||
akebi_path: config.akebi_path || '',
|
akebi_path: config.akebi_path || '',
|
||||||
@@ -388,6 +391,18 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="OptionSection" id="menuOptionsContainerRedirect">
|
||||||
|
<div className="OptionLabel" id="menuOptionsLabelRedirect">
|
||||||
|
<Tr text="options.redirect_more" />
|
||||||
|
</div>
|
||||||
|
<div className="OptionValue" id="menuOptionsCheckboxRedirect">
|
||||||
|
<Checkbox
|
||||||
|
onChange={() => this.toggleOption('redirect_more')}
|
||||||
|
checked={this.state?.redirect_more}
|
||||||
|
id="RedirectMore"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Divider />
|
<Divider />
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ let defaultConfig: Configuration
|
|||||||
horny_mode: false,
|
horny_mode: false,
|
||||||
auto_mongodb: false,
|
auto_mongodb: false,
|
||||||
un_elevated: false,
|
un_elevated: false,
|
||||||
|
redirect_more: false,
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|
||||||
@@ -55,6 +56,7 @@ export interface Configuration {
|
|||||||
swag_mode?: boolean
|
swag_mode?: boolean
|
||||||
auto_mongodb: boolean
|
auto_mongodb: boolean
|
||||||
un_elevated: boolean
|
un_elevated: boolean
|
||||||
|
redirect_more: boolean
|
||||||
|
|
||||||
// Swag stuff
|
// Swag stuff
|
||||||
akebi_path?: string
|
akebi_path?: string
|
||||||
|
|||||||
Reference in New Issue
Block a user