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>
80 lines
2.1 KiB
JavaScript
80 lines
2.1 KiB
JavaScript
'use strict';
|
|
'require view';
|
|
'require ui';
|
|
'require form';
|
|
'require bandwidth-manager/api as API';
|
|
|
|
return L.view.extend({
|
|
load: function() {
|
|
return API.listRules();
|
|
},
|
|
|
|
render: function(rules) {
|
|
var m = new form.Map('bandwidth', _('QoS Rules'),
|
|
_('Define traffic shaping rules based on applications, ports, or IP addresses'));
|
|
|
|
var s = m.section(form.GridSection, 'rule', _('Rules'));
|
|
s.anonymous = false;
|
|
s.addremove = true;
|
|
s.sortable = true;
|
|
|
|
s.modaltitle = function(section_id) {
|
|
return _('Edit Rule: ') + section_id;
|
|
};
|
|
|
|
var o;
|
|
|
|
o = s.option(form.Value, 'name', _('Rule Name'));
|
|
o.rmempty = false;
|
|
o.placeholder = 'Limit YouTube';
|
|
|
|
o = s.option(form.ListValue, 'type', _('Type'));
|
|
o.value('application', _('Application'));
|
|
o.value('port', _('Port'));
|
|
o.value('ip', _('IP Address'));
|
|
o.value('mac', _('MAC Address'));
|
|
o.default = 'application';
|
|
|
|
o = s.option(form.Value, 'target', _('Target'));
|
|
o.rmempty = false;
|
|
o.placeholder = 'youtube / 80,443 / 192.168.1.100 / AA:BB:CC:DD:EE:FF';
|
|
o.description = _('Application name, port(s), IP address, or MAC address');
|
|
|
|
o = s.option(form.Value, 'limit_down', _('Download Limit (kbit/s)'));
|
|
o.datatype = 'uinteger';
|
|
o.placeholder = '5000';
|
|
o.description = _('Maximum download speed in kbit/s (0 = unlimited)');
|
|
o.default = '0';
|
|
|
|
o = s.option(form.Value, 'limit_up', _('Upload Limit (kbit/s)'));
|
|
o.datatype = 'uinteger';
|
|
o.placeholder = '1000';
|
|
o.description = _('Maximum upload speed in kbit/s (0 = unlimited)');
|
|
o.default = '0';
|
|
|
|
o = s.option(form.ListValue, 'priority', _('Priority'));
|
|
o.value('1', '1 (Highest)');
|
|
o.value('2', '2 (High)');
|
|
o.value('3', '3');
|
|
o.value('4', '4');
|
|
o.value('5', '5 (Normal)');
|
|
o.value('6', '6');
|
|
o.value('7', '7 (Low)');
|
|
o.value('8', '8 (Lowest)');
|
|
o.default = '5';
|
|
|
|
o = s.option(form.Value, 'schedule', _('Schedule (Optional)'));
|
|
o.placeholder = 'Mon-Fri 08:00-18:00';
|
|
o.description = _('Apply rule only during specific times');
|
|
|
|
o = s.option(form.Flag, 'enabled', _('Enabled'));
|
|
o.default = o.enabled;
|
|
|
|
return m.render();
|
|
},
|
|
|
|
handleSaveApply: null,
|
|
handleSave: null,
|
|
handleReset: null
|
|
});
|