fix: add async http proxy func and format the code

This commit is contained in:
yuluo
2024-04-16 00:24:02 +08:00
parent c3b8621554
commit 1176750a4f
12 changed files with 232 additions and 174 deletions

View File

@@ -9,6 +9,8 @@ use std::{
use uuid::Uuid;
use hbb_common::log::info;
use hbb_common::proxy::Proxy;
use hbb_common::{
allow_err,
anyhow::{self, bail},
@@ -28,8 +30,6 @@ use hbb_common::{
udp::FramedSocket,
AddrMangle, IntoTargetAddr, ResultType, TargetAddr,
};
use hbb_common::log::info;
use hbb_common::proxy::Proxy;
use crate::{
check_port,
@@ -392,12 +392,12 @@ impl RendezvousMediator {
info!("start rendezvous mediator of {}", host);
//If the investment agent type is http or https, then tcp forwarding is enabled.
let is_http_proxy = if let Some(conf) = Config::get_socks() {
let proxy = Proxy::form_conf(&conf, None)?;
let proxy = Proxy::from_conf(&conf, None)?;
proxy.is_http_or_https()
} else {
false
};
if (cfg!(debug_assertions) && option_env!("TEST_TCP").is_some()) || is_http_proxy {
if (cfg!(debug_assertions) && option_env!("TEST_TCP").is_some()) || is_http_proxy {
Self::start_tcp(server, host).await
} else {
Self::start_udp(server, host).await