overview.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. 'use strict';
  2. 'require view';
  3. 'require poll';
  4. 'require fs';
  5. 'require ui';
  6. 'require uci';
  7. 'require form';
  8. 'require tools.widgets as widgets';
  9. /*
  10. button handling
  11. */
  12. function handleAction(ev) {
  13. if (ev === 'timer') {
  14. L.ui.showModal(_('Refresh Timer'), [
  15. E('p', _('To keep your adblock lists up-to-date, you should set up an automatic update job for these lists.')),
  16. E('div', { 'class': 'left', 'style': 'display:flex; flex-direction:column' }, [
  17. E('h5', _('Existing job(s)')),
  18. E('textarea', {
  19. 'id': 'cronView',
  20. 'style': 'width: 100% !important; padding: 5px; font-family: monospace',
  21. 'readonly': 'readonly',
  22. 'wrap': 'off',
  23. 'rows': 5
  24. })
  25. ]),
  26. E('div', { 'class': 'left', 'style': 'display:flex; flex-direction:column' }, [
  27. E('label', { 'class': 'cbi-input-select', 'style': 'padding-top:.5em' }, [
  28. E('h5', _('Set a new adblock job')),
  29. E('select', { 'class': 'cbi-input-select', 'id': 'timerA' }, [
  30. E('option', { 'value': 'start' }, 'Start'),
  31. E('option', { 'value': 'reload' }, 'Reload'),
  32. E('option', { 'value': 'restart' }, 'Restart'),
  33. E('option', { 'value': 'suspend' }, 'Suspend'),
  34. E('option', { 'value': 'resume' }, 'Resume'),
  35. E('option', { 'value': 'report gen' }, 'Report'),
  36. E('option', { 'value': 'report mail' }, 'Report & Mail')
  37. ]),
  38. '\xa0\xa0\xa0',
  39. _('Adblock action')
  40. ]),
  41. E('label', { 'class': 'cbi-input-text', 'style': 'padding-top:.5em' }, [
  42. E('input', { 'class': 'cbi-input-text', 'id': 'timerH', 'maxlength': '2' }, [
  43. ]),
  44. '\xa0\xa0\xa0',
  45. _('The hours portition (req., range: 0-23)')
  46. ]),
  47. E('label', { 'class': 'cbi-input-text', 'style': 'padding-top:.5em' }, [
  48. E('input', { 'class': 'cbi-input-text', 'id': 'timerM', 'maxlength': '2' }),
  49. '\xa0\xa0\xa0',
  50. _('The minutes portion (opt., range: 0-59)')
  51. ]),
  52. E('label', { 'class': 'cbi-input-text', 'style': 'padding-top:.5em' }, [
  53. E('input', { 'class': 'cbi-input-text', 'id': 'timerD', 'maxlength': '13' }),
  54. '\xa0\xa0\xa0',
  55. _('The day of the week (opt., values: 0-6 possibly sep. by , or -)')
  56. ])
  57. ]),
  58. E('div', { 'class': 'left', 'style': 'display:flex; flex-direction:column' }, [
  59. E('label', { 'class': 'cbi-input-select', 'style': 'padding-top:.5em' }, [
  60. E('h5', _('Remove an existing job')),
  61. E('input', { 'class': 'cbi-input-text', 'id': 'lineno', 'maxlength': '2' }, [
  62. ]),
  63. '\xa0\xa0\xa0',
  64. _('Line number to remove')
  65. ])
  66. ]),
  67. E('div', { 'class': 'right' }, [
  68. E('button', {
  69. 'class': 'btn cbi-button',
  70. 'click': L.hideModal
  71. }, _('Cancel')),
  72. ' ',
  73. E('button', {
  74. 'class': 'btn cbi-button-action',
  75. 'click': ui.createHandlerFn(this, function(ev) {
  76. var lineno = document.getElementById('lineno').value;
  77. var action = document.getElementById('timerA').value;
  78. var hours = document.getElementById('timerH').value;
  79. var minutes = document.getElementById('timerM').value || '0';
  80. var days = document.getElementById('timerD').value || '*';
  81. if (hours) {
  82. L.resolveDefault(fs.exec_direct('/etc/init.d/adblock', ['timer', 'add', action, hours, minutes, days]))
  83. .then(function(res) {
  84. if (res) {
  85. ui.addNotification(null, E('p', _('The Refresh Timer could not been updated.')), 'error');
  86. } else {
  87. ui.addNotification(null, E('p', _('The Refresh Timer has been updated.')), 'info');
  88. }
  89. });
  90. } else if (lineno) {
  91. L.resolveDefault(fs.exec_direct('/etc/init.d/adblock', ['timer', 'remove', lineno]))
  92. .then(function(res) {
  93. if (res) {
  94. ui.addNotification(null, E('p', _('The Refresh Timer could not been updated.')), 'error');
  95. } else {
  96. ui.addNotification(null, E('p', _('The Refresh Timer has been updated.')), 'info');
  97. }
  98. });
  99. } else {
  100. document.getElementById('timerH').focus();
  101. return
  102. }
  103. L.hideModal();
  104. })
  105. }, _('Save'))
  106. ])
  107. ]);
  108. L.resolveDefault(fs.exec_direct('/etc/init.d/adblock', ['timer', 'list']))
  109. .then(function(res) {
  110. document.getElementById('cronView').value = res.trim();
  111. });
  112. document.getElementById('timerH').focus();
  113. return
  114. }
  115. if (document.getElementById('status') && document.getElementById('status').textContent.substr(0,6) === 'paused') {
  116. ev = 'resume';
  117. }
  118. fs.exec_direct('/etc/init.d/adblock', [ev])
  119. }
  120. return view.extend({
  121. load: function() {
  122. return Promise.all([
  123. L.resolveDefault(fs.exec_direct('/etc/init.d/adblock', ['list']), {}),
  124. L.resolveDefault(fs.read_direct('/etc/adblock/adblock.categories'), ''),
  125. uci.load('adblock')
  126. ]);
  127. },
  128. render: function(result) {
  129. var m, s, o;
  130. m = new form.Map('adblock', 'Adblock', _('Configuration of the adblock package to block ad/abuse domains by using DNS. \
  131. For further information <a href="https://github.com/openwrt/packages/blob/master/net/adblock/files/README.md" target="_blank" rel="noreferrer noopener" >check the online documentation</a>'));
  132. /*
  133. poll runtime information
  134. */
  135. pollData: poll.add(function() {
  136. return L.resolveDefault(fs.read_direct('/tmp/adb_runtime.json'), 'null').then(function(res) {
  137. var info = JSON.parse(res);
  138. var status = document.getElementById('status');
  139. if (status && info) {
  140. status.textContent = (info.adblock_status || '-') + ' / ' + (info.adblock_version || '-');
  141. if (info.adblock_status === "running") {
  142. if (!status.classList.contains("spinning")) {
  143. status.classList.add("spinning");
  144. }
  145. } else {
  146. if (status.classList.contains("spinning")) {
  147. status.classList.remove("spinning");
  148. if (document.getElementById('btn_suspend')) {
  149. if (status.textContent.substr(0,6) === 'paused') {
  150. document.querySelector('#btn_suspend').textContent = 'Resume';
  151. }
  152. if (document.getElementById('status').textContent.substr(0,7) === 'enabled') {
  153. document.querySelector('#btn_suspend').textContent = 'Suspend';
  154. }
  155. }
  156. }
  157. }
  158. if (status.textContent.substr(0,6) === 'paused' && document.getElementById('btn_suspend')) {
  159. document.querySelector('#btn_suspend').textContent = 'Resume';
  160. }
  161. } else if (status) {
  162. status.textContent = '-';
  163. if (status.classList.contains("spinning")) {
  164. status.classList.remove("spinning");
  165. }
  166. }
  167. var domains = document.getElementById('domains');
  168. if (domains && info) {
  169. domains.textContent = parseInt(info.blocked_domains, 10).toLocaleString() || '-';
  170. }
  171. var sources = document.getElementById('sources');
  172. var src_array = [];
  173. if (sources && info) {
  174. for (var i = 0; i < info.active_sources.length; i++) {
  175. if (i < info.active_sources.length-1) {
  176. src_array += info.active_sources[i] + ', ';
  177. } else {
  178. src_array += info.active_sources[i]
  179. }
  180. }
  181. sources.textContent = src_array || '-';
  182. }
  183. var backend = document.getElementById('backend');
  184. if (backend && info) {
  185. backend.textContent = info.dns_backend || '-';
  186. }
  187. var utils = document.getElementById('utils');
  188. if (utils && info) {
  189. utils.textContent = info.run_utils || '-';
  190. }
  191. var ifaces = document.getElementById('ifaces');
  192. if (ifaces && info) {
  193. ifaces.textContent = info.run_ifaces || '-';
  194. }
  195. var dirs = document.getElementById('dirs');
  196. if (dirs && info) {
  197. dirs.textContent = info.run_directories || '-';
  198. }
  199. var flags = document.getElementById('flags');
  200. if (flags && info) {
  201. flags.textContent = info.run_flags || '-';
  202. }
  203. var run = document.getElementById('run');
  204. if (run && info) {
  205. run.textContent = info.last_run || '-';
  206. }
  207. });
  208. }, 1);
  209. /*
  210. runtime information and buttons
  211. */
  212. s = m.section(form.NamedSection, 'global');
  213. s.render = L.bind(function(view, section_id) {
  214. return E('div', { 'class': 'cbi-section' }, [
  215. E('h3', _('Information')),
  216. E('div', { 'class': 'cbi-value' }, [
  217. E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Status / Version')),
  218. E('div', { 'class': 'cbi-value-field spinning', 'id': 'status', 'style': 'color:#37c' },'\xa0')
  219. ]),
  220. E('div', { 'class': 'cbi-value' }, [
  221. E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Blocked Domains')),
  222. E('div', { 'class': 'cbi-value-field', 'id': 'domains', 'style': 'color:#37c' },'-')
  223. ]),
  224. E('div', { 'class': 'cbi-value' }, [
  225. E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Active Sources')),
  226. E('div', { 'class': 'cbi-value-field', 'id': 'sources', 'style': 'color:#37c' },'-')
  227. ]),
  228. E('div', { 'class': 'cbi-value' }, [
  229. E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('DNS Backend')),
  230. E('div', { 'class': 'cbi-value-field', 'id': 'backend', 'style': 'color:#37c' },'-')
  231. ]),
  232. E('div', { 'class': 'cbi-value' }, [
  233. E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Run Utils')),
  234. E('div', { 'class': 'cbi-value-field', 'id': 'utils', 'style': 'color:#37c' },'-')
  235. ]),
  236. E('div', { 'class': 'cbi-value' }, [
  237. E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Run Interfaces')),
  238. E('div', { 'class': 'cbi-value-field', 'id': 'ifaces', 'style': 'color:#37c' },'-')
  239. ]),
  240. E('div', { 'class': 'cbi-value' }, [
  241. E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Run Directories')),
  242. E('div', { 'class': 'cbi-value-field', 'id': 'dirs', 'style': 'color:#37c' },'-')
  243. ]),
  244. E('div', { 'class': 'cbi-value' }, [
  245. E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Run Flags')),
  246. E('div', { 'class': 'cbi-value-field', 'id': 'flags', 'style': 'color:#37c' },'-')
  247. ]),
  248. E('div', { 'class': 'cbi-value' }, [
  249. E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Last Run')),
  250. E('div', { 'class': 'cbi-value-field', 'id': 'run', 'style': 'color:#37c' },'-')
  251. ]),
  252. E('div', { class: 'right' }, [
  253. E('button', {
  254. 'class': 'btn cbi-button cbi-button-apply',
  255. 'click': ui.createHandlerFn(this, function() {
  256. return handleAction('timer');
  257. })
  258. }, [ _('Refresh Timer...') ]),
  259. '\xa0\xa0\xa0',
  260. E('button', {
  261. 'class': 'btn cbi-button cbi-button-apply',
  262. 'id': 'btn_suspend',
  263. 'click': ui.createHandlerFn(this, function() {
  264. return handleAction('suspend');
  265. })
  266. }, [ _('Suspend') ]),
  267. '\xa0\xa0\xa0',
  268. E('button', {
  269. 'class': 'btn cbi-button cbi-button-positive',
  270. 'click': ui.createHandlerFn(this, function() {
  271. return handleAction('reload');
  272. })
  273. }, [ _('Reload') ]),
  274. '\xa0\xa0\xa0',
  275. E('button', {
  276. 'class': 'btn cbi-button cbi-button-negative',
  277. 'click': ui.createHandlerFn(this, function() {
  278. return handleAction('restart');
  279. })
  280. }, [ _('Restart') ])
  281. ])
  282. ]);
  283. }, o, this);
  284. this.pollData;
  285. /*
  286. tabbed config section
  287. */
  288. s = m.section(form.NamedSection, 'global', 'adblock', _('Settings'));
  289. s.addremove = false;
  290. s.tab('general', _('General Settings'));
  291. s.tab('additional', _('Additional Settings'));
  292. s.tab('adv_dns', _('Advanced DNS Settings'));
  293. s.tab('adv_report', _('Advanced Report Settings'));
  294. s.tab('adv_email', _('Advanced E-Mail Settings'));
  295. s.tab('sources', _('Blocklist Sources'));
  296. /*
  297. general settings tab
  298. */
  299. o = s.taboption('general', form.Flag, 'adb_enabled', _('Enabled'), _('Enable the adblock service.'));
  300. o.rmempty = false;
  301. o = s.taboption('general', widgets.NetworkSelect, 'adb_trigger', _('Startup Trigger Interface'), _('List of available network interfaces to trigger the adblock start. \
  302. Choose \'unspecified\' to use a classic startup timeout instead of a network trigger.'));
  303. o.nocreate = true;
  304. o.rmempty = true;
  305. o = s.taboption('general', form.Flag, 'adb_forcedns', _('Force Local DNS'), _('Redirect all DNS queries from specified zones to the local DNS resolver, applies to UDP and TCP protocol.'));
  306. o.rmempty = false;
  307. o = s.taboption('general', widgets.ZoneSelect, 'adb_zonelist', _('Forced Zones'), _('Firewall source zones that should be forced locally.'));
  308. o.depends('adb_forcedns', '1');
  309. o.multiple = true;
  310. o.nocreate = true;
  311. o.rmempty = true;
  312. o = s.taboption('general', form.DynamicList, 'adb_portlist', _('Forced Ports'), _('Firewall ports that should be forced locally.'));
  313. o.depends('adb_forcedns', '1');
  314. o.multiple = true;
  315. o.nocreate = false;
  316. o.datatype = 'port';
  317. o.value('53');
  318. o.value('853');
  319. o.value('5353');
  320. o.rmempty = true;
  321. o = s.taboption('general', form.Flag, 'adb_tld', _('TLD Compression'), _('The top level domain compression removes thousands of needless host entries from the final DNS blocklist.'));
  322. o.default = 1
  323. o.rmempty = true;
  324. o = s.taboption('general', form.Flag, 'adb_safesearch', _('Enable SafeSearch'), _('Enforcing SafeSearch for google, bing, duckduckgo, yandex, youtube and pixabay.'));
  325. o.rmempty = false;
  326. o = s.taboption('general', form.MultiValue, 'adb_safesearchlist', _('Limit SafeSearch'), _('Limit SafeSearch to certain providers.'));
  327. o.depends('adb_safesearch', '1');
  328. o.value('google');
  329. o.value('bing');
  330. o.value('duckduckgo');
  331. o.value('yandex');
  332. o.value('youtube');
  333. o.value('pixabay');
  334. o.rmempty = true;
  335. o = s.taboption('general', form.Flag, 'adb_safesearchmod', _('Relax SafeSearch'), _('Enable moderate SafeSearch filters for youtube.'));
  336. o.depends('adb_safesearch', '1');
  337. o.rmempty = true;
  338. o = s.taboption('general', form.Flag, 'adb_report', _('DNS Report'), _('Gather DNS related network traffic via tcpdump and provide a DNS Report on demand. \
  339. Please note: this needs additional \'tcpdump\' or \'tcpdump-mini\' package installation and a full adblock service restart to take effect.'));
  340. o.rmempty = false;
  341. o = s.taboption('general', form.Flag, 'adb_mail', _('E-Mail Notification'), _('Send adblock related notification e-mails. \
  342. Please note: this needs additional \'msmtp\' package installation.'));
  343. o.rmempty = false;
  344. o = s.taboption('general', form.Value, 'adb_mailreceiver', _('E-Mail Receiver Address'), _('Receiver address for adblock notification e-mails.'));
  345. o.depends('adb_mail', '1');
  346. o.placeholder = 'name@example.com';
  347. o.rmempty = true;
  348. /*
  349. additional settings tab
  350. */
  351. o = s.taboption('additional', form.Flag, 'adb_debug', _('Verbose Debug Logging'), _('Enable verbose debug logging in case of any processing errors.'));
  352. o.rmempty = false;
  353. o = s.taboption('additional', form.Flag, 'adb_nice', _('Low Priority Service'), _('Reduce the priority of the adblock background processing to take fewer resources from the system. \
  354. Please note: This change requires a full adblock service restart to take effect.'));
  355. o.enabled = '10';
  356. o.rmempty = true;
  357. o = s.taboption('additional', form.Value, 'adb_triggerdelay', _('Trigger Delay'), _('Additional trigger delay in seconds before adblock processing begins.'));
  358. o.placeholder = '2';
  359. o.datatype = 'range(1,300)';
  360. o.rmempty = true;
  361. o = s.taboption('additional', form.Value, 'adb_tmpbase', _('Base Temp Directory'), _('Base Temp Directory for all adblock related runtime operations, \
  362. e.g. downloading, sorting, merging etc.'));
  363. o.placeholder = '/tmp';
  364. o.rmempty = true;
  365. o = s.taboption('additional', form.Flag, 'adb_backup', _('Blocklist Backup'), _('Create compressed blocklist backups, they will be used in case of download errors or during startup.'));
  366. o.default = 1
  367. o.rmempty = false;
  368. o = s.taboption('additional', form.Value, 'adb_backupdir', _('Backup Directory'), _('Target directory for blocklist backups.'));
  369. o.depends('adb_backup', '1');
  370. o.placeholder = '/tmp/adblock-Backup';
  371. o.rmempty = true;
  372. o = s.taboption('additional', form.ListValue, 'adb_fetchutil', _('Download Utility'), _('List of supported and fully pre-configured download utilities.'));
  373. o.value('uclient-fetch');
  374. o.value('wget');
  375. o.value('curl');
  376. o.value('aria2c');
  377. o.optional = true;
  378. o.rmempty = true;
  379. o = s.taboption('additional', form.Flag, 'adb_fetchinsecure', _('Download Insecure'), _('Don\'t check SSL server certificates during download.'));
  380. o.default = 0
  381. o.rmempty = true;
  382. o = s.taboption('additional', form.Value, 'adb_fetchparm', _('Download Parameters'), _('Manually override the pre-configured download options for the selected download utility.'));
  383. o.optional = true;
  384. o.rmempty = true;
  385. /*
  386. advanced dns settings tab
  387. */
  388. o = s.taboption('adv_dns', form.ListValue, 'adb_dns', _('DNS Backend'), _('List of supported DNS backends with their default list directory. \
  389. To overwrite the default path use the \'DNS Directory\' option.'));
  390. o.value('dnsmasq', _('dnsmasq (/tmp/dnsmasq.d)'));
  391. o.value('unbound', _('unbound (/var/lib/unbound)'));
  392. o.value('named', _('bind (/var/lib/bind)'));
  393. o.value('kresd', _('kresd (/etc/kresd)'));
  394. o.value('raw', _('raw (/tmp)'));
  395. o.optional = true;
  396. o.rmempty = true;
  397. o = s.taboption('adv_dns', form.Value, 'adb_dnsdir', _('DNS Directory'), _('Target directory for the generated blocklist \'adb_list.overall\'.'));
  398. o.placeholder = '/tmp';
  399. o.rmempty = true;
  400. o = s.taboption('adv_dns', form.ListValue, 'adb_dnsinstance', _('DNS Instance'), _('Set the dns backend instance used by adblock.'));
  401. o.value('0', _('First instance (default)'));
  402. o.value('1', _('Second instance'));
  403. o.value('2', _('Third instance'));
  404. o.value('3', _('Fourth instance'));
  405. o.value('4', _('Fifth instance'));
  406. o.depends('adb_dns', 'dnsmasq');
  407. o.optional = true;
  408. o.rmempty = true;
  409. o = s.taboption('adv_dns', form.Value, 'adb_dnstimeout', _('DNS Restart Timeout'), _('Timeout to wait for a successful DNS backend restart.'));
  410. o.placeholder = '20';
  411. o.datatype = 'range(1,60)';
  412. o.rmempty = true;
  413. o = s.taboption('adv_dns', form.Value, 'adb_lookupdomain', _('External DNS Lookup Domain'), _('External domain to check for a successful DNS backend restart. \
  414. Please note: To disable this check set this option to \'false\'.'));
  415. o.placeholder = 'example.com';
  416. o.rmempty = true;
  417. o = s.taboption('adv_dns', form.Flag, 'adb_dnsflush', _('Flush DNS Cache'), _('Empty the DNS cache before adblock processing starts to reduce the memory consumption.'));
  418. o.rmempty = true;
  419. o = s.taboption('adv_dns', form.Flag, 'adb_dnsallow', _('Disable DNS Allow'), _('Disable selective DNS whitelisting (RPZ-PASSTHRU).'));
  420. o.rmempty = true;
  421. o = s.taboption('adv_dns', form.DynamicList, 'adb_denyip', _('Block Local Client IPs'), _('Block all requests of certain DNS clients based on their IP address (RPZ-CLIENT-IP). \
  422. Please note: This feature is currently only supported by bind DNS backend.'));
  423. o.datatype = 'or(ip4addr("nomask"),ip6addr("nomask"))';
  424. o.optional = true;
  425. o.rmempty = true;
  426. o = s.taboption('adv_dns', form.DynamicList, 'adb_allowip', _('Allow Local Client IPs'), _('Allow all requests of certain DNS clients based on their IP address (RPZ-CLIENT-IP). \
  427. Please note: This feature is currently only supported by bind DNS backend.'));
  428. o.datatype = 'or(ip4addr("nomask"),ip6addr("nomask"))';
  429. o.optional = true;
  430. o.rmempty = true;
  431. o = s.taboption('adv_dns', form.Flag, 'adb_jail', _('Additional Jail Blocklist'), _('Builds an additional DNS blocklist to block access to all domains except those listed in the whitelist. \
  432. Please note: You can use this restrictive blocklist e.g. for guest wifi or kidsafe configurations.'));
  433. o.rmempty = true;
  434. o = s.taboption('adv_dns', form.Value, 'adb_jaildir', _('Jail Directory'), _('Target directory for the generated jail blocklist \'adb_list.jail\'.'));
  435. o.depends('adb_jail', '1');
  436. o.placeholder = '/tmp';
  437. o.rmempty = true;
  438. /*
  439. advanced report settings tab
  440. */
  441. o = s.taboption('adv_report', form.DummyValue, '_sub');
  442. o.rawhtml = true;
  443. o.default = '<em><b>Changes on this tab needs a full adblock service restart to take effect.</b></em>';
  444. o = s.taboption('adv_report', widgets.DeviceSelect, 'adb_repiface', _('Report Interface'), _('List of available network devices used by tcpdump.'));
  445. o.nocreate = false;
  446. o.rmempty = true;
  447. o = s.taboption('adv_report', form.Value, 'adb_reportdir', _('Report Directory'), _('Target directory for DNS related report files.'));
  448. o.placeholder = '/tmp/adblock-Report';
  449. o.rmempty = true;
  450. o = s.taboption('adv_report', form.Value, 'adb_repchunkcnt', _('Report Chunk Count'), _('Report chunk count used by tcpdump.'));
  451. o.placeholder = '5';
  452. o.datatype = 'range(1,10)';
  453. o.rmempty = true;
  454. o = s.taboption('adv_report', form.Value, 'adb_repchunksize', _('Report Chunk Size'), _('Report chunk size used by tcpdump in MByte.'));
  455. o.placeholder = '1';
  456. o.datatype = 'range(1,10)';
  457. o.rmempty = true;
  458. o = s.taboption('adv_report', form.Value, 'adb_replisten', _('Report Ports'), _('Space separated list of ports used by tcpdump.'));
  459. o.placeholder = '53';
  460. o.rmempty = true;
  461. o = s.taboption('adv_report', form.Flag, 'adb_represolve', _('Resolve IPs'), _('Resolve reporting IP addresses by using reverse DNS (PTR) lookups.'));
  462. o.rmempty = true;
  463. /*
  464. advanced email settings tab
  465. */
  466. o = s.taboption('adv_email', form.Value, 'adb_mailsender', _('E-Mail Sender Address'), _('Sender address for adblock notification E-Mails.'));
  467. o.placeholder = 'no-reply@adblock';
  468. o.rmempty = true;
  469. o = s.taboption('adv_email', form.Value, 'adb_mailtopic', _('E-Mail Topic'), _('Topic for adblock notification E-Mails.'));
  470. o.placeholder = 'adblock notification';
  471. o.rmempty = true;
  472. o = s.taboption('adv_email', form.Value, 'adb_mailprofile', _('E-Mail Profile'), _('Profile used by \'msmtp\' for adblock notification E-Mails.'));
  473. o.placeholder = 'adb_notify';
  474. o.rmempty = true;
  475. o = s.taboption('adv_email', form.Value, 'adb_mailcnt', _('E-Mail Notification Count'), _('Raise the notification count, to get E-Mails if the overall blocklist count is less or equal to the given limit.'));
  476. o.placeholder = '0';
  477. o.datatype = 'min(0)';
  478. o.rmempty = true;
  479. /*
  480. blocklist sources tab
  481. */
  482. o = s.taboption('sources', form.DummyValue, '_sub');
  483. o.rawhtml = true;
  484. o.default = '<em><b>List of supported and fully pre-configured adblock sources.</b></em><br /> \
  485. List size information with the respective domain ranges as follows:<br /> \
  486. &#8226;&#xa0;<b>S</b> (-10k), <b>M</b> (10k-30k) and <b>L</b> (30k-80k) should work for 128 MByte devices,<br /> \
  487. &#8226;&#xa0;<b>XL</b> (80k-200k) should work for 256-512 MByte devices,<br /> \
  488. &#8226;&#xa0;<b>XXL</b> (200k-) needs more RAM and Multicore support, e.g. x86 or raspberry devices.<br /> \
  489. &#8226;&#xa0;<b>VAR</b> (50k-500k) variable size depending on the selection.<br />';
  490. var name, size, focus, sources = [];
  491. if (result[0]) {
  492. sources = result[0].trim().split('\n');
  493. }
  494. o = s.taboption('sources', form.MultiValue, 'adb_sources', _('Sources (Size, Focus)'));
  495. for (var i = 0; i < sources.length; i++) {
  496. if (sources[i].match(/^\s+\+/)) {
  497. name = sources[i].match(/^\s+\+\s(\w+)\s/)[1] || '-';
  498. size = sources[i].match(/^\s+\+\s\w+[\sx]+(\w+)/)[1] || '-';
  499. focus = sources[i].match(/^\s+\+\s\w+[\sx]+\w+\s+([\w\+]+)/)[1] || '-';
  500. o.value(name, name + ' (' + size + ', ' + focus + ')');
  501. }
  502. }
  503. o.optional = true;
  504. o.rmempty = true;
  505. /*
  506. prepare category data
  507. */
  508. var code, category, list, path, categories = [];
  509. if (result[1]) {
  510. categories = result[1].trim().split('\n');
  511. }
  512. o = s.taboption('sources', form.DummyValue, '_sub');
  513. o.rawhtml = true;
  514. o.default = '<em><b>UTCapitole Archive Selection</b></em>';
  515. o = s.taboption('sources', form.DynamicList, 'adb_utc_sources', _('Categories'));
  516. for (var i = 0; i < categories.length; i++) {
  517. code = categories[i].match(/^(\w+);/)[1].trim();
  518. if (code === 'utc') {
  519. category = categories[i].match(/^\w+;(.*$)/)[1].trim();
  520. o.value(category);
  521. }
  522. }
  523. o.optional = true;
  524. o.rmempty = true;
  525. o = s.taboption('sources', form.DummyValue, '_sub');
  526. o.rawhtml = true;
  527. o.default = '<em><b>StevenBlack List Selection</b></em>';
  528. o = s.taboption('sources', form.DynamicList, 'adb_stb_sources', _('Variants'));
  529. for (var i = 0; i < categories.length; i++) {
  530. code = categories[i].match(/^(\w+);/)[1].trim();
  531. if (code === 'stb') {
  532. list = categories[i].match(/^\w+;(.*);/)[1].trim();
  533. path = categories[i].match(/^.*;(.*$)/)[1].trim();
  534. o.value(path, list);
  535. }
  536. }
  537. o.optional = true;
  538. o.rmempty = true;
  539. o = s.taboption('sources', form.DummyValue, '_sub');
  540. o.rawhtml = true;
  541. o.default = '<em><b>Hagezi List Selection</b></em>';
  542. o = s.taboption('sources', form.DynamicList, 'adb_hag_sources', _('Variants'));
  543. for (var i = 0; i < categories.length; i++) {
  544. code = categories[i].match(/^(\w+);/)[1].trim();
  545. if (code === 'hag') {
  546. list = categories[i].match(/^\w+;(.*);/)[1].trim();
  547. path = categories[i].match(/^.*;(.*$)/)[1].trim();
  548. o.value(path, list);
  549. }
  550. }
  551. o.optional = true;
  552. o.rmempty = true;
  553. o = s.taboption('sources', form.DummyValue, '_sub');
  554. o.rawhtml = true;
  555. o.default = '<em><b>1Hosts List Selection</b></em>';
  556. o = s.taboption('sources', form.DynamicList, 'adb_hst_sources', _('Variants'));
  557. for (var i = 0; i < categories.length; i++) {
  558. code = categories[i].match(/^(\w+);/)[1].trim();
  559. if (code === 'hst') {
  560. list = categories[i].match(/^\w+;(.*);/)[1].trim();
  561. path = categories[i].match(/^.*;(.*$)/)[1].trim();
  562. o.value(path, list);
  563. }
  564. }
  565. o.optional = true;
  566. o.rmempty = true;
  567. return m.render();
  568. },
  569. handleReset: null
  570. });