Skip to content

Commit

Permalink
Merge branch 'simulate-overriden-environment-variable-when-running-on…
Browse files Browse the repository at this point in the history
…-ios-ios-541'
  • Loading branch information
buggmagnet committed Mar 7, 2024
2 parents 0d59450 + 2b94c70 commit ea865a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ios/MullvadVPNUITests/MullvadApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ struct InitMutableBufferError: Error {
let description = "Failed to allocate memory for mutable buffer"
}

/// - Warning: Do not change the `apiAddress` or the `hostname` after the time `MullvadApi.init` has been invoked
/// The Mullvad API crate is using a global static variable to store those. They will be initialized only once.
///
class MullvadApi {
private var clientContext = MullvadApiClient()

Expand Down
6 changes: 6 additions & 0 deletions mullvad-api/src/ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ impl FfiClient {
)
})?;

// The call site guarantees that
// api_hostname and api_address will never change after the first call to new.
std::env::set_var(crate::env::API_HOST_VAR, &api_hostname);
std::env::set_var(crate::env::API_ADDR_VAR, &addr_str);
std::env::set_var(crate::env::API_FORCE_DIRECT_VAR, "0");
std::env::set_var(crate::env::DISABLE_TLS_VAR, "0");
let mut runtime_builder = tokio::runtime::Builder::new_multi_thread();

runtime_builder.worker_threads(2).enable_all();
Expand Down

0 comments on commit ea865a0

Please sign in to comment.