Skip to content

Commit ea865a0

Browse files
committedMar 7, 2024
Merge branch 'simulate-overriden-environment-variable-when-running-on-ios-ios-541'
2 parents 0d59450 + 2b94c70 commit ea865a0

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed
 

‎ios/MullvadVPNUITests/MullvadApi.swift

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ struct InitMutableBufferError: Error {
3232
let description = "Failed to allocate memory for mutable buffer"
3333
}
3434

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

‎mullvad-api/src/ffi/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ impl FfiClient {
6868
)
6969
})?;
7070

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

7379
runtime_builder.worker_threads(2).enable_all();

0 commit comments

Comments
 (0)