dslite.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. 'use strict';
  2. 'require form';
  3. 'require network';
  4. 'require tools.widgets as widgets';
  5. network.registerPatternVirtual(/^ds-.+$/);
  6. network.registerErrorCode('AFTR_DNS_FAIL', _('Unable to resolve AFTR host name'));
  7. return network.registerProtocol('dslite', {
  8. getI18n: function() {
  9. return _('Dual-Stack Lite (RFC6333)');
  10. },
  11. getIfname: function() {
  12. return this._ubus('l3_device') || 'ds-%s'.format(this.sid);
  13. },
  14. getOpkgPackage: function() {
  15. return 'ds-lite';
  16. },
  17. isFloating: function() {
  18. return true;
  19. },
  20. isVirtual: function() {
  21. return true;
  22. },
  23. getDevices: function() {
  24. return null;
  25. },
  26. containsDevice: function(ifname) {
  27. return (network.getIfnameOf(ifname) == this.getIfname());
  28. },
  29. renderFormOptions: function(s) {
  30. var o;
  31. o = s.taboption('general', form.Value, 'peeraddr', _('DS-Lite AFTR address'));
  32. o.rmempty = false;
  33. o.datatype = 'or(hostname,ip6addr("nomask"))';
  34. o.value("gw.transix.jp", _("Transix (Japan only)"));
  35. o.value("dgw.xpass.jp", _("Cross Pass (Japan only)"));
  36. o = s.taboption('general', form.Value, 'ip6addr', _('Local IPv6 address'), _('Leave empty to use the current WAN address'));
  37. o.datatype = 'ip6addr("nomask")';
  38. o.load = function(section_id) {
  39. return network.getWAN6Networks().then(L.bind(function(nets) {
  40. if (Array.isArray(nets) && nets.length)
  41. this.placeholder = nets[0].getIP6Addr();
  42. return form.Value.prototype.load.apply(this, [section_id]);
  43. }, this));
  44. };
  45. o = s.taboption('advanced', widgets.NetworkSelect, 'tunlink', _('Tunnel Link'));
  46. o.nocreate = true;
  47. o.exclude = s.section;
  48. o = s.taboption('advanced', form.ListValue, 'encaplimit', _('Encapsulation limit'));
  49. o.rmempty = false;
  50. o.default = 'ignore';
  51. o.datatype = 'or("ignore",range(0,255))';
  52. o.value('ignore', _('ignore'));
  53. for (var i = 0; i < 256; i++)
  54. o.value(i);
  55. o = s.taboption('advanced', form.Value, 'mtu', _('Use MTU on tunnel interface'));
  56. o.placeholder = '1280';
  57. o.datatype = 'max(9200)';
  58. }
  59. });