Skip to content

Commit 59cd3a4

Browse files
authored
feat(tauri): add dev menu (#1871)
* add a dev menu * update workflows
1 parent df5165b commit 59cd3a4

27 files changed

+223
-143
lines changed

.github/workflows/build-nym-vpn-app-linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ jobs:
109109
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
110110
APP_SENTRY_DSN: ${{ secrets.DESKTOP_JS_SENTRY_DSN }}
111111
# RUSTFLAGS: "-L ${{ env.WG_GO_LIB_PATH }}"
112-
NETWORK_ENV_SELECT: ${{ inputs.dev_mode == true }}
112+
DEV_MODE: ${{ inputs.dev_mode == true }}
113113
run: |
114114
if [ "${{ env.CARGO_TARGET }}" = "release" ]; then
115115
npm run tauri build

.github/workflows/build-nym-vpn-app-windows-ev-sign.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ jobs:
239239
RUSTFLAGS: "-L ${{ env.TAURI_SRC }}/x86_64-pc-windows-msvc -L ${{ env.TAURI_SRC }} -Clink-args=/LIBPATH:${{ env.TAURI_SRC }}/x64-${{ env.CPP_BUILD_MODES }}"
240240
WINDOWS_CERTIFICATE: ${{ secrets.WINDOWS_SIGNING_PFX_BASE64 }}
241241
WINDOWS_CERTIFICATE_PASSWORD: ${{ secrets.WINDOWS_SIGNING_PFX_PASSWORD }}
242-
NETWORK_ENV_SELECT: ${{ inputs.dev_mode == true }}
242+
DEV_MODE: ${{ inputs.dev_mode == true }}
243243
run: |
244244
if [ "${{ env.CARGO_TARGET }}" = "release" ]; then
245245
npm run tauri build

.github/workflows/build-nym-vpn-app-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ jobs:
239239
RUSTFLAGS: "-L ${{ env.TAURI_SRC }}/x86_64-pc-windows-msvc -L ${{ env.TAURI_SRC }} -Clink-args=/LIBPATH:${{ env.TAURI_SRC }}/x64-${{ env.CPP_BUILD_MODES }}"
240240
WINDOWS_CERTIFICATE: ${{ secrets.WINDOWS_SIGNING_PFX_BASE64 }}
241241
WINDOWS_CERTIFICATE_PASSWORD: ${{ secrets.WINDOWS_SIGNING_PFX_PASSWORD }}
242-
NETWORK_ENV_SELECT: ${{ inputs.dev_mode == true }}
242+
DEV_MODE: ${{ inputs.dev_mode == true }}
243243
run: |
244244
if [ "${{ env.CARGO_TARGET }}" = "release" ]; then
245245
npm run tauri build

.github/workflows/publish-nym-vpn-app.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414
type: boolean
1515
default: false
1616
dev_mode:
17-
description: "dev build (enable env selector)"
17+
description: "Enable dev mode (in-app dev menu)"
1818
required: true
1919
type: boolean
2020
default: false

nym-vpn-app/src-tauri/src/cli.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ pub struct Cli {
7373
#[arg(short = 's', long)]
7474
pub nosplash: bool,
7575

76-
/// Enable zknyms credentials mode
76+
// Run in 'dev' mode
7777
#[arg(long, hide = true)]
78-
pub credentials_mode: bool,
78+
pub dev_mode: bool,
7979

8080
#[command(subcommand)]
8181
pub command: Option<Commands>,

nym-vpn-app/src-tauri/src/commands/connection.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ pub async fn connect(
7676
.dns_server
7777
.clone()
7878
.map(|ip| nym_vpn_proto::Dns { ip });
79+
let credentials_mode = app_state.credentials_mode;
7980
// release the lock
8081
drop(app_state);
8182

@@ -146,6 +147,7 @@ pub async fn connect(
146147
entry_node,
147148
exit_node,
148149
two_hop_mod,
150+
credentials_mode,
149151
use_netstack_wireguard,
150152
dns,
151153
)

nym-vpn-app/src-tauri/src/commands/daemon.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::env::NETWORK_ENV_SELECT;
1+
use crate::env::DEV_MODE;
22
use crate::error::BackendError;
33
use crate::grpc::client::{FeatureFlags, GrpcClient, SystemMessage, VpndStatus};
44
use crate::states::SharedAppState;
@@ -41,8 +41,8 @@ pub async fn set_network(
4141
grpc_client: State<'_, GrpcClient>,
4242
network: NetworkEnv,
4343
) -> Result<(), BackendError> {
44-
if !*NETWORK_ENV_SELECT {
45-
warn!("network env selector is disabled");
44+
if !*DEV_MODE {
45+
warn!("not in dev mode");
4646
return Err(BackendError::internal("nope", None));
4747
}
4848
grpc_client
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use crate::env::DEV_MODE;
2+
use crate::error::BackendError;
3+
use crate::states::SharedAppState;
4+
use tauri::State;
5+
use tracing::{instrument, warn};
6+
7+
#[instrument(skip(state))]
8+
#[tauri::command]
9+
pub async fn get_credentials_mode(state: State<'_, SharedAppState>) -> Result<bool, BackendError> {
10+
let state = state.lock().await;
11+
Ok(state.credentials_mode)
12+
}
13+
14+
#[instrument(skip(state))]
15+
#[tauri::command]
16+
pub async fn set_credentials_mode(
17+
state: State<'_, SharedAppState>,
18+
enabled: bool,
19+
) -> Result<(), BackendError> {
20+
if !*DEV_MODE {
21+
warn!("not in dev mode");
22+
return Err(BackendError::internal("nope", None));
23+
}
24+
let mut state = state.lock().await;
25+
state.credentials_mode = enabled;
26+
Ok(())
27+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::env::NETWORK_ENV_SELECT;
1+
use crate::env::DEV_MODE;
22
use serde::Serialize;
33
use tracing::instrument;
44
use ts_rs::TS;
@@ -7,13 +7,13 @@ use ts_rs::TS;
77
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
88
#[ts(export)]
99
pub struct Env {
10-
network_env_select: bool,
10+
dev_mode: bool,
1111
}
1212

1313
#[instrument(skip_all)]
1414
#[tauri::command]
1515
pub async fn env() -> Env {
1616
Env {
17-
network_env_select: *NETWORK_ENV_SELECT,
17+
dev_mode: *DEV_MODE,
1818
}
1919
}

nym-vpn-app/src-tauri/src/commands/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pub mod connection;
44
pub mod country;
55
pub mod daemon;
66
pub mod db;
7+
pub mod dev;
78
pub mod env;
89
pub mod fs;
910
pub mod log;

0 commit comments

Comments
 (0)