'require view';
'require form';
'require uci';
+'require ui';
'require tools.widgets as widgets';
'require strongswan_algorithms';
});
}
+function sectionNameCheck(extra_class) {
+ var el = form.GridSection.prototype.renderSectionAdd.apply(this, arguments),
+ nameEl = el.querySelector('.cbi-section-create-name');
+ ui.addValidator(nameEl, 'uciname', true, function(v) {
+ let sections = [
+ ...uci.sections('ipsec', 'remote'),
+ ...uci.sections('ipsec', 'tunnel'),
+ ...uci.sections('ipsec', 'crypto_proposal'),
+ ];
+ if (sections.find(function(s) {
+ return s['.name'] == v;
+ })) {
+ return _('Remotes, Encryption Proposals and Tunnels may not share the same names.') + ' ' +
+ _('Use combinations like tunnel1_phase1 that do not exceed 15 characters.');
+ }
+ if (v.length > 15) return _('Name length shall not exceed 15 characters');
+ return true;
+ }, 'blur', 'keyup');
+ return el;
+};
+
return view.extend({
load: function () {
return uci.load('network');
// strongSwan General Settings
s = m.section(form.TypedSection, 'ipsec', _('General Settings'));
s.anonymous = true;
+ s.addremove = true;
o = s.option(widgets.ZoneSelect, 'zone', _('Zone'),
_('Firewall zone that has to match the defined firewall zone'));
_('Define Remote IKE Configurations.'));
s.addremove = true;
s.nodescriptions = true;
+ s.renderSectionAdd = sectionNameCheck
o = s.tab('general', _('General'));
o = s.tab('authentication', _('Authentication'));
o.rmempty = false;
o = s.taboption('general', form.MultiValue, 'tunnel', _('Tunnel'),
- _('Name of ESP (phase 2) section'));
+ _('The Tunnel containing the ESP (phase 2) section'));
o.load = function (section_id) {
this.keylist = [];
this.vallist = [];
_('Define Connection Children to be used as Tunnels in Remote Configurations.'));
s.addremove = true;
s.nodescriptions = true;
+ s.renderSectionAdd = sectionNameCheck;
o = s.tab('general', _('General'));
o = s.tab('advanced', _('Advanced'));
_('Configure Cipher Suites to define IKE (Phase 1) or ESP (Phase 2) Proposals.'));
s.addremove = true;
s.nodescriptions = true;
+ s.renderSectionAdd = sectionNameCheck;
o = s.option(form.Flag, 'is_esp', _('ESP Proposal'),
_('Whether this is an ESP (phase 2) proposal or not'));