l2tp.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. 'use strict';
  2. 'require uci';
  3. 'require form';
  4. 'require network';
  5. network.registerPatternVirtual(/^l2tp-.+$/);
  6. return network.registerProtocol('l2tp', {
  7. getI18n: function() {
  8. return _('L2TP');
  9. },
  10. getIfname: function() {
  11. return this._ubus('l3_device') || 'l2tp-%s'.format(this.sid);
  12. },
  13. getOpkgPackage: function() {
  14. return 'xl2tpd';
  15. },
  16. isFloating: function() {
  17. return true;
  18. },
  19. isVirtual: function() {
  20. return true;
  21. },
  22. getDevices: function() {
  23. return null;
  24. },
  25. containsDevice: function(ifname) {
  26. return (network.getIfnameOf(ifname) == this.getIfname());
  27. },
  28. renderFormOptions: function(s) {
  29. var dev = this.getL3Device() || this.getDevice(), o;
  30. o = s.taboption('general', form.Value, 'server', _('L2TP Server'));
  31. o.datatype = 'or(host(1), hostport(1))';
  32. s.taboption('general', form.Value, 'username', _('PAP/CHAP username'));
  33. o = s.taboption('general', form.Value, 'password', _('PAP/CHAP password'));
  34. o.password = true;
  35. if (L.hasSystemFeature('ipv6')) {
  36. o = s.taboption('advanced', form.ListValue, 'ppp_ipv6', _('Obtain IPv6 address'), _('Enable IPv6 negotiation on the PPP link'));
  37. o.ucioption = 'ipv6';
  38. o.value('auto', _('Automatic'));
  39. o.value('0', _('Disabled'));
  40. o.value('1', _('Manual'));
  41. o.default = 'auto';
  42. }
  43. o = s.taboption('advanced', form.Value, 'mtu', _('Override MTU'));
  44. o.placeholder = dev ? (dev.getMTU() || '1500') : '1500';
  45. o.datatype = 'max(9200)';
  46. }
  47. });