Implements comprehensive bandwidth management system with QoS traffic shaping, client quotas, and SQM/CAKE integration for OpenWrt. Features: - QoS traffic shaping with rule-based control (application/port/IP/MAC) - Per-rule download/upload limits with 8-level priority system - Time-based scheduling support for rules - Monthly data quotas per client (MAC address) - iptables-based usage tracking with real-time statistics - Configurable quota actions: throttle, block, or notify - Automatic monthly reset with configurable reset day - SQM/CAKE integration with NAT-aware configuration - Link overhead compensation (Ethernet, PPPoE, VLAN) - Alternative FQ_CoDel and HTB qdisc support Components: - RPCD backend (luci.bandwidth-manager): 10 ubus methods * status, list_rules, add_rule, delete_rule * list_quotas, get_quota, set_quota, reset_quota * get_usage_realtime, get_usage_history - 5 JavaScript views: overview, rules, quotas, usage, settings - ACL with read/write permissions for all methods - UCI config with global, SQM, tracking, alerts, rules, and quotas sections - Comprehensive README with API docs and examples Technical implementation: - Traffic tracking via iptables BW_TRACKING chain - Usage database in /tmp/bandwidth_usage.db (pipe-delimited format) - Real-time client usage with 5-second auto-refresh - Historical data with configurable timeframes (1h to 30d) - Per-client quota progress visualization with color-coded bars - TC (traffic control) integration for QoS enforcement Architecture follows SecuBox standards: - RPCD naming convention (luci. prefix) - Menu paths match view file structure - All JavaScript in strict mode - Form-based configuration management - Comprehensive error handling Dependencies: tc, kmod-sched-core, kmod-sched-cake, kmod-ifb, sqm-scripts, iptables, iptables-mod-conntrack-extra, ip-full 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
82 lines
1.7 KiB
JavaScript
82 lines
1.7 KiB
JavaScript
'use strict';
|
|
'require rpc';
|
|
|
|
var callStatus = rpc.declare({
|
|
object: 'luci.bandwidth-manager',
|
|
method: 'status',
|
|
expect: {}
|
|
});
|
|
|
|
var callListRules = rpc.declare({
|
|
object: 'luci.bandwidth-manager',
|
|
method: 'list_rules',
|
|
expect: { rules: [] }
|
|
});
|
|
|
|
var callAddRule = rpc.declare({
|
|
object: 'luci.bandwidth-manager',
|
|
method: 'add_rule',
|
|
params: ['name', 'type', 'target', 'limit_down', 'limit_up', 'priority'],
|
|
expect: {}
|
|
});
|
|
|
|
var callDeleteRule = rpc.declare({
|
|
object: 'luci.bandwidth-manager',
|
|
method: 'delete_rule',
|
|
params: ['rule_id'],
|
|
expect: {}
|
|
});
|
|
|
|
var callListQuotas = rpc.declare({
|
|
object: 'luci.bandwidth-manager',
|
|
method: 'list_quotas',
|
|
expect: { quotas: [] }
|
|
});
|
|
|
|
var callGetQuota = rpc.declare({
|
|
object: 'luci.bandwidth-manager',
|
|
method: 'get_quota',
|
|
params: ['mac'],
|
|
expect: {}
|
|
});
|
|
|
|
var callSetQuota = rpc.declare({
|
|
object: 'luci.bandwidth-manager',
|
|
method: 'set_quota',
|
|
params: ['mac', 'name', 'limit_mb', 'action', 'reset_day'],
|
|
expect: {}
|
|
});
|
|
|
|
var callResetQuota = rpc.declare({
|
|
object: 'luci.bandwidth-manager',
|
|
method: 'reset_quota',
|
|
params: ['mac'],
|
|
expect: {}
|
|
});
|
|
|
|
var callGetUsageRealtime = rpc.declare({
|
|
object: 'luci.bandwidth-manager',
|
|
method: 'get_usage_realtime',
|
|
expect: { clients: [] }
|
|
});
|
|
|
|
var callGetUsageHistory = rpc.declare({
|
|
object: 'luci.bandwidth-manager',
|
|
method: 'get_usage_history',
|
|
params: ['timeframe', 'mac'],
|
|
expect: { history: [] }
|
|
});
|
|
|
|
return {
|
|
getStatus: callStatus,
|
|
listRules: callListRules,
|
|
addRule: callAddRule,
|
|
deleteRule: callDeleteRule,
|
|
listQuotas: callListQuotas,
|
|
getQuota: callGetQuota,
|
|
setQuota: callSetQuota,
|
|
resetQuota: callResetQuota,
|
|
getUsageRealtime: callGetUsageRealtime,
|
|
getUsageHistory: callGetUsageHistory
|
|
};
|