Implement three-tier permission management across all SecuBox modules: **1. Package-Level Permissions (PKG_FILE_MODES)** - Add PKG_FILE_MODES to all 15 module Makefiles - RPCD scripts: 755 (executable) - CSS/JS/JSON files: 644 (default, no config needed) - Ensures correct permissions at installation time **2. Runtime Permission Fix** - New script: /usr/libexec/secubox/fix-permissions.sh - RPCD method: luci.secubox fix_permissions - UI control: "🔧 Fix Perms" button in Quick Actions - Fixes all permissions and restarts services **3. Automation & Documentation** - secubox-tools/add-pkg-file-modes.sh: Auto-configure PKG_FILE_MODES - PERMISSIONS-GUIDE.md: Comprehensive permissions guide - MODULE-ENABLE-DISABLE-DESIGN.md: Enable/disable system design doc - Updated Makefile template with PKG_FILE_MODES pattern **Modules Updated:** - luci-app-auth-guardian - luci-app-bandwidth-manager - luci-app-cdn-cache - luci-app-client-guardian - luci-app-crowdsec-dashboard - luci-app-ksm-manager - luci-app-media-flow - luci-app-netdata-dashboard - luci-app-netifyd-dashboard - luci-app-network-modes - luci-app-secubox (+ fix-permissions.sh script) - luci-app-system-hub - luci-app-traffic-shaper - luci-app-vhost-manager - luci-app-wireguard-dashboard **Benefits:** - No more manual permission fixes after installation - Users can fix permissions from UI without SSH access - Proper OpenWrt package management compliance - Automated detection and configuration 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
165 lines
4.0 KiB
JavaScript
165 lines
4.0 KiB
JavaScript
'use strict';
|
|
'require baseclass';
|
|
'require rpc';
|
|
|
|
/**
|
|
* Network Modes API
|
|
* Package: luci-app-network-modes
|
|
* RPCD object: luci.network-modes
|
|
*/
|
|
|
|
// Version: 0.2.2
|
|
|
|
var callStatus = rpc.declare({
|
|
object: 'luci.network-modes',
|
|
method: 'status',
|
|
expect: { }
|
|
});
|
|
|
|
var callGetCurrentMode = rpc.declare({
|
|
object: 'luci.network-modes',
|
|
method: 'get_current_mode',
|
|
expect: { mode: '' }
|
|
});
|
|
|
|
var callGetAvailableModes = rpc.declare({
|
|
object: 'luci.network-modes',
|
|
method: 'get_available_modes',
|
|
expect: { modes: [] }
|
|
});
|
|
|
|
var callSetMode = rpc.declare({
|
|
object: 'luci.network-modes',
|
|
method: 'set_mode',
|
|
params: ['mode']
|
|
});
|
|
|
|
var callGetInterfaces = rpc.declare({
|
|
object: 'luci.network-modes',
|
|
method: 'get_interfaces',
|
|
expect: { interfaces: [] }
|
|
});
|
|
|
|
var callValidateConfig = rpc.declare({
|
|
object: 'luci.network-modes',
|
|
method: 'validate_config',
|
|
params: ['mode', 'config'],
|
|
expect: { valid: false, errors: [] }
|
|
});
|
|
|
|
return baseclass.extend({
|
|
getStatus: callStatus,
|
|
getCurrentMode: callGetCurrentMode,
|
|
getAvailableModes: callGetAvailableModes,
|
|
setMode: callSetMode,
|
|
getInterfaces: callGetInterfaces,
|
|
validateConfig: callValidateConfig,
|
|
|
|
// Aggregate function for overview page
|
|
getAllData: function() {
|
|
return Promise.all([
|
|
callStatus(),
|
|
callGetCurrentMode(),
|
|
callGetAvailableModes(),
|
|
callGetInterfaces()
|
|
]).then(function(results) {
|
|
var status = results[0] || {};
|
|
var currentMode = results[1] || {};
|
|
|
|
// Merge current_mode into status for compatibility
|
|
status.current_mode = currentMode.mode || 'router';
|
|
status.interfaces = (results[3] || {}).interfaces || [];
|
|
|
|
return {
|
|
status: status,
|
|
modes: results[2] || { modes: [] }
|
|
};
|
|
});
|
|
},
|
|
|
|
// Get static information about a mode
|
|
getModeInfo: function(mode) {
|
|
var modeInfo = {
|
|
router: {
|
|
id: 'router',
|
|
name: 'Router Mode',
|
|
icon: '🏠',
|
|
description: 'Traditional home/office router with NAT, firewall, and DHCP server. Ideal for connecting multiple devices to the internet.',
|
|
features: [
|
|
'NAT and firewall enabled',
|
|
'DHCP server for LAN clients',
|
|
'Port forwarding and DMZ',
|
|
'QoS and traffic shaping'
|
|
]
|
|
},
|
|
bridge: {
|
|
id: 'bridge',
|
|
name: 'Bridge Mode',
|
|
icon: '🌉',
|
|
description: 'Transparent layer-2 forwarding without NAT. All devices appear on the same network segment.',
|
|
features: [
|
|
'Layer-2 transparent bridging',
|
|
'No NAT or routing',
|
|
'STP/RSTP support',
|
|
'VLAN tagging support'
|
|
]
|
|
},
|
|
accesspoint: {
|
|
id: 'accesspoint',
|
|
name: 'Access Point',
|
|
icon: '📡',
|
|
description: 'WiFi access point with wired uplink. Extends your existing network wirelessly.',
|
|
features: [
|
|
'WiFi hotspot functionality',
|
|
'Wired uplink to main router',
|
|
'Multiple SSID support',
|
|
'Fast roaming (802.11r/k/v)'
|
|
]
|
|
},
|
|
relay: {
|
|
id: 'relay',
|
|
name: 'Repeater/Extender',
|
|
icon: '🔁',
|
|
description: 'WiFi to WiFi repeating to extend wireless coverage. Connects wirelessly to upstream network.',
|
|
features: [
|
|
'WiFi range extension',
|
|
'Wireless uplink (WDS/Relay)',
|
|
'Rebroadcast on same or different SSID',
|
|
'Signal amplification'
|
|
]
|
|
},
|
|
sniffer: {
|
|
id: 'sniffer',
|
|
name: 'Sniffer Mode',
|
|
icon: '🔍',
|
|
description: 'Network monitoring and packet capture mode for security analysis and troubleshooting.',
|
|
features: [
|
|
'Promiscuous mode capture',
|
|
'WiFi monitor mode',
|
|
'pcap/pcapng output',
|
|
'Integration with Wireshark'
|
|
]
|
|
}
|
|
};
|
|
|
|
return modeInfo[mode] || {
|
|
id: mode,
|
|
name: mode.charAt(0).toUpperCase() + mode.slice(1),
|
|
icon: '⚙️',
|
|
description: 'Unknown mode',
|
|
features: []
|
|
};
|
|
},
|
|
|
|
// Format uptime seconds to human readable
|
|
formatUptime: function(seconds) {
|
|
if (!seconds || seconds < 0) return '0d 0h 0m';
|
|
|
|
var days = Math.floor(seconds / 86400);
|
|
var hours = Math.floor((seconds % 86400) / 3600);
|
|
var minutes = Math.floor((seconds % 3600) / 60);
|
|
|
|
return days + 'd ' + hours + 'h ' + minutes + 'm';
|
|
}
|
|
});
|