add http(s) proxy

This commit is contained in:
yuluo
2024-04-03 03:07:47 +08:00
parent 41d99d5108
commit 0bf3a91352
7 changed files with 525 additions and 52 deletions

View File

@@ -28,6 +28,8 @@ use hbb_common::{
udp::FramedSocket,
AddrMangle, IntoTargetAddr, ResultType, TargetAddr,
};
use hbb_common::log::info;
use hbb_common::proxy::Proxy;
use crate::{
check_port,
@@ -387,8 +389,15 @@ impl RendezvousMediator {
}
pub async fn start(server: ServerPtr, host: String) -> ResultType<()> {
log::info!("start rendezvous mediator of {}", host);
if cfg!(debug_assertions) && option_env!("TEST_TCP").is_some() {
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)?;
proxy.is_http_or_https()
} else {
false
};
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