mirror of
https://github.com/TeamPiped/piped-proxy.git
synced 2024-08-14 23:50:45 +00:00
Add option to disable ipv6.
This commit is contained in:
parent
f44df15206
commit
dafafaf418
1 changed files with 13 additions and 3 deletions
16
src/main.rs
16
src/main.rs
|
@ -34,7 +34,19 @@ lazy_static!(
|
|||
);
|
||||
|
||||
lazy_static!(
|
||||
static ref CLIENT: Client = Client::new();
|
||||
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() {
|
||||
builder
|
||||
.local_address(Some("0.0.0.0".parse().unwrap()))
|
||||
.build()
|
||||
.unwrap()
|
||||
} else {
|
||||
builder.build().unwrap()
|
||||
}
|
||||
};
|
||||
);
|
||||
|
||||
const ALLOWED_DOMAINS: [&str; 7] = [
|
||||
|
@ -121,8 +133,6 @@ async fn index(req: HttpRequest) -> Result<HttpResponse, Box<dyn Error>> {
|
|||
|
||||
let request_headers = request.headers_mut();
|
||||
|
||||
request_headers.insert("User-Agent", "Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0".parse().unwrap());
|
||||
|
||||
for (key, value) in req.headers() {
|
||||
if is_header_allowed(key.as_str()) {
|
||||
request_headers.insert(key.clone(), value.clone());
|
||||
|
|
Loading…
Reference in a new issue