- Add catch() handler for getInterfaces() API call - Provide fallback interface list if API returns null - Bump release to r2 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
166 lines
5.0 KiB
JavaScript
166 lines
5.0 KiB
JavaScript
'use strict';
|
|
'require view';
|
|
'require form';
|
|
'require uci';
|
|
'require ui';
|
|
'require ndpid.api as api';
|
|
|
|
return view.extend({
|
|
title: _('nDPId Settings'),
|
|
|
|
load: function() {
|
|
return Promise.all([
|
|
uci.load('ndpid'),
|
|
api.getInterfaces().catch(function() { return {}; })
|
|
]);
|
|
},
|
|
|
|
render: function(data) {
|
|
var interfaces = data[1] || {};
|
|
var available = (interfaces && interfaces.available) ? interfaces.available : ['br-lan', 'eth0', 'eth1', 'wlan0'];
|
|
|
|
var m, s, o;
|
|
|
|
m = new form.Map('ndpid', _('nDPId Configuration'),
|
|
_('Configure the nDPId deep packet inspection daemon.'));
|
|
|
|
// Main Settings
|
|
s = m.section(form.TypedSection, 'ndpid', _('Service Settings'));
|
|
s.anonymous = true;
|
|
|
|
o = s.option(form.Flag, 'enabled', _('Enable nDPId'),
|
|
_('Start nDPId service on boot'));
|
|
o.default = '0';
|
|
o.rmempty = false;
|
|
|
|
o = s.option(form.MultiValue, 'interface', _('Monitored Interfaces'),
|
|
_('Select network interfaces to monitor for traffic'));
|
|
available.forEach(function(iface) {
|
|
o.value(iface, iface);
|
|
});
|
|
o.default = 'br-lan';
|
|
|
|
o = s.option(form.Value, 'max_flows', _('Maximum Flows'),
|
|
_('Maximum number of concurrent flows to track'));
|
|
o.datatype = 'uinteger';
|
|
o.default = '100000';
|
|
o.placeholder = '100000';
|
|
|
|
o = s.option(form.Value, 'collector_socket', _('Collector Socket'),
|
|
_('Path to the collector socket'));
|
|
o.default = '/var/run/ndpid/collector.sock';
|
|
o.placeholder = '/var/run/ndpid/collector.sock';
|
|
|
|
o = s.option(form.Value, 'flow_idle_timeout', _('Flow Idle Timeout (ms)'),
|
|
_('Time before idle flows are expired'));
|
|
o.datatype = 'uinteger';
|
|
o.default = '600000';
|
|
o.placeholder = '600000';
|
|
|
|
o = s.option(form.Value, 'tcp_timeout', _('TCP Timeout (ms)'),
|
|
_('Timeout for TCP connections'));
|
|
o.datatype = 'uinteger';
|
|
o.default = '7200000';
|
|
o.placeholder = '7200000';
|
|
|
|
o = s.option(form.Value, 'udp_timeout', _('UDP Timeout (ms)'),
|
|
_('Timeout for UDP flows'));
|
|
o.datatype = 'uinteger';
|
|
o.default = '180000';
|
|
o.placeholder = '180000';
|
|
|
|
o = s.option(form.Flag, 'compression', _('Enable Compression'),
|
|
_('Compress data sent to distributor'));
|
|
o.default = '1';
|
|
|
|
// Distributor Settings
|
|
s = m.section(form.TypedSection, 'ndpisrvd', _('Distributor Settings'),
|
|
_('Configure the nDPIsrvd event distributor'));
|
|
s.anonymous = true;
|
|
|
|
o = s.option(form.Flag, 'enabled', _('Enable Distributor'),
|
|
_('Enable nDPIsrvd event distribution'));
|
|
o.default = '1';
|
|
o.rmempty = false;
|
|
|
|
o = s.option(form.Value, 'listen_socket', _('Listen Socket'),
|
|
_('Unix socket path for clients'));
|
|
o.default = '/var/run/ndpid/distributor.sock';
|
|
|
|
o = s.option(form.Value, 'tcp_port', _('TCP Port'),
|
|
_('TCP port for remote clients (0 to disable)'));
|
|
o.datatype = 'port';
|
|
o.default = '7000';
|
|
o.placeholder = '7000';
|
|
|
|
o = s.option(form.Value, 'tcp_address', _('TCP Address'),
|
|
_('Address to bind TCP listener'));
|
|
o.default = '127.0.0.1';
|
|
o.placeholder = '127.0.0.1';
|
|
|
|
o = s.option(form.Value, 'max_clients', _('Max Clients'),
|
|
_('Maximum number of connected clients'));
|
|
o.datatype = 'uinteger';
|
|
o.default = '10';
|
|
|
|
// Compatibility Layer
|
|
s = m.section(form.TypedSection, 'compat', _('Compatibility Layer'),
|
|
_('Netifyd-compatible output for existing consumers'));
|
|
s.anonymous = true;
|
|
|
|
o = s.option(form.Flag, 'enabled', _('Enable Compatibility'),
|
|
_('Generate Netifyd-compatible status files'));
|
|
o.default = '1';
|
|
o.rmempty = false;
|
|
|
|
o = s.option(form.Value, 'status_file', _('Status File'),
|
|
_('Path for Netifyd-compatible status.json'));
|
|
o.default = '/var/run/netifyd/status.json';
|
|
|
|
o = s.option(form.Value, 'update_interval', _('Update Interval'),
|
|
_('How often to update status file (seconds)'));
|
|
o.datatype = 'uinteger';
|
|
o.default = '1';
|
|
|
|
// Flow Actions
|
|
s = m.section(form.TypedSection, 'actions', _('Flow Actions'),
|
|
_('Automatic actions based on detected applications'));
|
|
s.anonymous = true;
|
|
|
|
o = s.option(form.Flag, 'enabled', _('Enable Flow Actions'),
|
|
_('Process flow events and update ipsets'));
|
|
o.default = '0';
|
|
o.rmempty = false;
|
|
|
|
o = s.option(form.Value, 'bittorrent_ipset', _('BitTorrent IPSet'),
|
|
_('IPSet for BitTorrent traffic'));
|
|
o.default = 'secubox-bittorrent';
|
|
o.depends('enabled', '1');
|
|
|
|
o = s.option(form.Value, 'bittorrent_timeout', _('BitTorrent Timeout'),
|
|
_('IPSet entry timeout in seconds'));
|
|
o.datatype = 'uinteger';
|
|
o.default = '900';
|
|
o.depends('enabled', '1');
|
|
|
|
o = s.option(form.Value, 'streaming_ipset', _('Streaming IPSet'),
|
|
_('IPSet for streaming services'));
|
|
o.default = 'secubox-streaming';
|
|
o.depends('enabled', '1');
|
|
|
|
o = s.option(form.Value, 'blocked_ipset', _('Blocked IPSet'),
|
|
_('IPSet for blocked applications'));
|
|
o.default = 'secubox-blocked';
|
|
o.depends('enabled', '1');
|
|
|
|
o = s.option(form.DynamicList, 'blocked_app', _('Blocked Applications'),
|
|
_('Applications to block'));
|
|
o.value('bittorrent', 'BitTorrent');
|
|
o.value('tor', 'Tor');
|
|
o.value('vpn_udp', 'VPN (UDP)');
|
|
o.depends('enabled', '1');
|
|
|
|
return m.render();
|
|
}
|
|
});
|