proposals.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. 'use strict';
  2. 'require view';
  3. 'require ui';
  4. 'require form';
  5. 'require uci';
  6. return view.extend({
  7. render: function() {
  8. var m, s, o;
  9. m = new form.Map('libreswan', _('IPSec Proposals'));
  10. s = m.section(form.GridSection, 'crypto_proposal');
  11. s.anonymous = false;
  12. s.addremove = true;
  13. s.nodescriptions = true;
  14. s.addbtntitle = _('Add Proposal');
  15. s.renderSectionAdd = function(extra_class) {
  16. var el = form.GridSection.prototype.renderSectionAdd.apply(this, arguments),
  17. nameEl = el.querySelector('.cbi-section-create-name');
  18. ui.addValidator(nameEl, 'uciname', true, function(v) {
  19. let sections = [
  20. ...uci.sections('libreswan', 'crypto_proposal'),
  21. ...uci.sections('libreswan', 'tunnel'),
  22. ];
  23. if (sections.find(function(s) {
  24. return s['.name'] == v;
  25. })) {
  26. return _('This may not share the same name as other proposals or configured tunnels.');
  27. }
  28. if (v.length > 15) return _('Name length shall not exceed 15 characters');
  29. return true;
  30. }, 'blur', 'keyup');
  31. return el;
  32. };
  33. o = s.tab('general', _('General'));
  34. o = s.taboption('general', form.MultiValue, 'hash_algorithm', _('Hash Algorithm'), ('* = %s').format(_('Unsafe')));
  35. o.default = 'md5';
  36. o.value('md5', _('MD5*'));
  37. o.value('sha1', _('SHA1*'));
  38. o.value('sha256', _('SHA256'));
  39. o.value('sha384', _('SHA384'));
  40. o.value('sha512', _('SHA512'));
  41. o = s.taboption('general', form.MultiValue, 'encryption_algorithm', _('Encryption Method'), ('* = %s').format(_('Unsafe')));
  42. o.default = 'aes';
  43. o.value('3des', _('3DES*'))
  44. o.value('aes', _('AES'))
  45. o.value('aes_ctr', _('AES_CTR'));
  46. o.value('aes_cbc', _('AES_CBC'));
  47. o.value('aes128', _('AES128'));
  48. o.value('aes192', _('AES192'));
  49. o.value('aes256', _('AES256'));
  50. o.value('camellia_cbc', _('CAMELLIA_CBC'));
  51. o = s.taboption('general', form.MultiValue, 'dh_group', _('DH Group'),
  52. ('* = %s <a href="%s">RFC8247</a>.').format(_('Unsafe, See'), 'https://www.rfc-editor.org/rfc/rfc8247#section-2.4'));
  53. o.default = 'modp1536';
  54. o.value('modp1536', _('DH Group 5*'));
  55. o.value('modp2048', _('DH Group 14'));
  56. o.value('modp3072', _('DH Group 15'));
  57. o.value('modp4096', _('DH Group 16'));
  58. o.value('modp6144', _('DH Group 17'));
  59. o.value('modp8192', _('DH Group 18'));
  60. o.value('dh19', _('DH Group 19'));
  61. o.value('dh20', _('DH Group 20'));
  62. o.value('dh21', _('DH Group 21'));
  63. o.value('dh22', _('DH Group 22*'));
  64. o.value('dh31', _('DH Group 31'));
  65. return m.render();
  66. }
  67. });