8 'require tools.widgets as widgets';
13 async
function handleAction(ev
) {
15 L
.ui
.showModal(_('Refresh Timer'), [
16 E('p', _('To keep your banIP lists up-to-date, you should setup an automatic update job for these lists.')),
17 E('div', { 'class': 'left', 'style': 'display:flex; flex-direction:column' }, [
18 E('h5', _('Existing job(s)')),
21 'style': 'width: 100% !important; padding: 5px; font-family: monospace',
22 'readonly': 'readonly',
27 E('div', { 'class': 'left', 'style': 'display:flex; flex-direction:column' }, [
28 E('label', { 'class': 'cbi-input-select', 'style': 'padding-top:.5em' }, [
29 E('h5', _('Set a new banIP job')),
30 E('select', { 'class': 'cbi-input-select', 'id': 'timerA' }, [
31 E('option', { 'value': 'start' }, 'Start'),
32 E('option', { 'value': 'reload' }, 'Reload'),
33 E('option', { 'value': 'restart' }, 'Restart'),
34 E('option', { 'value': 'refresh' }, 'Refresh'),
35 E('option', { 'value': 'suspend' }, 'Suspend'),
36 E('option', { 'value': 'resume' }, 'Resume'),
37 E('option', { 'value': 'report gen' }, 'Report'),
38 E('option', { 'value': 'report mail' }, 'Report & Mail')
43 E('label', { 'class': 'cbi-input-text', 'style': 'padding-top:.5em' }, [
44 E('input', { 'class': 'cbi-input-text', 'id': 'timerH', 'maxlength': '2' }, [
47 _('The hours portition (req., range: 0-23)')
49 E('label', { 'class': 'cbi-input-text', 'style': 'padding-top:.5em' }, [
50 E('input', { 'class': 'cbi-input-text', 'id': 'timerM', 'maxlength': '2' }),
52 _('The minutes portion (opt., range: 0-59)')
54 E('label', { 'class': 'cbi-input-text', 'style': 'padding-top:.5em' }, [
55 E('input', { 'class': 'cbi-input-text', 'id': 'timerD', 'maxlength': '13' }),
57 _('The day of the week (opt., values: 1-7 possibly sep. by , or -)')
60 E('div', { 'class': 'left', 'style': 'display:flex; flex-direction:column' }, [
61 E('label', { 'class': 'cbi-input-select', 'style': 'padding-top:.5em' }, [
62 E('h5', _('Remove an existing job')),
63 E('input', { 'class': 'cbi-input-text', 'id': 'lineno', 'maxlength': '2' }, [
66 _('Line number to remove')
69 E('div', { 'class': 'right' }, [
76 'class': 'btn cbi-button-action',
77 'click': ui
.createHandlerFn(this, function(ev
) {
78 var lineno
= document
.getElementById('lineno').value
;
79 var action
= document
.getElementById('timerA').value
;
80 var hours
= document
.getElementById('timerH').value
;
81 var minutes
= document
.getElementById('timerM').value
|| '0';
82 var days
= document
.getElementById('timerD').value
|| '*';
84 L
.resolveDefault(fs
.exec_direct('/etc/init.d/banip', ['timer', 'add', action
, hours
, minutes
, days
]))
87 ui
.addNotification(null, E('p', _('The Refresh Timer could not been updated.')), 'error');
89 ui
.addNotification(null, E('p', _('The Refresh Timer has been updated.')), 'info');
93 L
.resolveDefault(fs
.exec_direct('/etc/init.d/banip', ['timer', 'remove', lineno
]))
96 ui
.addNotification(null, E('p', _('The Refresh Timer could not been updated.')), 'error');
98 ui
.addNotification(null, E('p', _('The Refresh Timer has been updated.')), 'info');
102 document
.getElementById('timerH').focus();
110 L
.resolveDefault(fs
.exec_direct('/etc/init.d/banip', ['timer', 'list']))
111 .then(function(res
) {
112 document
.getElementById('cronView').value
= res
.trim();
114 document
.getElementById('timerH').focus();
118 if (document
.getElementById('status') && document
.getElementById('btn_suspend')) {
119 if (document
.getElementById('status').textContent
.substr(0,6) === 'paused') {
125 fs
.exec_direct('/etc/init.d/banip', [ev
])
127 while (running
=== 1) {
128 await
new Promise(r
=> setTimeout(r
, 1000));
129 L
.resolveDefault(fs
.read_direct('/var/run/banip.pid')).then(function(res
) {
132 if (document
.getElementById('status') && document
.getElementById('btn_suspend')) {
133 if (document
.getElementById('status').textContent
.substr(0,7) === 'enabled') {
134 document
.querySelector('#btn_suspend').textContent
= 'Suspend';
146 L
.resolveDefault(fs
.exec_direct('/etc/init.d/banip', ['list']), {}),
147 L
.resolveDefault(fs
.exec_direct('/usr/sbin/iptables', ['-L']), null),
148 L
.resolveDefault(fs
.exec_direct('/usr/sbin/ip6tables', ['-L']), null),
149 L
.resolveDefault(fs
.read_direct('/etc/banip/banip.countries'), ''),
154 render: function(result
) {
157 m
= new form
.Map('banip', 'banIP', _('Configuration of the banIP package to block ip adresses/subnets via IPSet. \
158 For further information <a href="https://github.com/openwrt/packages/blob/master/net/banip/files/README.md" target="_blank" rel="noreferrer noopener" >check the online documentation</a>'));
161 poll runtime information
163 var rt_res
, inf_stat
, inf_ipsets
, inf_sources
, inf_srcarr
, inf_devices
, inf_devarr
, inf_ifaces
, inf_ifarr
, inf_logterms
, inf_logtarr
164 var inf_subnets
, inf_subnarr
, inf_misc
, inf_flags
, inf_run
166 pollData
: poll
.add(function() {
167 return L
.resolveDefault(fs
.read_direct('/tmp/ban_runtime.json'), 'null').then(function(res
) {
168 rt_res
= JSON
.parse(res
);
169 inf_stat
= document
.getElementById('status');
170 if (inf_stat
&& rt_res
) {
171 inf_stat
.textContent
= (rt_res
.status
|| '-') + ' / ' + (rt_res
.version
|| '-');
172 if (rt_res
.status
=== "running") {
173 if (!inf_stat
.classList
.contains("spinning")) {
174 inf_stat
.classList
.add("spinning");
177 if (inf_stat
.classList
.contains("spinning")) {
178 inf_stat
.classList
.remove("spinning");
182 if (inf_stat
.textContent
.substr(0,6) === 'paused' && document
.getElementById('btn_suspend')) {
183 document
.querySelector('#btn_suspend').textContent
= 'Resume';
185 } else if (inf_stat
) {
186 inf_stat
.textContent
= '-';
187 if (inf_stat
.classList
.contains("spinning")) {
188 inf_stat
.classList
.remove("spinning");
191 inf_ipsets
= document
.getElementById('ipsets');
192 if (inf_ipsets
&& rt_res
) {
193 inf_ipsets
.textContent
= rt_res
.ipset_info
|| '-';
195 inf_sources
= document
.getElementById('sources');
197 if (inf_sources
&& rt_res
) {
198 for (var i
= 0; i
< rt_res
.active_sources
.length
; i
++) {
199 if (i
< rt_res
.active_sources
.length
-1) {
200 inf_srcarr
+= rt_res
.active_sources
[i
].source
+ ', ';
202 inf_srcarr
+= rt_res
.active_sources
[i
].source
205 inf_sources
.textContent
= inf_srcarr
|| '-';
207 inf_devices
= document
.getElementById('devices');
209 if (inf_devices
&& rt_res
) {
210 for (var i
= 0; i
< rt_res
.active_devs
.length
; i
++) {
211 if (i
< rt_res
.active_devs
.length
-1) {
212 inf_devarr
+= rt_res
.active_devs
[i
].dev
+ ', ';
214 inf_devarr
+= rt_res
.active_devs
[i
].dev
217 inf_devices
.textContent
= inf_devarr
|| '-';
219 inf_ifaces
= document
.getElementById('ifaces');
221 if (inf_ifaces
&& rt_res
) {
222 for (var i
= 0; i
< rt_res
.active_ifaces
.length
; i
++) {
223 if (i
< rt_res
.active_ifaces
.length
-1) {
224 inf_ifarr
+= rt_res
.active_ifaces
[i
].iface
+ ', ';
226 inf_ifarr
+= rt_res
.active_ifaces
[i
].iface
229 inf_ifaces
.textContent
= inf_ifarr
|| '-';
231 inf_logterms
= document
.getElementById('logterms');
233 if (inf_logterms
&& rt_res
) {
234 for (var i
= 0; i
< rt_res
.active_logterms
.length
; i
++) {
235 if (i
< rt_res
.active_logterms
.length
-1) {
236 inf_logtarr
+= rt_res
.active_logterms
[i
].term
+ ', ';
238 inf_logtarr
+= rt_res
.active_logterms
[i
].term
241 inf_logterms
.textContent
= inf_logtarr
|| '-';
243 inf_subnets
= document
.getElementById('subnets');
245 if (inf_subnets
&& rt_res
) {
246 for (var i
= 0; i
< rt_res
.active_subnets
.length
; i
++) {
247 if (i
< rt_res
.active_subnets
.length
-1) {
248 inf_subnarr
+= rt_res
.active_subnets
[i
].subnet
+ ', ';
250 inf_subnarr
+= rt_res
.active_subnets
[i
].subnet
253 inf_subnets
.textContent
= inf_subnarr
|| '-';
255 inf_misc
= document
.getElementById('infos');
256 if (inf_misc
&& rt_res
) {
257 inf_misc
.textContent
= rt_res
.run_infos
|| '-';
259 inf_flags
= document
.getElementById('flags');
260 if (inf_flags
&& rt_res
) {
261 inf_flags
.textContent
= rt_res
.run_flags
|| '-';
263 inf_run
= document
.getElementById('run');
264 if (inf_run
&& rt_res
) {
265 inf_run
.textContent
= rt_res
.last_run
|| '-';
271 runtime information and buttons
273 s
= m
.section(form
.NamedSection
, 'global');
274 s
.render
= L
.bind(function(view
, section_id
) {
275 return E('div', { 'class': 'cbi-section' }, [
276 E('h3', _('Information')),
277 E('div', { 'class': 'cbi-value' }, [
278 E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Status / Version')),
279 E('div', { 'class': 'cbi-value-field spinning', 'id': 'status', 'style': 'color:#37c' },'\xa0')
281 E('div', { 'class': 'cbi-value' }, [
282 E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('IPSet Information')),
283 E('div', { 'class': 'cbi-value-field', 'id': 'ipsets', 'style': 'color:#37c' },'-')
285 E('div', { 'class': 'cbi-value' }, [
286 E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Active Sources')),
287 E('div', { 'class': 'cbi-value-field', 'id': 'sources', 'style': 'color:#37c' },'-')
289 E('div', { 'class': 'cbi-value' }, [
290 E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Active Devices')),
291 E('div', { 'class': 'cbi-value-field', 'id': 'devices', 'style': 'color:#37c' },'-')
293 E('div', { 'class': 'cbi-value' }, [
294 E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Active Interfaces')),
295 E('div', { 'class': 'cbi-value-field', 'id': 'ifaces', 'style': 'color:#37c' },'-')
297 E('div', { 'class': 'cbi-value' }, [
298 E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Active Logterms')),
299 E('div', { 'class': 'cbi-value-field', 'id': 'logterms', 'style': 'color:#37c' },'-')
301 E('div', { 'class': 'cbi-value' }, [
302 E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Active Subnets')),
303 E('div', { 'class': 'cbi-value-field', 'id': 'subnets', 'style': 'color:#37c' },'-')
305 E('div', { 'class': 'cbi-value' }, [
306 E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Run Information')),
307 E('div', { 'class': 'cbi-value-field', 'id': 'infos', 'style': 'color:#37c' },'-')
309 E('div', { 'class': 'cbi-value' }, [
310 E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Run Flags')),
311 E('div', { 'class': 'cbi-value-field', 'id': 'flags', 'style': 'color:#37c' },'-')
313 E('div', { 'class': 'cbi-value' }, [
314 E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Last Run')),
315 E('div', { 'class': 'cbi-value-field', 'id': 'run', 'style': 'color:#37c' },'-')
317 E('div', { class: 'right' }, [
319 'class': 'cbi-button cbi-button-apply',
320 'click': ui
.createHandlerFn(this, function() {
321 return handleAction('timer');
323 }, [ _('Refresh Timer...') ]),
326 'class': 'cbi-button cbi-button-apply',
328 'click': ui
.createHandlerFn(this, function() {
329 return handleAction('suspend');
331 }, [ _('Suspend') ]),
334 'class': 'cbi-button cbi-button-positive',
335 'click': ui
.createHandlerFn(this, function() {
336 return handleAction('refresh');
338 }, [ _('Refresh') ]),
341 'class': 'cbi-button cbi-button-negative',
342 'click': ui
.createHandlerFn(this, function() {
343 return handleAction('restart');
352 tabbed config section
354 s
= m
.section(form
.NamedSection
, 'global', 'banip', _('Settings'));
356 s
.tab('general', _('General Settings'));
357 s
.tab('additional', _('Additional Settings'));
358 s
.tab('adv_chain', _('Advanced Chain Settings'));
359 s
.tab('adv_log', _('Advanced Log Settings'));
360 s
.tab('adv_email', _('Advanced E-Mail Settings'));
361 s
.tab('sources', _('Blocklist Sources'));
366 o
= s
.taboption('general', form
.Flag
, 'ban_enabled', _('Enabled'), _('Enable the banIP service.'));
369 o
= s
.taboption('general', widgets
.NetworkSelect
, 'ban_trigger', _('Startup Trigger Interface'), _('List of available network interfaces to trigger the banIP start.'));
370 o
.unspecified
= true;
374 o
= s
.taboption('general', form
.Flag
, 'ban_autodetect', _('Auto Detection'), _('Detect relevant network interfaces, devices, subnets and protocols automatically.'));
377 o
= s
.taboption('general', widgets
.NetworkSelect
, 'ban_ifaces', _('Network Interfaces'), _('Select the relevant network interfaces manually.'));
378 o
.depends('ban_autodetect', '0');
379 o
.unspecified
= true;
385 o
= s
.taboption('general', form
.Flag
, 'ban_proto4_enabled', _('IPv4 Support'), _('Enables IPv4 support in banIP.'));
386 o
.depends('ban_autodetect', '0');
390 o
= s
.taboption('general', form
.Flag
, 'ban_proto6_enabled', _('IPv6 Support'), _('Enables IPv6 support in banIP.'));
391 o
.depends('ban_autodetect', '0');
395 o
= s
.taboption('general', form
.Flag
, 'ban_monitor_enabled', _('Log Monitor'), _('Starts a small log monitor in the background to block suspicious SSH/LuCI login attempts.'));
398 o
= s
.taboption('general', form
.Flag
, 'ban_logsrc_enabled', _('Enable SRC logging'), _('Log suspicious incoming packets - usually dropped.'));
401 o
= s
.taboption('general', form
.Flag
, 'ban_logdst_enabled', _('Enable DST logging'), _('Log suspicious outgoing packets - usually rejected. \
402 Logging such packets may cause an increase in latency due to it requiring additional system resources.'));
405 o
= s
.taboption('general', form
.Flag
, 'ban_mail_enabled', _('E-Mail Notification'), _('Send banIP related notification e-mails. \
406 This needs the installation and setup of the additional \'msmtp\' package.'));
409 o
= s
.taboption('general', form
.Value
, 'ban_mailreceiver', _('E-Mail Receiver Address'), _('Receiver address for banIP notification e-mails.'));
410 o
.depends('ban_mail_enabled', '1');
411 o
.placeholder
= 'name@example.com';
415 additional settings tab
417 o
= s
.taboption('additional', form
.Flag
, 'ban_debug', _('Verbose Debug Logging'), _('Enable verbose debug logging in case of any processing errors.'));
420 o
= s
.taboption('additional', form
.ListValue
, 'ban_nice', _('Service Priority'), _('The selected priority will be used for banIP background processing. \
421 This change requires a full banIP service restart to take effect.'));
422 o
.value('-20', _('Highest Priority'));
423 o
.value('-10', _('High Priority'));
424 o
.value('0', _('Normal Priority (default)'));
425 o
.value('10', _('Less Priority'));
426 o
.value('19', _('Least Priority'));
430 o
= s
.taboption('additional', form
.Value
, 'ban_triggerdelay', _('Trigger Delay'), _('Additional trigger delay in seconds before banIP processing begins.'));
432 o
.datatype
= 'range(1,120)';
435 o
= s
.taboption('additional', form
.ListValue
, 'ban_maxqueue', _('Download Queue'), _('Size of the download queue for download processing in parallel.'));
445 o
= s
.taboption('additional', form
.Value
, 'ban_tmpbase', _('Base Temp Directory'), _('Base Temp Directory used for all banIP related runtime operations.'));
446 o
.placeholder
= '/tmp';
449 o
= s
.taboption('additional', form
.Value
, 'ban_backupdir', _('Backup Directory'), _('Target directory for compressed source list backups.'));
450 o
.placeholder
= '/tmp/banIP-Backup';
453 o
= s
.taboption('additional', form
.Value
, 'ban_reportdir', _('Report Directory'), _('Target directory for IPSet related report files.'));
454 o
.placeholder
= '/tmp/banIP-Report';
457 o
= s
.taboption('additional', form
.ListValue
, 'ban_fetchutil', _('Download Utility'), _('List of supported and fully pre-configured download utilities.'));
458 o
.value('uclient-fetch');
465 o
= s
.taboption('additional', form
.Value
, 'ban_fetchparm', _('Download Parameters'), _('Special config options for the selected download utility.'))
469 advanced chain settings tab
471 o
= s
.taboption('adv_chain', form
.DummyValue
, '_sub');
473 o
.default = '<em><b>Changes on this tab needs a full banIP service restart to take effect.</b></em>';
475 o
= s
.taboption('adv_chain', form
.ListValue
, 'ban_global_settype', _('Global IPSet Type'), _('Set the global IPset type default, to block incoming (SRC) and/or outgoing (DST) packets.'));
481 o
= s
.taboption('adv_chain', form
.ListValue
, 'ban_target_src', _('SRC Target'), _('Set the firewall target for all SRC related rules.'));
486 o
= s
.taboption('adv_chain', form
.ListValue
, 'ban_target_dst', _('DST Target'), _('Set the firewall target for all DST related rules.'));
491 o
= s
.taboption('adv_chain', form
.DummyValue
, '_sub');
493 o
.default = '<em><b>Individual IPSet Types</b></em>';
498 var info
, source
, sources
= [];
500 sources
= result
[0].trim().split('\n');
503 o
= s
.taboption('adv_chain', form
.MultiValue
, 'ban_settype_src', _('SRC IPSet Type'), _('Set individual SRC type per IPset to block only incoming packets.'));
504 for (var i
= 0; i
< sources
.length
; i
++) {
505 if (sources
[i
].match(/^\s+\+/)) {
506 source
= sources
[i
].match(/^\s+\+\s(\w+)\s/)[1].trim();
513 o
= s
.taboption('adv_chain', form
.MultiValue
, 'ban_settype_dst', _('DST IPSet Type'), _('Set individual DST type per IPset to block only outgoing packets.'));
514 for (var i
= 0; i
< sources
.length
; i
++) {
515 if (sources
[i
].match(/^\s+\+/)) {
516 source
= sources
[i
].match(/^\s+\+\s(\w+)\s/)[1].trim();
523 o
= s
.taboption('adv_chain', form
.MultiValue
, 'ban_settype_all', _('SRC+DST IPSet Type'), _('Set individual SRC+DST type per IPset to block incoming and outgoing packets.'));
524 for (var i
= 0; i
< sources
.length
; i
++) {
525 if (sources
[i
].match(/^\s+\+/)) {
526 source
= sources
[i
].match(/^\s+\+\s(\w+)\s/)[1].trim();
533 o
= s
.taboption('adv_chain', form
.DummyValue
, '_sub');
535 o
.default = '<em><b>IPv4 Chains</b></em>';
538 prepare iptables data
540 var chain
, result_v4
=[], result_v6
=[];
542 result_v4
= result
[1].trim().split('\n');
543 } else if (result
[2]) {
544 result_v4
= result
[2].trim().split('\n');
548 result_v6
= result
[2].trim().split('\n');
549 } else if (result
[1]) {
550 result_v6
= result
[1].trim().split('\n');
553 o
= s
.taboption('adv_chain', form
.DynamicList
, 'ban_lan_inputchains_4', _('LAN Input'), _('Default chain used by banIP is \'input_lan_rule\''));
554 for (var i
= 0; i
< result_v4
.length
; i
++) {
555 if (result_v4
[i
].match(/^Chain input[\w_]+\s+/)) {
556 chain
= result_v4
[i
].match(/\s+(input[\w_]+)\s+/)[1].trim();
560 o
.datatype
= 'uciname';
564 o
= s
.taboption('adv_chain', form
.DynamicList
, 'ban_lan_forwardchains_4', _('LAN Forward'), _('Default chain used by banIP is \'forwarding_lan_rule\''));
565 for (var i
= 0; i
< result_v4
.length
; i
++) {
566 if (result_v4
[i
].match(/^Chain forwarding[\w_]+\s+/)) {
567 chain
= result_v4
[i
].match(/\s+(forwarding[\w_]+)\s+/)[1].trim();
571 o
.datatype
= 'uciname';
575 o
= s
.taboption('adv_chain', form
.DynamicList
, 'ban_wan_inputchains_4', _('WAN Input'), _('Default chain used by banIP is \'input_wan_rule\''));
576 for (var i
= 0; i
< result_v4
.length
; i
++) {
577 if (result_v4
[i
].match(/^Chain input[\w_]+\s+/)) {
578 chain
= result_v4
[i
].match(/\s+(input[\w_]+)\s+/)[1].trim();
582 o
.datatype
= 'uciname';
586 o
= s
.taboption('adv_chain', form
.DynamicList
, 'ban_wan_forwardchains_4', _('WAN Forward'), _('Default chain used by banIP is \'forwarding_wan_rule\''));
587 for (var i
= 0; i
< result_v4
.length
; i
++) {
588 if (result_v4
[i
].match(/^Chain forwarding[\w_]+\s+/)) {
589 chain
= result_v4
[i
].match(/\s+(forwarding[\w_]+)\s+/)[1].trim();
593 o
.datatype
= 'uciname';
597 o
= s
.taboption('adv_chain', form
.DummyValue
, '_sub');
599 o
.default = '<em><b>IPv6 Chains</b></em>';
601 o
= s
.taboption('adv_chain', form
.DynamicList
, 'ban_lan_inputchains_6', _('LAN Input'), _('Default chain used by banIP is \'input_lan_rule\''));
602 for (var i
= 0; i
< result_v6
.length
; i
++) {
603 if (result_v6
[i
].match(/^Chain input[\w_]+\s+/)) {
604 chain
= result_v6
[i
].match(/\s+(input[\w_]+)\s+/)[1].trim();
608 o
.datatype
= 'uciname';
612 o
= s
.taboption('adv_chain', form
.DynamicList
, 'ban_lan_forwardchains_6', _('LAN Forward'), _('Default chain used by banIP is \'forwarding_lan_rule\''));
613 for (var i
= 0; i
< result_v6
.length
; i
++) {
614 if (result_v6
[i
].match(/^Chain forwarding[\w_]+\s+/)) {
615 chain
= result_v6
[i
].match(/\s+(forwarding[\w_]+)\s+/)[1].trim();
619 o
.datatype
= 'uciname';
623 o
= s
.taboption('adv_chain', form
.DynamicList
, 'ban_wan_inputchains_6', _('WAN Input'), _('Default chain used by banIP is \'input_wan_rule\''));
624 for (var i
= 0; i
< result_v6
.length
; i
++) {
625 if (result_v6
[i
].match(/^Chain input[\w_]+\s+/)) {
626 chain
= result_v6
[i
].match(/\s+(input[\w_]+)\s+/)[1].trim();
630 o
.datatype
= 'uciname';
634 o
= s
.taboption('adv_chain', form
.DynamicList
, 'ban_wan_forwardchains_6', _('WAN Forward'), _('Default chain used by banIP is \'forwarding_wan_rule\''));
635 for (var i
= 0; i
< result_v6
.length
; i
++) {
636 if (result_v6
[i
].match(/^Chain forwarding[\w_]+\s+/)) {
637 chain
= result_v6
[i
].match(/\s+(forwarding[\w_]+)\s+/)[1].trim();
641 o
.datatype
= 'uciname';
646 advanced log settings tab
648 o
= s
.taboption('adv_log', form
.DummyValue
, '_sub');
650 o
.default = '<em><b>Changes on this tab needs a full banIP service restart to take effect.</b></em>';
652 o
= s
.taboption('adv_log', form
.ListValue
, 'ban_loglimit', _('Log Limit'), _('Parse only the last stated number of log entries for suspicious events.'));
659 o
= s
.taboption('adv_log', form
.MultiValue
, 'ban_logterms', _('Log Terms'), _('Limit the log monitor to certain log terms.'));
666 o
= s
.taboption('adv_log', form
.Value
, 'ban_logopts_src', _('SRC Log Options'), _('Set special SRC log options, e.g. to set a limit rate.'));
668 o
.unspecified
= true;
669 o
.value('-m limit --limit 2/sec', _('-m limit --limit 2/sec (default)'));
670 o
.value('-m limit --limit 10/sec');
674 o
= s
.taboption('adv_log', form
.Value
, 'ban_logopts_dst', _('DST Log Options'), _('Set special DST log options, e.g. to set a limit rate.'));
676 o
.unspecified
= true;
677 o
.value('-m limit --limit 2/sec', _('-m limit --limit 2/sec (default)'));
678 o
.value('-m limit --limit 10/sec');
683 advanced email settings tab
685 o
= s
.taboption('adv_email', form
.Value
, 'ban_mailsender', _('E-Mail Sender Address'), _('Sender address for banIP notification E-Mails.'));
686 o
.placeholder
= 'no-reply@banIP';
689 o
= s
.taboption('adv_email', form
.Value
, 'ban_mailtopic', _('E-Mail Topic'), _('Topic for banIP notification E-Mails.'));
690 o
.placeholder
= 'banIP notification';
693 o
= s
.taboption('adv_email', form
.Value
, 'ban_mailprofile', _('E-Mail Profile'), _('Profile used by \'msmtp\' for banIP notification E-Mails.'));
694 o
.placeholder
= 'ban_notify';
695 o
.datatype
= 'uciname';
698 o
= s
.taboption('adv_email', form
.MultiValue
, 'ban_mailactions', _('E-Mail Actions'), _('Limit E-Mail trigger to certain banIP actions.'));
706 blocklist sources tab
708 o
= s
.taboption('sources', form
.DummyValue
, '_sub');
710 o
.default = '<em><b>List of supported and fully pre-configured banIP sources.</b></em>';
712 o
= s
.taboption('sources', form
.MultiValue
, 'ban_sources', _('Sources (Info)'));
713 for (var i
= 0; i
< sources
.length
; i
++) {
714 if (sources
[i
].match(/^\s+\+/)) {
715 source
= sources
[i
].match(/^\s+\+\s(\w+)\s/)[1].trim();
716 info
= sources
[i
].slice(35,70).trim();
717 o
.value(source
, source
+ ' (' + info
+ ')');
723 o
= s
.taboption('sources', form
.DummyValue
, '_sub');
725 o
.default = '<em><b>Country selection</b></em>';
730 var code
, country
, countries
= [];
732 countries
= result
[3].trim().split('\n');
735 o
= s
.taboption('sources', form
.DynamicList
, 'ban_countries', _('Countries'));
736 for (var i
= 0; i
< countries
.length
; i
++) {
737 code
= countries
[i
].match(/^(\w+);/)[1].trim();
738 country
= countries
[i
].match(/^\w+;(.*$)/)[1].trim();
739 o
.value(code
, country
);
744 o
= s
.taboption('sources', form
.DummyValue
, '_sub');
746 o
.default = '<em><b>ASN selection</b></em>';
748 o
= s
.taboption('sources', form
.DynamicList
, 'ban_asns', _('ASNs'));
749 o
.datatype
= 'uinteger';
753 o
= s
.taboption('sources', form
.DummyValue
, '_sub');
755 o
.default = '<em><b>Local Sources</b></em>';
757 o
= s
.taboption('sources', form
.Flag
, 'ban_autoblacklist', _('Auto Blacklist'), _('Automatically transfers suspicious IPs from the log to the banIP blacklist during runtime.'));
760 o
= s
.taboption('sources', form
.Flag
, 'ban_autowhitelist', _('Auto Whitelist'), _('Automatically transfers uplink IPs to the banIP whitelist during runtime.'));