6rd.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. 'use strict';
  2. 'require form';
  3. 'require network';
  4. network.registerPatternVirtual(/^6rd-.+$/);
  5. return network.registerProtocol('6rd', {
  6. getI18n: function() {
  7. return _('IPv6-over-IPv4 (6rd)');
  8. },
  9. getIfname: function() {
  10. return this._ubus('l3_device') || '6rd-%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('general', form.Value, 'peeraddr', _('Remote IPv4 address'), _('This IPv4 address of the relay'));
  39. o.rmempty = false;
  40. o.datatype = 'ip4addr("nomask")';
  41. o = s.taboption('general', form.Value, 'ip6prefix', _('IPv6 prefix'), _('The IPv6 prefix assigned to the provider, usually ends with <code>::</code>'));
  42. o.rmempty = false;
  43. o.datatype = 'ip6addr';
  44. o = s.taboption('general', form.Value, 'ip6prefixlen', _('IPv6 prefix length'), _('The length of the IPv6 prefix in bits'));
  45. o.placeholder = '16';
  46. o.datatype = 'range(0,128)';
  47. o = s.taboption('general', form.Value, 'ip4prefixlen', _('IPv4 prefix length'), _('The length of the IPv4 prefix in bits, the remainder is used in the IPv6 addresses.'));
  48. o.placeholder = '0';
  49. o.datatype = 'range(0,32)';
  50. o = s.taboption('advanced', form.Value, 'ttl', _('Use TTL on tunnel interface'));
  51. o.placeholder = '64';
  52. o.datatype = 'range(1,255)';
  53. o = s.taboption('advanced', form.Value, 'mtu', _('Use MTU on tunnel interface'));
  54. o.placeholder = '1280';
  55. o.datatype = 'max(9200)';
  56. }
  57. });