javtiful proxy
This commit is contained in:
13
src/proxy.rs
13
src/proxy.rs
@@ -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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user