Merge pull request #181 from NotThorny/Redirect-More

Redirect more domains
This commit is contained in:
SpikeHD 2023-06-18 20:36:47 -07:00 committed by GitHub
commit 26d7ac2b11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 170 additions and 46 deletions

View File

@ -8,7 +8,8 @@
"ip_placeholder": "IP 地址...",
"port_placeholder": "端口...",
"files_downloading": "文件下载中:",
"files_extracting": "文件解压中:"
"files_extracting": "文件解压中:",
"game_path_notify": "未找到游戏路径,请记得在设置中进行设置"
},
"options": {
"enabled": "已启用",
@ -30,7 +31,8 @@
"wipe_login": "清除登录缓存",
"horny_mode": "Horny 模式",
"auto_mongodb": "自动启动 MongoDB",
"un_elevated": "非提升运行游戏(无管理员)"
"un_elevated": "非提升运行游戏(无管理员)",
"redirect_more": "还可以重定向其他MHY游戏"
},
"downloads": {
"grasscutter_fullbuild": "下载 Grasscutter 一体化",

View File

@ -8,7 +8,8 @@
"ip_placeholder": "IP地址...",
"port_placeholder": "通訊埠...",
"files_downloading": "檔案下載中:",
"files_extracting": "檔案解壓縮中:"
"files_extracting": "檔案解壓縮中:",
"game_path_notify": "找不到遊戲路徑,記得在設置裡設置!"
},
"options": {
"enabled": "已啟用",
@ -30,7 +31,8 @@
"wipe_login": "擦除登錄緩存",
"horny_mode": "Horny模式",
"auto_mongodb": "自動啟動 MongoDB",
"un_elevated": "在不升高的情况下运行游戏(没有管理员)。"
"un_elevated": "在不升高的情况下运行游戏(没有管理员)。",
"redirect_more": "同時重定向其他 MHY 遊戲"
},
"downloads": {
"grasscutter_fullbuild": "下載Grasscutter多合一下載",

View File

@ -8,7 +8,8 @@
"ip_placeholder": "Server Adresse...",
"port_placeholder": "Port...",
"files_downloading": "Herunterladen von Dateien: ",
"files_extracting": "Extrahieren von Dateien: "
"files_extracting": "Extrahieren von Dateien: ",
"game_path_notify": "Spielpfad nicht gefunden, denken Sie daran, ihn in den Einstellungen festzulegen!"
},
"options": {
"enabled": "Aktiviert",
@ -29,7 +30,8 @@
"wipe_login": "Wis de inlogcache",
"horny_mode": "Geile modus",
"auto_mongodb": "Start automatisch MongoDB",
"un_elevated": "Führen Sie das Spiel nicht erhöht aus (kein Admin)"
"un_elevated": "Führen Sie das Spiel nicht erhöht aus (kein Admin)",
"redirect_more": "Leiten Sie auch andere MHY-Spiele um"
},
"downloads": {
"grasscutter_fullbuild": "Alles in Einem Grasscutter Daten herunterladen",

View File

@ -9,7 +9,7 @@
"port_placeholder": "Port...",
"files_downloading": "Files Downloading: ",
"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": {
"enabled": "Enabled",
@ -31,7 +31,8 @@
"wipe_login": "Wipe Login Cache",
"horny_mode": "Horny Mode",
"auto_mongodb": "Automatically Start MongoDB",
"un_elevated": "Run the game non-elevated (no admin)"
"un_elevated": "Run the game non-elevated (no admin)",
"redirect_more": "Also redirect other MHY games"
},
"downloads": {
"grasscutter_fullbuild": "Download Grasscutter All-in-One",

View File

@ -8,7 +8,8 @@
"ip_placeholder": "Dirección del servidor...",
"port_placeholder": "Puerto...",
"files_downloading": "Archivos Descargandose: ",
"files_extracting": "Archivos Extrayendose: "
"files_extracting": "Archivos Extrayendose: ",
"game_path_notify": "Ruta de juego no encontrada, ¡recuerda configurarla en ajustes!"
},
"options": {
"enabled": "Activado",
@ -30,7 +31,8 @@
"wipe_login": "Borrar caché de inicio de sesión",
"horny_mode": "Modo cachondo",
"auto_mongodb": "Iniciar automáticamente MongoDB",
"un_elevated": "Ejecutar el juego no elevado (no admin)"
"un_elevated": "Ejecutar el juego no elevado (no admin)",
"redirect_more": "También redirigir otros juegos MHY"
},
"downloads": {
"grasscutter_fullbuild": "Descargar Datos todo en uno de Grasscutter",

View File

@ -8,7 +8,8 @@
"ip_placeholder": "Adresse du serveur...",
"port_placeholder": "Port...",
"files_downloading": "Fichiers en cours de telechargement: ",
"files_extracting": "Fichiers en cours d'extraction: "
"files_extracting": "Fichiers en cours d'extraction: ",
"game_path_notify": "Chemin d'accès au jeu non trouvé, n'oubliez pas de le définir dans les options !"
},
"options": {
"enabled": "Activé",
@ -30,7 +31,8 @@
"wipe_login": "Effacer le cache de connexion",
"horny_mode": "Mode horny",
"auto_mongodb": "Démarrer automatiquement MongoDB",
"un_elevated": "Exécuter le jeu sans élévation (pas d'administrateur)"
"un_elevated": "Exécuter le jeu sans élévation (pas d'administrateur)",
"redirect_more": "Réorienter également les autres jeux MHY"
},
"downloads": {
"grasscutter_fullbuild": "Telecharger Grasscutter tout-en-un",

View File

@ -7,7 +7,8 @@
"ip_placeholder": "Alamat Server...",
"port_placeholder": "Port...",
"files_downloading": "Mendownload File Yang Diperlukan: ",
"files_extracting": "MengExtract File: "
"files_extracting": "MengExtract File: ",
"game_path_notify": "Jalur permainan tidak ditemukan, ingatlah untuk mengaturnya dalam pengaturan!"
},
"options": {
"enabled": "Diaktifkan",
@ -29,7 +30,8 @@
"wipe_login": "Menghapus Cache Login",
"horny_mode": "Mode Terangsang",
"auto_mongodb": "Mulai MongoDB secara otomatis",
"un_elevated": "Jalankan game yang tidak ditinggikan (tanpa admin)"
"un_elevated": "Jalankan game yang tidak ditinggikan (tanpa admin)",
"redirect_more": "Juga mengarahkan ulang game MHY lainnya"
},
"downloads": {
"grasscutter_fullbuild": "Sedang Mendownload Grasscutter Semua Dalam Satu",

View File

@ -8,7 +8,8 @@
"ip_placeholder": "서버 주소",
"port_placeholder": "포트",
"files_downloading": "파일 다운로드 중: ",
"files_extracting": "파일 추출 중: "
"files_extracting": "파일 추출 중: ",
"game_path_notify": "게임 경로를 찾을 수 없습니다. 설정에서 설정하는 것을 잊지 마세요!"
},
"options": {
"enabled": "활성",
@ -30,7 +31,8 @@
"wipe_login": "로그인 캐시 지우기",
"horny_mode": "Horny 모드",
"auto_mongodb": "MongoDB 자동 시작",
"un_elevated": "게임 비상승 실행(관리자 없음)"
"un_elevated": "게임 비상승 실행(관리자 없음)",
"redirect_more": "다른 MHY 게임도 리디렉션"
},
"downloads": {
"grasscutter_fullbuild": "올인원 Grasscutter 다운로드",

View File

@ -8,7 +8,8 @@
"ip_placeholder": "Servera Adrese...",
"port_placeholder": "Ports...",
"files_downloading": "Failu Lejupielāde: ",
"files_extracting": "Failu Izvilkšana: "
"files_extracting": "Failu Izvilkšana: ",
"game_path_notify": "Spēles ceļš nav atrasts, atcerieties to iestatījumos!"
},
"options": {
"enabled": "Iespējots",
@ -28,7 +29,8 @@
"wipe_login": "Noslaucīt pieteikšanās kešatmiņu",
"horny_mode": "Uzbudināts režīms",
"auto_mongodb": "Automātiski startējiet MongoDB",
"un_elevated": "Palaist spēli bez paaugstinājuma (bez administratora)"
"un_elevated": "Palaist spēli bez paaugstinājuma (bez administratora)",
"redirect_more": "Arī novirzīt citas MHY spēles"
},
"downloads": {
"grasscutter_fullbuild": "Lejupielādējiet Grasscutter viss vienā",

View File

@ -8,7 +8,8 @@
"ip_placeholder": "Server Address...",
"port_placeholder": "Poort...",
"files_downloading": "Bestanden Aan Downloaden: ",
"files_extracting": "Bestanden Uitpakken: "
"files_extracting": "Bestanden Uitpakken: ",
"game_path_notify": "Spelpad niet gevonden, denk eraan dit in te stellen in instellingen!"
},
"options": {
"enabled": "Ingeschakeld",
@ -29,7 +30,8 @@
"wipe_login": "Login cache wissen",
"horny_mode": "Geile modus",
"auto_mongodb": "Start automatisch MongoDB",
"un_elevated": "Voer het spel uit zonder hoogtevrees (geen admin)"
"un_elevated": "Voer het spel uit zonder hoogtevrees (geen admin)",
"redirect_more": "Richt ook andere MHY-spellen"
},
"downloads": {
"grasscutter_fullbuild": "Grasscutter Alles-in-één Downloaden",

View File

@ -8,7 +8,8 @@
"ip_placeholder": "Endereço do Servidor...",
"port_placeholder": "Porta...",
"files_downloading": "Baixando Arquivos: ",
"files_extracting": "Extraindo Arquivos: "
"files_extracting": "Extraindo Arquivos: ",
"game_path_notify": "Caminho do jogo não encontrado, lembre-se de defini-lo nas configurações!"
},
"options": {
"enabled": "Habilitado",
@ -30,7 +31,8 @@
"wipe_login": "Limpar Cache de Login",
"horny_mode": "Modo com tesão",
"auto_mongodb": "Iniciar MongoDB Automaticamente",
"un_elevated": "Executar o jogo não-elevated (sem admin)"
"un_elevated": "Executar o jogo não-elevated (sem admin)",
"redirect_more": "Também redirecionar outros jogos MHY"
},
"downloads": {
"grasscutter_fullbuild": "Baixar o Grasscutter Tudo-em-Um",

View File

@ -8,7 +8,8 @@
"ip_placeholder": "Айпи адрес...",
"port_placeholder": "Порт...",
"files_downloading": "Файлов скачано: ",
"files_extracting": "Извлечено файлов: "
"files_extracting": "Извлечено файлов: ",
"game_path_notify": "Путь к игре не найден, не забудьте установить его в настройках!"
},
"options": {
"enabled": "Включено",
@ -29,7 +30,8 @@
"wipe_login": "Очистить кэш входа в систему",
"horny_mode": "роговой режим",
"auto_mongodb": "Автоматически запускать MongoDB",
"un_elevated": "Запустите игру в неэлегантном режиме (без администратора)"
"un_elevated": "Запустите игру в неэлегантном режиме (без администратора)",
"redirect_more": "Также перенаправьте другие игры MHY"
},
"downloads": {
"grasscutter_fullbuild": "Скачать все в одном Grasscutter",

View File

@ -8,7 +8,8 @@
"ip_placeholder": "Địa chỉ máy chủ...",
"port_placeholder": "Cổng...",
"files_downloading": "Đang tải tập tin: ",
"files_extracting": "Đang giải nén tập tin: "
"files_extracting": "Đang giải nén tập tin: ",
"game_path_notify": "Không tìm thấy đường dẫn trò chơi, hãy nhớ đặt nó trong cài đặt!"
},
"options": {
"enabled": "Bật",
@ -30,7 +31,8 @@
"wipe_login": "Tẩy sạch cache đăng nhập",
"horny_mode": "Chế độ hứng tình",
"auto_mongodb": "Tự động khởi động MongoDB",
"un_elevated": "Chạy trò chơi không nâng cao (không có quản trị viên)"
"un_elevated": "Chạy trò chơi không nâng cao (không có quản trị viên)",
"redirect_more": "Đồng thời chuyển hướng các trò chơi MHY khác"
},
"downloads": {
"grasscutter_fullbuild": "Tải Grasscutter tất cả trong một",

View File

@ -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 {

View File

@ -49,6 +49,7 @@ async fn parse_args(inp: &Vec<String>) -> Result<Args, ArgsError> {
args.flag("h", "help", "Print various CLI args");
args.flag("p", "proxy", "Start the proxy server");
args.flag("G", "launch-game", "Launch the game");
args.flag("o", "other-redirects", "Redirect other certain anime games");
args.flag(
"A",
"no-admin",
@ -142,6 +143,10 @@ async fn parse_args(inp: &Vec<String>) -> Result<Args, ArgsError> {
pathbuf.push("cultivation");
pathbuf.push("ca");
if args.value_of("other_redirects")? {
proxy::set_redirect_more();
}
connect(8035, pathbuf.to_str().unwrap().to_string()).await;
}
@ -207,6 +212,7 @@ fn main() -> Result<(), ArgsError> {
system_helpers::run_un_elevated,
proxy::set_proxy_addr,
proxy::generate_ca_files,
proxy::set_redirect_more,
release::get_latest_release,
unzip::unzip,
file_helpers::rename,
@ -230,12 +236,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");

View File

@ -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;
@ -35,6 +36,7 @@ async fn shutdown_signal() {
// Global ver for getting server address.
static SERVER: Lazy<Mutex<String>> = Lazy::new(|| Mutex::new("http://localhost:443".to_string()));
static REDIRECT_MORE: Lazy<Mutex<bool>> = Lazy::new(|| Mutex::new(false));
#[derive(Clone)]
struct ProxyHandler;
@ -51,6 +53,11 @@ pub fn set_proxy_addr(addr: String) {
println!("Set server to {}", SERVER.lock().unwrap());
}
#[tauri::command]
pub fn set_redirect_more() {
*REDIRECT_MORE.lock().unwrap() = true;
}
#[async_trait]
impl HttpHandler for ProxyHandler {
async fn handle_request(
@ -60,24 +67,93 @@ 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();
let mut more = get_config().redirect_more;
// 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;
if *REDIRECT_MORE.lock().unwrap() {
more = Some(true);
}
match 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")
|| uri.contains("zenlesszonezero.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;
}
}
}
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;
}
}
}
}

View File

@ -42,6 +42,7 @@ interface IState {
swag: boolean
platform: string
un_elevated: boolean
redirect_more: boolean
// Swag stuff
akebi_path: string
@ -72,6 +73,7 @@ export default class Options extends React.Component<IProps, IState> {
auto_mongodb: false,
platform: '',
un_elevated: false,
redirect_more: false,
// Swag stuff
akebi_path: '',
@ -123,6 +125,7 @@ export default class Options extends React.Component<IProps, IState> {
auto_mongodb: config.auto_mongodb || false,
platform,
un_elevated: config.un_elevated || false,
redirect_more: config.redirect_more || false,
// Swag stuff
akebi_path: config.akebi_path || '',
@ -388,6 +391,18 @@ export default class Options extends React.Component<IProps, IState> {
/>
</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 />

View File

@ -26,6 +26,7 @@ let defaultConfig: Configuration
horny_mode: false,
auto_mongodb: false,
un_elevated: false,
redirect_more: false,
}
})()
@ -55,6 +56,7 @@ export interface Configuration {
swag_mode?: boolean
auto_mongodb: boolean
un_elevated: boolean
redirect_more: boolean
// Swag stuff
akebi_path?: string