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:
committed by
Martin Algesten
parent
b66e558027
commit
2b86691a81
@@ -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 authorization = if self.use_authorization() {
|
||||||
let creds = BASE64_STANDARD.encode(format!(
|
let creds = BASE64_STANDARD.encode(format!(
|
||||||
"{}:{}",
|
"{}:{}",
|
||||||
@@ -150,7 +150,7 @@ impl Proxy {
|
|||||||
format!(
|
format!(
|
||||||
"CONNECT {}:{} HTTP/1.1\r\n\
|
"CONNECT {}:{} HTTP/1.1\r\n\
|
||||||
Host: {}:{}\r\n\
|
Host: {}:{}\r\n\
|
||||||
User-Agent: something/1.0.0\r\n\
|
User-Agent: {}\r\n\
|
||||||
Proxy-Connection: Keep-Alive\r\n\
|
Proxy-Connection: Keep-Alive\r\n\
|
||||||
{}\
|
{}\
|
||||||
\r\n",
|
\r\n",
|
||||||
@@ -158,6 +158,7 @@ Proxy-Connection: Keep-Alive\r\n\
|
|||||||
port,
|
port,
|
||||||
host.as_ref(),
|
host.as_ref(),
|
||||||
port,
|
port,
|
||||||
|
user_agent,
|
||||||
authorization
|
authorization
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -425,7 +425,12 @@ pub(crate) fn connect_host(
|
|||||||
|
|
||||||
if proto == Some(Proto::HTTPConnect) {
|
if proto == Some(Proto::HTTPConnect) {
|
||||||
if let Some(ref proxy) = proxy {
|
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()?;
|
stream.flush()?;
|
||||||
|
|
||||||
let mut proxy_response = Vec::new();
|
let mut proxy_response = Vec::new();
|
||||||
|
|||||||
Reference in New Issue
Block a user