Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #19232: Specify relayd as user agent #3627

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions relay/sources/relayd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use crate::{
};
use anyhow::Error;
use configuration::main::CertificateVerificationModel;
use lazy_static::lazy_static;
use reqwest::{Certificate, Client};
use std::{
collections::HashMap, fs, fs::create_dir_all, path::Path, process::exit, string::ToString,
Expand All @@ -49,6 +50,10 @@ use tracing_subscriber::{
reload::Handle,
};

lazy_static! {
static ref USER_AGENT: String = format!("rudder-relayd/{}", crate_version!());
}

// There are two main phases in execution:
//
// * Startup, when all config files are loaded, various structures are initialized,
Expand Down Expand Up @@ -278,10 +283,14 @@ impl JobConfig {
)?)?;
Self::new_http_client(vec![cert])?
}
CertificateVerificationModel::System => Client::builder().https_only(true).build()?,
CertificateVerificationModel::System => Client::builder()
.user_agent(USER_AGENT.clone())
.https_only(true)
.build()?,
CertificateVerificationModel::DangerousNone => {
warn!("Certificate verification is disabled, it should not be done in production");
Client::builder()
.user_agent(USER_AGENT.clone())
.danger_accept_invalid_certs(true)
.build()?
}
Expand Down Expand Up @@ -309,14 +318,16 @@ impl JobConfig {
};
Self::new_http_client(certs)?
}
CertificateVerificationModel::System => {
Client::builder().https_only(true).build()?
}
CertificateVerificationModel::System => Client::builder()
.user_agent(USER_AGENT.clone())
.https_only(true)
.build()?,
CertificateVerificationModel::DangerousNone => {
warn!(
"Certificate verification is disabled, it should not be done in production"
);
Client::builder()
.user_agent(USER_AGENT.clone())
.danger_accept_invalid_certs(true)
.build()?
}
Expand Down Expand Up @@ -376,7 +387,7 @@ impl JobConfig {
//
// Not efficient in "System" case, but it's deprecated anyway
fn new_http_client(certs: Vec<Certificate>) -> Result<Client, Error> {
let mut client = Client::builder();
let mut client = Client::builder().user_agent(USER_AGENT.clone());

client = client
// Let's enforce https to prevent misconfigurations
Expand Down