From 28378fe24ef485631a5ed1a787744d6615971e5d Mon Sep 17 00:00:00 2001 From: Reactor Scram Date: Fri, 21 Jun 2024 23:06:41 +0000 Subject: [PATCH] refactor(headless-client): remove FIREZONE_PACKAGE_VERSION (#5487) Closes #5481 With this, I can connect to the staging portal without a build.rs or any extra env var setup image ```[tasklist] ### Next steps - [x] Split out a refactor PR for `ConnectArgs` (#5488) - [x] Try doing this for other Clients - [x] Check Gateway - [x] Check Tauri Client - [x] Change to `app_version` - [x] Open for review - [ ] Use `option_env` so that `FIREZONE_PACKAGE_VERSION` can still override the Cargo.toml version for local testing - [ ] Check Android Client - [ ] Check Apple Client ``` --------- Signed-off-by: Reactor Scram --- .github/workflows/_build_artifacts.yml | 8 +------- .github/workflows/_kotlin.yml | 2 -- .github/workflows/_swift.yml | 2 -- .github/workflows/_tauri.yml | 2 -- rust/connlib/clients/android/src/lib.rs | 1 + rust/connlib/clients/apple/src/lib.rs | 1 + rust/connlib/clients/shared/src/lib.rs | 4 +++- rust/connlib/shared/src/lib.rs | 5 ++--- rust/gateway/src/main.rs | 2 +- rust/headless-client/src/lib.rs | 2 ++ 10 files changed, 11 insertions(+), 18 deletions(-) diff --git a/.github/workflows/_build_artifacts.yml b/.github/workflows/_build_artifacts.yml index ada41f0a7..b0a1a14e9 100644 --- a/.github/workflows/_build_artifacts.yml +++ b/.github/workflows/_build_artifacts.yml @@ -153,8 +153,6 @@ jobs: artifact: firezone-client-headless-linux image_name: client # mark:next-headless-version - version: 1.1.0 - # mark:next-headless-version release_name: headless-client-1.1.0 - package: firezone-relay artifact: firezone-relay @@ -163,8 +161,6 @@ jobs: artifact: firezone-gateway image_name: gateway # mark:next-gateway-version - version: 1.1.1 - # mark:next-gateway-version release_name: gateway-1.1.1 - package: snownet-tests artifact: snownet-tests @@ -202,9 +198,7 @@ jobs: PROFILE="" fi - # Override version by setting it inside cross container if it's provided - ${{ matrix.name.version && format('CROSS_CONTAINER_OPTS="--env FIREZONE_PACKAGE_VERSION={0}"', matrix.name.version) }} \ - cross build $PROFILE -p ${{ matrix.name.package }} --target ${{ matrix.arch.target }} + cross build $PROFILE -p ${{ matrix.name.package }} --target ${{ matrix.arch.target }} # Used for Docker images cp target/${{ matrix.arch.target }}/${{ inputs.profile }}/${{ matrix.name.package }} ${{ matrix.name.package }} diff --git a/.github/workflows/_kotlin.yml b/.github/workflows/_kotlin.yml index e04bed0d3..c3d7a30ea 100644 --- a/.github/workflows/_kotlin.yml +++ b/.github/workflows/_kotlin.yml @@ -50,8 +50,6 @@ jobs: - run: touch local.properties - name: Bundle and sign release env: - # mark:next-android-version - FIREZONE_PACKAGE_VERSION: 1.1.0 KEYSTORE_BASE64: ${{ secrets.GOOGLE_UPLOAD_KEYSTORE_BASE64 }} KEYSTORE_PASSWORD: ${{ secrets.GOOGLE_UPLOAD_KEYSTORE_PASSWORD }} KEYSTORE_KEY_PASSWORD: ${{ secrets.GOOGLE_UPLOAD_KEYSTORE_KEY_PASSWORD }} diff --git a/.github/workflows/_swift.yml b/.github/workflows/_swift.yml index 2ca99444e..0c69598f2 100644 --- a/.github/workflows/_swift.yml +++ b/.github/workflows/_swift.yml @@ -95,8 +95,6 @@ jobs: ONLY_ACTIVE_ARCH: no # Needed because `productbuild` doesn't support picking this up automatically like Xcode does INSTALLER_CODE_SIGN_IDENTITY: "3rd Party Mac Developer Installer: Firezone, Inc. (47R2M6779T)" - # mark:next-apple-version - FIREZONE_PACKAGE_VERSION: 1.1.0 run: | # Use the same Xcode version as development sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app diff --git a/.github/workflows/_tauri.yml b/.github/workflows/_tauri.yml index 859aaa270..786a8ff29 100644 --- a/.github/workflows/_tauri.yml +++ b/.github/workflows/_tauri.yml @@ -49,8 +49,6 @@ jobs: AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }} AZURE_CERT_NAME: ${{ secrets.AZURE_CERT_NAME }} - # mark:next-gui-version - FIREZONE_PACKAGE_VERSION: 1.1.0 steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup-node diff --git a/rust/connlib/clients/android/src/lib.rs b/rust/connlib/clients/android/src/lib.rs index 298dd25d4..b2296c2eb 100644 --- a/rust/connlib/clients/android/src/lib.rs +++ b/rust/connlib/clients/android/src/lib.rs @@ -381,6 +381,7 @@ fn connect( sockets, private_key, os_version_override: Some(os_version), + app_version: env!("CARGO_PKG_VERSION").to_string(), callbacks, max_partition_time: Some(MAX_PARTITION_TIME), }; diff --git a/rust/connlib/clients/apple/src/lib.rs b/rust/connlib/clients/apple/src/lib.rs index e8fd41da0..895f90612 100644 --- a/rust/connlib/clients/apple/src/lib.rs +++ b/rust/connlib/clients/apple/src/lib.rs @@ -196,6 +196,7 @@ impl WrappedSession { sockets: Sockets::new(), private_key, os_version_override, + app_version: env!("CARGO_PKG_VERSION").to_string(), callbacks: CallbackHandler { inner: Arc::new(callback_handler), }, diff --git a/rust/connlib/clients/shared/src/lib.rs b/rust/connlib/clients/shared/src/lib.rs index 2c5c3a6b0..95e2aeb98 100644 --- a/rust/connlib/clients/shared/src/lib.rs +++ b/rust/connlib/clients/shared/src/lib.rs @@ -38,6 +38,7 @@ pub struct ConnectArgs { pub sockets: Sockets, pub private_key: StaticSecret, pub os_version_override: Option, + pub app_version: String, pub callbacks: CB, pub max_partition_time: Option, } @@ -113,6 +114,7 @@ where sockets, private_key, os_version_override, + app_version, callbacks, max_partition_time, } = args; @@ -121,7 +123,7 @@ where let portal = PhoenixChannel::connect( Secret::new(url), - get_user_agent(os_version_override), + get_user_agent(os_version_override, &app_version), PHOENIX_TOPIC, (), ExponentialBackoffBuilder::default() diff --git a/rust/connlib/shared/src/lib.rs b/rust/connlib/shared/src/lib.rs index 85d2823a7..79f81c7c6 100644 --- a/rust/connlib/shared/src/lib.rs +++ b/rust/connlib/shared/src/lib.rs @@ -51,7 +51,7 @@ pub fn keypair() -> (StaticSecret, PublicKey) { (private_key, public_key) } -pub fn get_user_agent(os_version_override: Option) -> String { +pub fn get_user_agent(os_version_override: Option, app_version: &str) -> String { // Note: we could switch to sys-info and get the hostname // but we lose the arch // and neither of the libraries provide the kernel version. @@ -67,9 +67,8 @@ pub fn get_user_agent(os_version_override: Option) -> String { let os_version = os_version_override.unwrap_or(info.version().to_string()); let additional_info = additional_info(); - let version = option_env!("FIREZONE_PACKAGE_VERSION").unwrap_or("development"); let lib_name = LIB_NAME; - format!("{os_type}/{os_version}{additional_info}{lib_name}/{version}") + format!("{os_type}/{os_version}{additional_info}{lib_name}/{app_version}") } fn additional_info() -> String { diff --git a/rust/gateway/src/main.rs b/rust/gateway/src/main.rs index 650636f79..455406759 100644 --- a/rust/gateway/src/main.rs +++ b/rust/gateway/src/main.rs @@ -102,7 +102,7 @@ async fn run(login: LoginUrl, private_key: StaticSecret) -> Result { let (portal, init) = phoenix_channel::init::<_, InitGateway, _, _>( Secret::new(login), - get_user_agent(None), + get_user_agent(None, env!("CARGO_PKG_VERSION")), PHOENIX_TOPIC, (), ExponentialBackoffBuilder::default() diff --git a/rust/headless-client/src/lib.rs b/rust/headless-client/src/lib.rs index 56f13fa75..654b07e10 100644 --- a/rust/headless-client/src/lib.rs +++ b/rust/headless-client/src/lib.rs @@ -288,6 +288,7 @@ pub fn run_only_headless_client() -> Result<()> { sockets: Sockets::new(), private_key, os_version_override: None, + app_version: env!("CARGO_PKG_VERSION").to_string(), callbacks, max_partition_time, }; @@ -563,6 +564,7 @@ impl Handler { sockets: Sockets::new(), private_key, os_version_override: None, + app_version: env!("CARGO_PKG_VERSION").to_string(), callbacks: self.callback_handler.clone(), max_partition_time: Some(Duration::from_secs(60 * 60 * 24 * 30)), };