mirror of
				https://github.com/TeamPiped/piped-proxy.git
				synced 2024-08-14 23:50:45 +00:00 
			
		
		
		
	replace lazy_static with once_cell
This commit is contained in:
		
							parent
							
								
									10a9acd99c
								
							
						
					
					
						commit
						86f5b67f2f
					
				
					 3 changed files with 254 additions and 280 deletions
				
			
		
							
								
								
									
										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}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										17
									
								
								src/main.rs
									
										
									
									
									
								
							
							
						
						
									
										17
									
								
								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,14 +27,12 @@ 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 = {
 | 
					static CLIENT: Lazy<Client> = Lazy::new(|| {
 | 
				
			||||||
    let builder = Client::builder()
 | 
					    let builder = Client::builder()
 | 
				
			||||||
        .user_agent("Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0");
 | 
					        .user_agent("Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -46,8 +44,7 @@ lazy_static!(
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        builder.build().unwrap()
 | 
					        builder.build().unwrap()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    };
 | 
					});
 | 
				
			||||||
);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
const ALLOWED_DOMAINS: [&str; 7] = [
 | 
					const ALLOWED_DOMAINS: [&str; 7] = [
 | 
				
			||||||
    "youtube.com",
 | 
					    "youtube.com",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue