mirror of
				https://github.com/TeamPiped/piped-proxy.git
				synced 2024-08-14 23:50:45 +00:00 
			
		
		
		
	cr fixes
This commit is contained in:
		
							parent
							
								
									a9e34cb678
								
							
						
					
					
						commit
						67369a494a
					
				
					 3 changed files with 25 additions and 16 deletions
				
			
		
							
								
								
									
										1
									
								
								Cargo.lock
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										1
									
								
								Cargo.lock
									
										
									
										generated
									
									
									
								
							| 
						 | 
					@ -1369,7 +1369,6 @@ dependencies = [
 | 
				
			||||||
 "bytes",
 | 
					 "bytes",
 | 
				
			||||||
 "futures-util",
 | 
					 "futures-util",
 | 
				
			||||||
 "image",
 | 
					 "image",
 | 
				
			||||||
 "lazy_static",
 | 
					 | 
				
			||||||
 "libwebp-sys",
 | 
					 "libwebp-sys",
 | 
				
			||||||
 "mimalloc",
 | 
					 "mimalloc",
 | 
				
			||||||
 "once_cell",
 | 
					 "once_cell",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,7 +26,6 @@ regex = "1.10.4"
 | 
				
			||||||
blake3 = { version = "1.5.1", optional = true }
 | 
					blake3 = { version = "1.5.1", optional = true }
 | 
				
			||||||
bytes = "1.6.0"
 | 
					bytes = "1.6.0"
 | 
				
			||||||
futures-util = "0.3.30"
 | 
					futures-util = "0.3.30"
 | 
				
			||||||
lazy_static = "1.4.0"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
[features]
 | 
					[features]
 | 
				
			||||||
default = ["webp", "mimalloc", "reqwest-rustls", "qhash"]
 | 
					default = ["webp", "mimalloc", "reqwest-rustls", "qhash"]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										39
									
								
								src/utils.rs
									
										
									
									
									
								
							
							
						
						
									
										39
									
								
								src/utils.rs
									
										
									
									
									
								
							| 
						 | 
					@ -1,22 +1,15 @@
 | 
				
			||||||
use lazy_static::lazy_static;
 | 
					use once_cell::sync::Lazy;
 | 
				
			||||||
use qstring::QString;
 | 
					use qstring::QString;
 | 
				
			||||||
use reqwest::Url;
 | 
					use reqwest::Url;
 | 
				
			||||||
use std::borrow::Cow;
 | 
					use std::borrow::Cow;
 | 
				
			||||||
use std::collections::BTreeMap;
 | 
					use std::collections::BTreeMap;
 | 
				
			||||||
use std::env;
 | 
					use std::env;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[cfg(not(feature = "prefix-path"))]
 | 
					 | 
				
			||||||
lazy_static! {
 | 
					 | 
				
			||||||
    static ref PREFIX_PATH: Option<String> = Some(String::from(""));
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[cfg(feature = "prefix-path")]
 | 
					#[cfg(feature = "prefix-path")]
 | 
				
			||||||
lazy_static! {
 | 
					static PREFIX_PATH: Lazy<Option<String>> = Lazy::new(|| match env::var("PREFIX_PATH") {
 | 
				
			||||||
    static ref PREFIX_PATH: Option<String> = match env::var("PREFIX_PATH") {
 | 
					    Ok(v) => Some(String::from(v)),
 | 
				
			||||||
        Ok(v) => Some(String::from(v)),
 | 
					    Err(e) => panic!("$PREFIX_PATH is not set ({})", e)
 | 
				
			||||||
        Err(e) => panic!("$PREFIX_PATH is not set ({})", e)
 | 
					});
 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub fn read_buf(buf: &[u8], pos: &mut usize) -> u8 {
 | 
					pub fn read_buf(buf: &[u8], pos: &mut usize) -> u8 {
 | 
				
			||||||
    let byte = buf[*pos];
 | 
					    let byte = buf[*pos];
 | 
				
			||||||
| 
						 | 
					@ -60,12 +53,30 @@ fn finalize_url(path: &str, query: BTreeMap<String, String>) -> String {
 | 
				
			||||||
        if qhash.is_some() {
 | 
					        if qhash.is_some() {
 | 
				
			||||||
            let mut query = QString::new(query.into_iter().collect::<Vec<_>>());
 | 
					            let mut query = QString::new(query.into_iter().collect::<Vec<_>>());
 | 
				
			||||||
            query.add_pair(("qhash", qhash.unwrap()));
 | 
					            query.add_pair(("qhash", qhash.unwrap()));
 | 
				
			||||||
            return format!("{}{}?{}", PREFIX_PATH.as_ref().unwrap().to_string(), path, query);
 | 
					            #[cfg(not(feature = "prefix-path"))]
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return format!("{}?{}", path, query);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            #[cfg(feature = "prefix-path")]
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return format!("{}{}?{}", PREFIX_PATH.as_ref().unwrap().to_string(), path, query);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let query = QString::new(query.into_iter().collect::<Vec<_>>());
 | 
					    let query = QString::new(query.into_iter().collect::<Vec<_>>());
 | 
				
			||||||
    format!("{}{}?{}", PREFIX_PATH.as_ref().unwrap().to_string(), path, query)
 | 
					    #[cfg(not(feature = "prefix-path"))]
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        format!("{}?{}", path, query)
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #[cfg(feature = "prefix-path")]
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        format!("{}{}?{}", PREFIX_PATH.as_ref().unwrap().to_string(), path, query)
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub fn localize_url(url: &str, host: &str) -> String {
 | 
					pub fn localize_url(url: &str, host: &str) -> String {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue