Skip to content
Merged
Show file tree
Hide file tree
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions crates/defguard_common/src/db/models/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub struct Gateway<I = NoId> {
pub disconnected_at: Option<NaiveDateTime>,
pub has_certificate: bool,
pub certificate_expiry: Option<NaiveDateTime>,
pub version: Option<String>,
}

impl<I> Gateway<I> {
Expand All @@ -43,6 +44,7 @@ impl Gateway {
disconnected_at: None,
has_certificate: false,
certificate_expiry: None,
version: None,
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/defguard_common/src/db/models/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub struct Proxy<I = NoId> {
pub public_address: String,
pub connected_at: Option<NaiveDateTime>,
pub disconnected_at: Option<NaiveDateTime>,
pub version: Option<String>,
pub has_certificate: bool,
pub certificate_expiry: Option<NaiveDateTime>,
}
Expand All @@ -29,6 +30,7 @@ impl Proxy {
disconnected_at: None,
has_certificate: false,
certificate_expiry: None,
version: None,
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions crates/defguard_core/src/grpc/gateway/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,14 @@ impl GatewayHandler {
};
info!("Connected to Defguard Gateway {uri}");

let maybe_info = defguard_version::ComponentInfo::from_metadata(response.metadata());
let (version, _info) = defguard_version::get_tracing_variables(&maybe_info);

if let Some(mut gateway) = Gateway::find_by_id(&self.pool, self.gateway.id).await? {
gateway.version = Some(version.to_string());
gateway.save(&self.pool).await?;
}

let mut resp_stream = response.into_inner();
let mut config_sent = false;

Expand Down
38 changes: 36 additions & 2 deletions crates/defguard_core/src/handlers/mail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,42 @@ pub async fn send_support_data(
"User {} sending support mail to {SUPPORT_EMAIL_ADDRESS}",
session.user.username
);

let proxies = defguard_common::db::models::proxy::Proxy::all(&appstate.pool).await?;
let gateways = defguard_common::db::models::gateway::Gateway::all(&appstate.pool).await?;

let components_info = json!({
"proxies": proxies.iter().map(|p| json!({
"id": p.id,
"name": p.name,
"version": p.version.as_deref().unwrap_or("unknown"),
"address": p.address,
"connected_at": p.connected_at
})).collect::<Vec<_>>(),
"gateways": gateways.iter().map(|g| json!({
"id": g.id,
"network_id": g.network_id,
"version": g.version.as_deref().unwrap_or("unknown"),
"url": g.url,
"has_certificate": g.has_certificate,
"hostname": g.hostname,
"connected_at": g.connected_at,
})).collect::<Vec<_>>(),
});

let components_json =
serde_json::to_string(&components_info).unwrap_or("JSON formatting error".to_string());

let components = Attachment {
filename: format!("defguard-components-{}.json", Utc::now()),
content: components_json.into(),
content_type: ContentType::TEXT_PLAIN,
};

let config = dump_config(&appstate.pool).await;
let config =
serde_json::to_string_pretty(&config).unwrap_or("Json formatting error".to_string());
serde_json::to_string_pretty(&config).unwrap_or("JSON formatting error".to_string());

let config = Attachment {
filename: format!("defguard-support-data-{}.json", Utc::now()),
content: config.into(),
Expand All @@ -149,10 +182,11 @@ pub async fn send_support_data(
to: SUPPORT_EMAIL_ADDRESS.to_string(),
subject: SUPPORT_EMAIL_SUBJECT.to_string(),
content: support_data_mail()?,
attachments: vec![config, logs],
attachments: vec![components, config, logs],
result_tx: Some(tx),
};
let (to, subject) = (mail.to.clone(), mail.subject.clone());

match appstate.mail_tx.send(mail) {
Ok(()) => match rx.recv().await {
Some(Ok(_)) => {
Expand Down
Loading
Loading