secubox-openwrt/package/secubox/luci-app-secubox-crowdsec/htdocs/luci-static/resources/secubox-crowdsec/api.js
CyberMind-FR 252341e045 feat: Add complete CrowdSec integration for OpenWrt 24.10+
New packages:
- secubox-crowdsec-setup: Automated installation script with:
  - Prerequisites verification (RAM, flash, OpenWrt version)
  - syslog-ng4 configuration for log forwarding
  - CAPI registration and hub setup
  - nftables firewall bouncer configuration
  - Backup/rollback, repair, and uninstall modes

- luci-app-secubox-crowdsec: LuCI dashboard with:
  - Service status and statistics dashboard
  - Active decisions (bans) management
  - Security alerts viewer
  - Collections and bouncers management
  - UCI-based settings configuration

Enhanced existing packages:
- luci-app-crowdsec-dashboard: Added acquisition configuration wizard
- secubox-app-crowdsec: Improved defaults and configuration

Documentation:
- CROWDSEC-OPENWRT-24.md with architecture, installation, and troubleshooting

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 17:58:17 +01:00

192 lines
3.6 KiB
JavaScript

'use strict';
'require rpc';
var callStatus = rpc.declare({
object: 'luci.secubox-crowdsec',
method: 'status',
expect: { }
});
var callDecisions = rpc.declare({
object: 'luci.secubox-crowdsec',
method: 'decisions',
expect: { decisions: [] }
});
var callAddDecision = rpc.declare({
object: 'luci.secubox-crowdsec',
method: 'add_decision',
params: ['ip', 'duration', 'reason', 'type'],
expect: { }
});
var callDeleteDecision = rpc.declare({
object: 'luci.secubox-crowdsec',
method: 'delete_decision',
params: ['ip', 'decision_id'],
expect: { }
});
var callAlerts = rpc.declare({
object: 'luci.secubox-crowdsec',
method: 'alerts',
params: ['limit', 'since'],
expect: { alerts: [] }
});
var callMetrics = rpc.declare({
object: 'luci.secubox-crowdsec',
method: 'metrics',
expect: { }
});
var callStats = rpc.declare({
object: 'luci.secubox-crowdsec',
method: 'stats',
expect: { }
});
var callCollections = rpc.declare({
object: 'luci.secubox-crowdsec',
method: 'collections',
expect: { collections: [] }
});
var callInstallCollection = rpc.declare({
object: 'luci.secubox-crowdsec',
method: 'install_collection',
params: ['collection'],
expect: { }
});
var callRemoveCollection = rpc.declare({
object: 'luci.secubox-crowdsec',
method: 'remove_collection',
params: ['collection'],
expect: { }
});
var callUpdateHub = rpc.declare({
object: 'luci.secubox-crowdsec',
method: 'update_hub',
expect: { }
});
var callUpgradeHub = rpc.declare({
object: 'luci.secubox-crowdsec',
method: 'upgrade_hub',
expect: { }
});
var callBouncers = rpc.declare({
object: 'luci.secubox-crowdsec',
method: 'bouncers',
expect: { bouncers: [] }
});
var callControlService = rpc.declare({
object: 'luci.secubox-crowdsec',
method: 'control_service',
params: ['service', 'action'],
expect: { }
});
var callNftablesStats = rpc.declare({
object: 'luci.secubox-crowdsec',
method: 'nftables_stats',
expect: { }
});
var callBlockedIps = rpc.declare({
object: 'luci.secubox-crowdsec',
method: 'blocked_ips',
expect: { ipv4: [], ipv6: [] }
});
var callConfig = rpc.declare({
object: 'luci.secubox-crowdsec',
method: 'config',
expect: { }
});
var callSaveConfig = rpc.declare({
object: 'luci.secubox-crowdsec',
method: 'save_config',
params: ['key', 'value'],
expect: { }
});
return L.Class.extend({
getStatus: function() {
return callStatus();
},
getDecisions: function() {
return callDecisions();
},
addDecision: function(ip, duration, reason, type) {
return callAddDecision(ip, duration || '24h', reason || 'Manual ban via LuCI', type || 'ban');
},
deleteDecision: function(ip, decisionId) {
return callDeleteDecision(ip, decisionId);
},
getAlerts: function(limit, since) {
return callAlerts(limit || 50, since || '24h');
},
getMetrics: function() {
return callMetrics();
},
getStats: function() {
return callStats();
},
getCollections: function() {
return callCollections();
},
installCollection: function(collection) {
return callInstallCollection(collection);
},
removeCollection: function(collection) {
return callRemoveCollection(collection);
},
updateHub: function() {
return callUpdateHub();
},
upgradeHub: function() {
return callUpgradeHub();
},
getBouncers: function() {
return callBouncers();
},
controlService: function(service, action) {
return callControlService(service, action);
},
getNftablesStats: function() {
return callNftablesStats();
},
getBlockedIps: function() {
return callBlockedIps();
},
getConfig: function() {
return callConfig();
},
saveConfig: function(key, value) {
return callSaveConfig(key, value);
}
});