Add: socks5 support. It may have problems with DoT, will see.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use reqwest::{Client, Method, StatusCode};
|
||||
use reqwest::{Client, Method, Proxy, StatusCode};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::net::{IpAddr, SocketAddr};
|
||||
use std::time::{Duration, Instant};
|
||||
@@ -63,6 +63,7 @@ pub struct HttpRequestOptions {
|
||||
pub show_body: bool,
|
||||
pub http1_only: bool,
|
||||
pub http2_only: bool,
|
||||
pub proxy: Option<String>,
|
||||
}
|
||||
|
||||
pub async fn request(url: &str, opts: HttpRequestOptions) -> Result<HttpReport, HttpError> {
|
||||
@@ -100,6 +101,11 @@ pub async fn request(url: &str, opts: HttpRequestOptions) -> Result<HttpReport,
|
||||
builder.redirect(reqwest::redirect::Policy::none())
|
||||
};
|
||||
|
||||
if let Some(proxy) = opts.proxy.as_ref() {
|
||||
let proxy = Proxy::all(proxy).map_err(|err| HttpError::Request(err.to_string()))?;
|
||||
builder = builder.proxy(proxy);
|
||||
}
|
||||
|
||||
if opts.http1_only {
|
||||
builder = builder.http1_only();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user