2
0

ipip6.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. 'use strict';
  2. 'require form';
  3. 'require network';
  4. 'require tools.widgets as widgets';
  5. network.registerPatternVirtual(/^ipip6-.+$/);
  6. return network.registerProtocol('ipip6', {
  7. getI18n: function () {
  8. return _('IPv4 over IPv6 (RFC2473-IPIPv6)');
  9. },
  10. getIfname: function () {
  11. return this._ubus('l3_device') || 'ipip6-%s'.format(this.sid);
  12. },
  13. getOpkgPackage: function () {
  14. return 'ds-lite';
  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 o;
  30. o = s.taboption('general', form.Value, 'peeraddr', _('Remote IPv6 address or FQDN'));
  31. o.rmempty = false;
  32. o.datatype = 'or(hostname,ip6addr("nomask"))';
  33. o = s.taboption('general', form.Value, 'ip4ifaddr', _('Local IPv4 address'));
  34. o.rmempty = false;
  35. o.datatype = 'ip4addr("nomask")';
  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.Flag, 'defaultroute', _('Default gateway'), _('If unchecked, no default route is configured'));
  56. o.default = o.enabled;
  57. o = s.taboption('advanced', form.Value, 'metric', _('Use gateway metric'));
  58. o.placeholder = '0';
  59. o.datatype = 'uinteger';
  60. o.depends('defaultroute', '1');
  61. o = s.taboption('advanced', form.Value, 'mtu', _('Use MTU on tunnel interface'));
  62. o.placeholder = '1280';
  63. o.datatype = 'max(9200)';
  64. }
  65. });