From 4b0aff2700764df09d9648776ab40884bd79efc3 Mon Sep 17 00:00:00 2001 From: CyberMind-FR Date: Wed, 28 Jan 2026 15:15:06 +0100 Subject: [PATCH] fix(tor-shield): Fix RPC expect declarations breaking API calls The expect: { success: false } was causing LuCI RPC to return false instead of the actual response. Changed all expect declarations to empty objects to get raw API responses. Also improved error messages to show actual response for debugging. Co-Authored-By: Claude Opus 4.5 --- .../luci-static/resources/tor-shield/api.js | 16 ++++++++-------- .../resources/view/tor-shield/overview.js | 9 ++++++--- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/package/secubox/luci-app-tor-shield/htdocs/luci-static/resources/tor-shield/api.js b/package/secubox/luci-app-tor-shield/htdocs/luci-static/resources/tor-shield/api.js index af5cc6f2..e659fd2b 100644 --- a/package/secubox/luci-app-tor-shield/htdocs/luci-static/resources/tor-shield/api.js +++ b/package/secubox/luci-app-tor-shield/htdocs/luci-static/resources/tor-shield/api.js @@ -12,19 +12,19 @@ var callEnable = rpc.declare({ object: 'luci.tor-shield', method: 'enable', params: ['preset'], - expect: { success: false } + expect: { } }); var callDisable = rpc.declare({ object: 'luci.tor-shield', method: 'disable', - expect: { success: false } + expect: { } }); var callRestart = rpc.declare({ object: 'luci.tor-shield', method: 'restart', - expect: { success: false } + expect: { } }); var callCircuits = rpc.declare({ @@ -36,7 +36,7 @@ var callCircuits = rpc.declare({ var callNewIdentity = rpc.declare({ object: 'luci.tor-shield', method: 'new_identity', - expect: { success: false } + expect: { } }); var callCheckLeaks = rpc.declare({ @@ -55,14 +55,14 @@ var callAddHiddenService = rpc.declare({ object: 'luci.tor-shield', method: 'add_hidden_service', params: ['name', 'local_port', 'virtual_port'], - expect: { success: false } + expect: { } }); var callRemoveHiddenService = rpc.declare({ object: 'luci.tor-shield', method: 'remove_hidden_service', params: ['name'], - expect: { success: false } + expect: { } }); var callExitIp = rpc.declare({ @@ -93,7 +93,7 @@ var callSetBridges = rpc.declare({ object: 'luci.tor-shield', method: 'set_bridges', params: ['enabled', 'type'], - expect: { success: false } + expect: { } }); var callSettings = rpc.declare({ @@ -106,7 +106,7 @@ var callSaveSettings = rpc.declare({ object: 'luci.tor-shield', method: 'save_settings', params: ['mode', 'dns_over_tor', 'kill_switch', 'socks_port', 'trans_port', 'dns_port', 'exit_nodes', 'exclude_exit_nodes', 'strict_nodes'], - expect: { success: false } + expect: { } }); function formatBytes(bytes) { diff --git a/package/secubox/luci-app-tor-shield/htdocs/luci-static/resources/view/tor-shield/overview.js b/package/secubox/luci-app-tor-shield/htdocs/luci-static/resources/view/tor-shield/overview.js index 4801cf14..0a679466 100644 --- a/package/secubox/luci-app-tor-shield/htdocs/luci-static/resources/view/tor-shield/overview.js +++ b/package/secubox/luci-app-tor-shield/htdocs/luci-static/resources/view/tor-shield/overview.js @@ -90,15 +90,18 @@ return view.extend({ api.enable(presetId).then(function(result) { ui.hideModal(); - if (result.success) { + if (result && result.success) { ui.addNotification(null, E('p', _('Preset %s activated').format(presetId)), 'info'); setTimeout(function() { window.location.reload(); }, 1000); } else { - ui.addNotification(null, E('p', result.error || _('Failed to apply preset')), 'error'); + var errMsg = (result && result.error) ? result.error : + (result && result.message) ? result.message : + 'Unknown error - result: ' + JSON.stringify(result); + ui.addNotification(null, E('p', _('Failed: %s').format(errMsg)), 'error'); } }).catch(function(err) { ui.hideModal(); - ui.addNotification(null, E('p', _('Error: %s').format(err.message || String(err))), 'error'); + ui.addNotification(null, E('p', _('Exception: %s').format(err.message || String(err))), 'error'); }); },