✨ Compress
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,5 +1,6 @@ | |||||||
| /config | /config | ||||||
| /certs | /certs | ||||||
|  | /test/data | ||||||
| /letsencrypt | /letsencrypt | ||||||
|  |  | ||||||
| # Added by cargo | # Added by cargo | ||||||
|   | |||||||
| @@ -63,13 +63,13 @@ impl Destination { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     pub fn get_host(&self) -> &str { |     pub fn get_host(&self) -> &str { | ||||||
|         (self |         self | ||||||
|             .uri |             .uri | ||||||
|             .as_str() |             .as_str() | ||||||
|             .splitn(2, "://") |             .splitn(2, "://") | ||||||
|             .collect::<Vec<_>>() |             .collect::<Vec<_>>() | ||||||
|             .get(1) |             .get(1) | ||||||
|             .unwrap_or(&"")) |             .unwrap_or(&"") | ||||||
|         .splitn(2, '?') |         .splitn(2, '?') | ||||||
|         .collect::<Vec<_>>()[0] |         .collect::<Vec<_>>()[0] | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -42,7 +42,7 @@ impl RoadTrace { | |||||||
|     ) -> RoadTrace { |     ) -> RoadTrace { | ||||||
|         let mut trace = Self::from_structs(ip, ua, reg, loc, end); |         let mut trace = Self::from_structs(ip, ua, reg, loc, end); | ||||||
|         trace.error = Some(err); |         trace.error = Some(err); | ||||||
|         return trace; |         trace | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -2,12 +2,12 @@ use crate::proxies::ProxyError; | |||||||
| use crate::proxies::ProxyError::{BadGateway, UpgradeRequired}; | use crate::proxies::ProxyError::{BadGateway, UpgradeRequired}; | ||||||
| use actix_files::NamedFile; | use actix_files::NamedFile; | ||||||
| use actix_web::http::{header, Method}; | use actix_web::http::{header, Method}; | ||||||
| use actix_web::web::BytesMut; | use actix_web::{web, HttpRequest, HttpResponse}; | ||||||
| use actix_web::{web, Error, HttpRequest, HttpResponse}; |  | ||||||
| use awc::error::HeaderValue; | use awc::error::HeaderValue; | ||||||
| use awc::http::Uri; | use awc::http::Uri; | ||||||
| use awc::Client; | use awc::Client; | ||||||
| use futures::{channel::mpsc::unbounded, Sink, sink::SinkExt, stream::StreamExt}; | use futures::Sink; | ||||||
|  | use futures::stream::StreamExt; | ||||||
| use std::str::FromStr; | use std::str::FromStr; | ||||||
| use std::time::Duration; | use std::time::Duration; | ||||||
| use std::{ | use std::{ | ||||||
| @@ -18,7 +18,6 @@ use actix::io::{SinkWrite, WriteHandler}; | |||||||
| use actix::{Actor, ActorContext, AsyncContext, StreamHandler}; | use actix::{Actor, ActorContext, AsyncContext, StreamHandler}; | ||||||
| use actix_web_actors::ws; | use actix_web_actors::ws; | ||||||
| use actix_web_actors::ws::{CloseReason, handshake, ProtocolError, WebsocketContext}; | use actix_web_actors::ws::{CloseReason, handshake, ProtocolError, WebsocketContext}; | ||||||
| use tokio::io::{AsyncReadExt, AsyncWriteExt}; |  | ||||||
| use tracing::log::warn; | use tracing::log::warn; | ||||||
|  |  | ||||||
| pub async fn respond_hypertext( | pub async fn respond_hypertext( | ||||||
|   | |||||||
| @@ -1,7 +1,7 @@ | |||||||
| use std::error; | use std::error; | ||||||
| use actix_web::{App, HttpServer, web}; | use actix_web::{App, HttpServer, web}; | ||||||
| use actix_web::dev::Server; | use actix_web::dev::Server; | ||||||
| use actix_web::middleware::Logger; | use actix_web::middleware::{Compress, Logger}; | ||||||
| use awc::Client; | use awc::Client; | ||||||
| use crate::config::CFG; | use crate::config::CFG; | ||||||
| use crate::proxies::route; | use crate::proxies::route; | ||||||
| @@ -28,6 +28,7 @@ pub fn build_single_proxy(cfg: ServerBindConfig) -> Result<Server, Box<dyn error | |||||||
|     let server = HttpServer::new(|| { |     let server = HttpServer::new(|| { | ||||||
|         App::new() |         App::new() | ||||||
|             .wrap(Logger::default()) |             .wrap(Logger::default()) | ||||||
|  |             .wrap(Compress::default()) | ||||||
|             .app_data(web::Data::new(Client::default())) |             .app_data(web::Data::new(Client::default())) | ||||||
|             .default_service(web::to(route::handle)) |             .default_service(web::to(route::handle)) | ||||||
|     }); |     }); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user