secubox-openwrt/package/secubox/luci-app-client-guardian/htdocs/luci-static/resources/client-guardian/api.js
CyberMind-FR 31a87c5d7a feat(structure): reorganize luci-app packages into package/secubox/ + appstore migration
Major structural reorganization and feature additions:

## Folder Reorganization
- Move 17 luci-app-* packages to package/secubox/ (except luci-app-secubox core hub)
- Update all tooling to support new structure:
  - secubox-tools/quick-deploy.sh: search both locations
  - secubox-tools/validate-modules.sh: validate both directories
  - secubox-tools/fix-permissions.sh: fix permissions in both locations
  - .github/workflows/test-validate.yml: build from both paths
- Update README.md links to new package/secubox/ paths

## AppStore Migration (Complete)
- Add catalog entries for all remaining luci-app packages:
  - network-tweaks.json: Network optimization tools
  - secubox-bonus.json: Documentation & demos hub
- Total: 24 apps in AppStore catalog (22 existing + 2 new)
- New category: 'documentation' for docs/demos/tutorials

## VHost Manager v2.0 Enhancements
- Add profile activation system for Internal Services and Redirects
- Implement createVHost() API wrapper for template-based deployment
- Fix Virtual Hosts view rendering with proper LuCI patterns
- Fix RPCD backend shell script errors (remove invalid local declarations)
- Extend backend validation for nginx return directives (redirect support)
- Add section_id parameter for named VHost profiles
- Add Remove button to Redirects page for feature parity
- Update README to v2.0 with comprehensive feature documentation

## Network Tweaks Dashboard
- Close button added to component details modal

Files changed: 340+ (336 renames with preserved git history)
Packages affected: 19 luci-app, 2 secubox-app, 1 theme, 4 tools

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-01 14:59:38 +01:00

202 lines
4.4 KiB
JavaScript

'use strict';
'require baseclass';
'require rpc';
/**
* Client Guardian API
* Package: luci-app-client-guardian
* RPCD object: luci.client-guardian
*/
// Version: 0.4.0
var callStatus = rpc.declare({
object: 'luci.client-guardian',
method: 'status',
expect: { }
});
var callClients = rpc.declare({
object: 'luci.client-guardian',
method: 'clients',
expect: { clients: [] }
});
var callGetClient = rpc.declare({
object: 'luci.client-guardian',
method: 'get_client',
params: ['mac'],
expect: { }
});
var callZones = rpc.declare({
object: 'luci.client-guardian',
method: 'zones',
expect: { zones: [] }
});
var callParental = rpc.declare({
object: 'luci.client-guardian',
method: 'parental',
expect: { }
});
var callPortal = rpc.declare({
object: 'luci.client-guardian',
method: 'portal',
expect: { }
});
var callAlerts = rpc.declare({
object: 'luci.client-guardian',
method: 'alerts',
expect: { }
});
var callLogs = rpc.declare({
object: 'luci.client-guardian',
method: 'logs',
params: ['limit', 'level'],
expect: { logs: [] }
});
var callApproveClient = rpc.declare({
object: 'luci.client-guardian',
method: 'approve_client',
params: ['mac', 'name', 'zone', 'notes'],
expect: { success: false }
});
var callBanClient = rpc.declare({
object: 'luci.client-guardian',
method: 'ban_client',
params: ['mac', 'reason'],
expect: { success: false }
});
var callQuarantineClient = rpc.declare({
object: 'luci.client-guardian',
method: 'quarantine_client',
params: ['mac'],
expect: { success: false }
});
var callUpdateClient = rpc.declare({
object: 'luci.client-guardian',
method: 'update_client',
params: ['section', 'name', 'zone', 'notes', 'daily_quota', 'static_ip'],
expect: { success: false }
});
var callUpdateZone = rpc.declare({
object: 'luci.client-guardian',
method: 'update_zone',
params: ['id', 'name', 'bandwidth_limit', 'content_filter'],
expect: { success: false }
});
var callUpdatePortal = rpc.declare({
object: 'luci.client-guardian',
method: 'update_portal',
params: ['title', 'subtitle', 'accent_color'],
expect: { success: false }
});
var callSendTestAlert = rpc.declare({
object: 'luci.client-guardian',
method: 'send_test_alert',
params: ['type'],
expect: { success: false }
});
// Nodogsplash Captive Portal Methods
var callListSessions = rpc.declare({
object: 'luci.client-guardian',
method: 'list_sessions',
expect: { sessions: [] }
});
var callGetPolicy = rpc.declare({
object: 'luci.client-guardian',
method: 'get_policy',
expect: { }
});
var callSetPolicy = rpc.declare({
object: 'luci.client-guardian',
method: 'set_policy',
params: ['policy', 'portal_enabled', 'auto_approve', 'session_timeout'],
expect: { success: false }
});
var callAuthorizeClient = rpc.declare({
object: 'luci.client-guardian',
method: 'authorize_client',
params: ['mac', 'ip'],
expect: { success: false }
});
var callDeauthorizeClient = rpc.declare({
object: 'luci.client-guardian',
method: 'deauthorize_client',
params: ['mac', 'ip'],
expect: { success: false }
});
function formatMac(mac) {
if (!mac) return '';
return mac.toUpperCase().replace(/(.{2})(?=.)/g, '$1:');
}
function formatDuration(seconds) {
if (!seconds) return 'Unlimited';
var h = Math.floor(seconds / 3600);
var m = Math.floor((seconds % 3600) / 60);
if (h > 24) return Math.floor(h / 24) + 'd';
if (h > 0) return h + 'h ' + m + 'm';
return m + 'm';
}
function formatBytes(bytes) {
if (!bytes || bytes === 0) return '0 B';
var units = ['B', 'KB', 'MB', 'GB', 'TB'];
var i = Math.floor(Math.log(bytes) / Math.log(1024));
i = Math.min(i, units.length - 1);
return (bytes / Math.pow(1024, i)).toFixed(2) + ' ' + units[i];
}
return baseclass.extend({
// Core methods
getStatus: callStatus,
getClients: callClients,
getClient: callGetClient,
getZones: callZones,
getParental: callParental,
getPortal: callPortal,
getAlerts: callAlerts,
getLogs: callLogs,
// Client management
approveClient: callApproveClient,
banClient: callBanClient,
quarantineClient: callQuarantineClient,
updateClient: callUpdateClient,
// Configuration
updateZone: callUpdateZone,
updatePortal: callUpdatePortal,
sendTestAlert: callSendTestAlert,
// Nodogsplash Captive Portal
listSessions: callListSessions,
getPolicy: callGetPolicy,
setPolicy: callSetPolicy,
authorizeClient: callAuthorizeClient,
deauthorizeClient: callDeauthorizeClient,
// Utility functions
formatMac: formatMac,
formatDuration: formatDuration,
formatBytes: formatBytes
});