javtiful proxy

This commit is contained in:
Simon
2026-01-07 14:24:18 +00:00
parent 6fac9d6d45
commit cf04441a69
4 changed files with 79 additions and 39 deletions

View File

@@ -1,5 +1,6 @@
use ntex::web::{self, HttpRequest};
use crate::proxies::javtiful::JavtifulProxy;
use crate::proxies::sxyprn::SxyprnProxy;
use crate::util::requester::Requester;
use crate::proxies::*;
@@ -7,8 +8,13 @@ use crate::proxies::*;
pub fn config(cfg: &mut web::ServiceConfig) {
cfg.service(
web::resource("/sxyprn/{endpoint}*")
.route(web::post().to(sxyprn))
.route(web::get().to(sxyprn)),
.route(web::post().to(proxy2redirect))
.route(web::get().to(proxy2redirect)),
)
.service(
web::resource("/javtiful/{endpoint}*")
.route(web::post().to(proxy2redirect))
.route(web::get().to(proxy2redirect)),
)
.service(
web::resource("/hanime-cdn/{endpoint}*")
@@ -19,7 +25,7 @@ pub fn config(cfg: &mut web::ServiceConfig) {
}
async fn sxyprn(req: HttpRequest,
async fn proxy2redirect(req: HttpRequest,
requester: web::types::State<Requester>,) -> Result<impl web::Responder, web::Error> {
let proxy = get_proxy(req.uri().to_string().split("/").collect::<Vec<&str>>()[2]).unwrap();
let endpoint = req.match_info().query("endpoint").to_string();
@@ -35,6 +41,7 @@ async fn sxyprn(req: HttpRequest,
fn get_proxy(proxy: &str) -> Option<AnyProxy> {
match proxy {
"sxyprn" => Some(AnyProxy::Sxyprn(SxyprnProxy::new())),
"javtiful" => Some(AnyProxy::Javtiful(JavtifulProxy::new())),
_ => None,
}
}