proxy: set proper user agent

instead of hard-coding "something/1.0.0".

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler
2023-03-03 12:13:27 +01:00
committed by Martin Algesten
parent b66e558027
commit 2b86691a81
2 changed files with 9 additions and 3 deletions

View File

@@ -131,7 +131,7 @@ impl Proxy {
})
}
pub(crate) fn connect<S: AsRef<str>>(&self, host: S, port: u16) -> String {
pub(crate) fn connect<S: AsRef<str>>(&self, host: S, port: u16, user_agent: &str) -> String {
let authorization = if self.use_authorization() {
let creds = BASE64_STANDARD.encode(format!(
"{}:{}",
@@ -150,7 +150,7 @@ impl Proxy {
format!(
"CONNECT {}:{} HTTP/1.1\r\n\
Host: {}:{}\r\n\
User-Agent: something/1.0.0\r\n\
User-Agent: {}\r\n\
Proxy-Connection: Keep-Alive\r\n\
{}\
\r\n",
@@ -158,6 +158,7 @@ Proxy-Connection: Keep-Alive\r\n\
port,
host.as_ref(),
port,
user_agent,
authorization
)
}

View File

@@ -425,7 +425,12 @@ pub(crate) fn connect_host(
if proto == Some(Proto::HTTPConnect) {
if let Some(ref proxy) = proxy {
write!(stream, "{}", proxy.connect(hostname, port)).unwrap();
write!(
stream,
"{}",
proxy.connect(hostname, port, &unit.agent.config.user_agent)
)
.unwrap();
stream.flush()?;
let mut proxy_response = Vec::new();