6to4.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. 'use strict';
  2. 'require form';
  3. 'require network';
  4. network.registerPatternVirtual(/^6to4-.+$/);
  5. return network.registerProtocol('6to4', {
  6. getI18n: function() {
  7. return _('IPv6-over-IPv4 (6to4)');
  8. },
  9. getIfname: function() {
  10. return this._ubus('l3_device') || '6to4-%s'.format(this.sid);
  11. },
  12. getOpkgPackage: function() {
  13. return '6rd';
  14. },
  15. isFloating: function() {
  16. return true;
  17. },
  18. isVirtual: function() {
  19. return true;
  20. },
  21. getDevices: function() {
  22. return null;
  23. },
  24. containsDevice: function(ifname) {
  25. return (network.getIfnameOf(ifname) == this.getIfname());
  26. },
  27. renderFormOptions: function(s) {
  28. var o;
  29. o = s.taboption('general', form.Value, 'ipaddr', _('Local IPv4 address'), _('Leave empty to use the current WAN address'));
  30. o.datatype = 'ip4addr("nomask")';
  31. o.load = function(section_id) {
  32. return network.getWANNetworks().then(L.bind(function(nets) {
  33. if (nets.length)
  34. this.placeholder = nets[0].getIPAddr();
  35. return form.Value.prototype.load.apply(this, [section_id]);
  36. }, this));
  37. };
  38. o = s.taboption('advanced', form.Value, 'ttl', _('Use TTL on tunnel interface'));
  39. o.placeholder = '64';
  40. o.datatype = 'range(1,255)';
  41. o = s.taboption('advanced', form.Value, 'mtu', _('Use MTU on tunnel interface'));
  42. o.placeholder = '1280';
  43. o.datatype = 'max(9200)';
  44. }
  45. });