mirror of
https://github.com/TeamPiped/piped-proxy.git
synced 2024-12-14 14:20:35 +05:30
replace lazy_static with once_cell
This commit is contained in:
parent
10a9acd99c
commit
86f5b67f2f
501
Cargo.lock
generated
501
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -8,7 +8,7 @@ version = "0.1.0"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = "4.3.1"
|
actix-web = "4.3.1"
|
||||||
image = "0.24.6"
|
image = "0.24.6"
|
||||||
lazy_static = "1.4.0"
|
once_cell = "1.17.1"
|
||||||
qstring = "0.7.2"
|
qstring = "0.7.2"
|
||||||
regex = "1.7.3"
|
regex = "1.7.3"
|
||||||
reqwest = {version = "0.11.15", features = ["rustls-tls", "stream", "brotli", "gzip"], default-features = false}
|
reqwest = {version = "0.11.15", features = ["rustls-tls", "stream", "brotli", "gzip"], default-features = false}
|
||||||
|
31
src/main.rs
31
src/main.rs
@ -4,7 +4,7 @@ use std::error::Error;
|
|||||||
use actix_web::{App, HttpRequest, HttpResponse, HttpResponseBuilder, HttpServer, web};
|
use actix_web::{App, HttpRequest, HttpResponse, HttpResponseBuilder, HttpServer, web};
|
||||||
use actix_web::http::Method;
|
use actix_web::http::Method;
|
||||||
use image::EncodableLayout;
|
use image::EncodableLayout;
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
use qstring::QString;
|
use qstring::QString;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use reqwest::{Client, Request, Url};
|
use reqwest::{Client, Request, Url};
|
||||||
@ -27,27 +27,24 @@ async fn main() -> std::io::Result<()> {
|
|||||||
}.run().await
|
}.run().await
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static!(
|
static RE_DOMAIN: Lazy<Regex> = Lazy::new(|| Regex::new(r"^(?:[a-z\d.-]*\.)?((?:[a-z\d-]*)\.(?:[a-z\d-]*))$").unwrap());
|
||||||
static ref RE_DOMAIN: Regex = Regex::new(r"^(?:[a-z\d\.-]*\.)?((?:[a-z\d-]*)\.(?:[a-z\d-]*))$").unwrap();
|
static RE_MANIFEST: Lazy<Regex> = Lazy::new(|| Regex::new("(?m)URI=\"([^\"]+)\"").unwrap());
|
||||||
static ref RE_MANIFEST: Regex = Regex::new("(?m)URI=\"([^\"]+)\"").unwrap();
|
static RE_DASH_MANIFEST: Lazy<Regex> = Lazy::new(|| Regex::new("BaseURL>(https://[^<]+)</BaseURL").unwrap());
|
||||||
static ref RE_DASH_MANIFEST: Regex = Regex::new("BaseURL>(https://[^<]+)</BaseURL").unwrap();
|
|
||||||
);
|
|
||||||
|
|
||||||
lazy_static!(
|
|
||||||
static ref CLIENT: Client = {
|
|
||||||
let builder = Client::builder()
|
|
||||||
.user_agent("Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0");
|
|
||||||
|
|
||||||
if env::var("IPV4_ONLY").is_ok() {
|
static CLIENT: Lazy<Client> = Lazy::new(|| {
|
||||||
builder
|
let builder = Client::builder()
|
||||||
|
.user_agent("Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0");
|
||||||
|
|
||||||
|
if env::var("IPV4_ONLY").is_ok() {
|
||||||
|
builder
|
||||||
.local_address(Some("0.0.0.0".parse().unwrap()))
|
.local_address(Some("0.0.0.0".parse().unwrap()))
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
} else {
|
} else {
|
||||||
builder.build().unwrap()
|
builder.build().unwrap()
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
);
|
|
||||||
|
|
||||||
const ALLOWED_DOMAINS: [&str; 7] = [
|
const ALLOWED_DOMAINS: [&str; 7] = [
|
||||||
"youtube.com",
|
"youtube.com",
|
||||||
|
Loading…
Reference in New Issue
Block a user