Skip to content
Open
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
6 changes: 3 additions & 3 deletions new-ui/src/shared/components/WindowHeader/WindowHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import clsx from 'clsx';
import './style.scss';
import { useQuery } from '@tanstack/react-query';
import { getVersion } from '@tauri-apps/api/app';
import { useId } from 'react';
import { api } from '../../rust-api/api';
import { isPresent } from '../../utils/isPresent';
import { ConnectionWatcher } from './components/ConnectionWatcher/ConnectionsWatcher';

Expand All @@ -12,8 +12,8 @@ interface Props {

export const WindowHeader = ({ variant }: Props) => {
const { data: appVersion } = useQuery({
queryFn: getVersion,
queryKey: ['app-version'],
queryFn: api.getClientBuildVersion,
queryKey: ['client-build-version'],
});

const version = () => {
Expand Down
4 changes: 4 additions & 0 deletions new-ui/src/shared/rust-api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ const getPlatformHeader = (): Promise<string> => invoke(TauriCommand.GetPlatform
const getLatestAppVersion = (): Promise<NewAppVersionInfo> =>
invoke(TauriCommand.GetLatestAppVersion);

const getClientBuildVersion = (): Promise<string> =>
invoke(TauriCommand.GetClientBuildVersion);

const openLink = (link: string): Promise<void> => invoke(TauriCommand.OpenLink, { link });

const startGlobalLogWatcher = (): Promise<void> =>
Expand Down Expand Up @@ -367,6 +370,7 @@ export const api = {
getProvisioningConfig,
getPlatformHeader,
getLatestAppVersion,
getClientBuildVersion,
openLink,
startGlobalLogWatcher,
stopGlobalLogWatcher,
Expand Down
1 change: 1 addition & 0 deletions new-ui/src/shared/rust-api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export const TauriCommand = {
GetProvisioningConfig: 'get_provisioning_config',
GetPlatformHeader: 'get_platform_header',
GetLatestAppVersion: 'get_latest_app_version',
GetClientBuildVersion: 'get_client_build_version',
OpenLink: 'open_link',
StartGlobalLogWatcher: 'start_global_logwatcher',
StopGlobalLogWatcher: 'stop_global_logwatcher',
Expand Down
7 changes: 5 additions & 2 deletions src-tauri/enterprise/posture/src/inspector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub(crate) mod windows;

use std::env::consts::OS;

use defguard_client_core::version::PKG_VERSION;
use defguard_client_core::version::{select_reported_app_version, PKG_VERSION};
use defguard_client_proto::defguard::enterprise::posture::v2::{
BoolCheck, DevicePostureData, Int32Check, StringCheck, UnavailableReason,
};
Expand Down Expand Up @@ -140,7 +140,10 @@ fn security_update_age_days() -> Result<i32, UnavailableReason> {
#[must_use]
pub fn device_posture_data(disk_target: DiskEncryptionTarget) -> DevicePostureData {
DevicePostureData {
defguard_client_version: PKG_VERSION.to_owned(),
defguard_client_version: select_reported_app_version(
PKG_VERSION,
option_env!("DEFGUARD_CLIENT_BUILD_VERSION"),
),
os_type: OS.to_string(),
os_name: Some(StringCheck::from(os_name())),
os_version: Some(StringCheck::from(os_version())),
Expand Down
1 change: 1 addition & 0 deletions src-tauri/permissions/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ commands.allow = [
"update_tunnel",
"delete_tunnel",
"get_latest_app_version",
"get_client_build_version",
"start_global_logwatcher",
"stop_global_logwatcher",
"command_get_app_config",
Expand Down
11 changes: 8 additions & 3 deletions src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1409,16 +1409,21 @@ pub struct AppVersionInfo {

const PRODUCT_NAME: &str = "defguard-client";

fn reported_app_version(handle: &AppHandle) -> String {
fn reported_app_version(package_version: &str) -> String {
defguard_client_core::version::select_reported_app_version(
&handle.package_info().version.to_string(),
package_version,
option_env!("DEFGUARD_CLIENT_BUILD_VERSION"),
)
}

#[tauri::command]
pub fn get_client_build_version() -> String {
reported_app_version(defguard_client_core::version::PKG_VERSION)
}

#[tauri::command(async)]
pub async fn get_latest_app_version(handle: AppHandle) -> Result<AppVersionInfo, Error> {
let app_version = reported_app_version(&handle);
let app_version = reported_app_version(&handle.package_info().version.to_string());
let operating_system = env::consts::OS;

let mut request_data = HashMap::new();
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ pub fn run_app() {
update_tunnel,
delete_tunnel,
get_latest_app_version,
get_client_build_version,
start_global_logwatcher,
stop_global_logwatcher,
command_get_app_config,
Expand Down
Loading