Commit d1605be3 authored by jan.koester's avatar jan.koester
Browse files

test

parent d1c4a328
Loading
Loading
Loading
Loading
+10 −2
Changes for modules/network/network.cpp: 10 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -30,10 +30,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * change those, start/restart/reload apply them.
 *
 *   list                                          -> {interfaces, netdevs}
 *   create  {interface, config?, match?, dhcp?, address?, gateway?, address6?, gateway6?, ipv6AcceptRA?, dns?[]}
 *   update  {interface | config, match?, dhcp?, address?, gateway?, address6?, gateway6?, ipv6AcceptRA?, dns?[]}
 *   create  {interface, config?, match?, dhcp?, dhcp6?, address?, gateway?, address6?, gateway6?, ipv6AcceptRA?, dns?[]}
 *   update  {interface | config, match?, dhcp?, dhcp6?, address?, gateway?, address6?, gateway6?, ipv6AcceptRA?, dns?[]}
 *           dhcp: DHCPv4; dhcp6: DHCPv6 when router advertisements ask for it;
 *           address6/gateway6: IPv6, next to DHCP or an IPv4 address;
 *           ipv6AcceptRA: yes|no|"" (router advertisements, "": the kernel's default)
 *   an interface in the list also has liveDns[]: the name servers in use
 *   (configured, DHCP, router advertisements, DHCPv6)
 *   delete  {interface, config?}
 *   start | stop | restart  {interface}
 *   reload | forceReload    {interface?}          (none: all)
@@ -84,10 +87,14 @@ json_object *toJson(const sysbus::InterfaceInfo &i) {
    json_object *addrs = json_object_new_array();
    for (auto &a : i.addresses) json_object_array_add(addrs, jstr(a));
    json_object_object_add(o, "addresses", addrs);
    json_object *live = json_object_new_array();
    for (auto &d : i.liveDns) json_object_array_add(live, jstr(d));
    json_object_object_add(o, "liveDns", live);
    json_object_object_add(o, "config", jstr(i.config));
    json_object_object_add(o, "configPath", jstr(i.configPath));
    json_object_object_add(o, "match", jstr(i.match));
    json_object_object_add(o, "dhcp", json_object_new_boolean(i.dhcp));
    json_object_object_add(o, "dhcp6", json_object_new_boolean(i.dhcp6));
    json_object_object_add(o, "address", jstr(i.configAddress));
    json_object_object_add(o, "gateway", jstr(i.gateway));
    json_object_object_add(o, "address6", jstr(i.configAddress6));
@@ -235,6 +242,7 @@ bool settings(json_object *a, sysbus::InterfaceSettings &s, std::string &err) {
    s.config = webctl::str(a, "config");
    if (webctl::has(a, "match")) s.match = webctl::str(a, "match");
    if (webctl::has(a, "dhcp")) s.dhcp = webctl::boolean(a, "dhcp");
    if (webctl::has(a, "dhcp6")) s.dhcp6 = webctl::boolean(a, "dhcp6");
    if (webctl::has(a, "address")) s.address = webctl::str(a, "address");
    if (webctl::has(a, "gateway")) s.gateway = webctl::str(a, "gateway");
    if (webctl::has(a, "address6")) s.address6 = webctl::str(a, "address6");
+18 −7
Changes for www/modules/network.js: 18 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -18,6 +18,10 @@
    'no': 'nein',
    'IPv6 works next to DHCP or a static IPv4 address. A link-local gateway (fe80::…) is fine.':
      'IPv6 gilt neben DHCP oder einer statischen IPv4-Adresse. Ein link-lokales Gateway (fe80::…) geht auch.',
    'DHCPv6 when the router asks for it': 'DHCPv6, wenn der Router es verlangt',
    'Router advertisements also bring name servers (RDNSS). DHCPv6 starts when they ask for it: for an address (M flag) or for name servers only (O flag); not with router advertisements off.':
      'Router-Advertisements bringen auch Nameserver mit (RDNSS). DHCPv6 startet, wenn sie es verlangen: für eine Adresse (M-Flag) oder nur für Nameserver (O-Flag); nicht bei abgeschalteten Router-Advertisements.',
    'configured: {0}': 'konfiguriert: {0}',
    'Configuration for {0} saved and applied.': 'Konfiguration für {0} gespeichert und angewendet.',
    'Configuration for {0} saved.': 'Konfiguration für {0} gespeichert.',
    'Delete configuration': 'Konfiguration löschen',
@@ -188,7 +192,7 @@
  // how an interface gets its addresses: 'dhcp', 'static' or 'none' (its
  // own configuration has none: it only carries VLANs, or is layer 2 only)
  const ipModeOf = (i, own) => !own ? 'dhcp' : i.dhcp ? 'dhcp'
                             : i.address || i.address6 || i.ipv6AcceptRA === 'yes' ? 'static' : 'none';
                             : i.address || i.address6 || i.ipv6AcceptRA === 'yes' || i.dhcp6 ? 'static' : 'none';
  // the address fields of a dialog as create/update take them; IPv6 goes
  // with DHCP and static alike, 'none' clears it too
  const ipArgsOf = (d, mode) => ({dhcp: mode === 'dhcp', address: mode === 'static' ? d.address.trim() : '',
@@ -196,9 +200,10 @@
                                  address6: mode === 'none' ? '' : (d.address6 || '').trim(),
                                  gateway6: mode === 'none' ? '' : (d.gateway6 || '').trim(),
                                  ipv6AcceptRA: mode === 'none' ? '' : (d.ipv6AcceptRA || ''),
                                  dhcp6: mode !== 'none' && !!d.dhcp6,
                                  dns: mode === 'none' ? [] : d.dns.split(/[\s,]+/).filter(Boolean)});
  // a static configuration: an IPv4 or an IPv6 address (or one by SLAAC)
  const staticOk = (d, mode) => mode !== 'static' || d.address.trim() || (d.address6 || '').trim() || d.ipv6AcceptRA === 'yes';
  const staticOk = (d, mode) => mode !== 'static' || d.address.trim() || (d.address6 || '').trim() || d.ipv6AcceptRA === 'yes' || d.dhcp6;
  // a dialog's IPv6 fields, filled from i's configuration (none: empty)
  const ipv6Fields = i => h('div', {},
    h('h3', {}, t('IPv6')),
@@ -208,7 +213,9 @@
    h('label', {}, t('Router advertisements'), h('select', {name: 'ipv6AcceptRA'},
      [['', t('kernel default')], ['yes', t('yes: default route and address (SLAAC) from the router')], ['no', t('no')]]
        .map(([v, text]) => h('option', {value: v, selected: (i ? i.ipv6AcceptRA || '' : '') === v}, text)))),
    h('p', {class: 'hint'}, t('IPv6 works next to DHCP or a static IPv4 address. A link-local gateway (fe80::…) is fine.')));
    h('label', {class: 'check'}, h('input', {type: 'checkbox', name: 'dhcp6', checked: !!(i && i.dhcp6)}), t('DHCPv6 when the router asks for it')),
    h('p', {class: 'hint'}, t('IPv6 works next to DHCP or a static IPv4 address. A link-local gateway (fe80::…) is fine.') + ' ' +
      t('Router advertisements also bring name servers (RDNSS). DHCPv6 starts when they ask for it: for an address (M flag) or for name servers only (O flag); not with router advertisements off.')));

  function netdevDialog(kind, nd) {
    const iface = nd && interfaces.find(i => i.name === nd.name);
@@ -253,13 +260,14 @@
        // host's address becoming a bridge port keeps the host reachable
        let addressesTouched = false;
        const takeAddresses = i => {
          if (nd || own || addressesTouched || !ownConfig(i) || (!i.dhcp && !i.address && !i.address6 && i.ipv6AcceptRA !== 'yes')) return;
          if (nd || own || addressesTouched || !ownConfig(i) || ipModeOf(i, true) === 'none') return;
          form.querySelector(`input[name=ipmode][value=${i.dhcp ? 'dhcp' : 'static'}]`).checked = true;
          form.elements.address.value = i.dhcp ? '' : i.address;
          form.elements.gateway.value = i.dhcp ? '' : (i.gateway || '');
          form.elements.address6.value = i.address6 || '';
          form.elements.gateway6.value = i.gateway6 || '';
          form.elements.ipv6AcceptRA.value = i.ipv6AcceptRA || '';
          form.elements.dhcp6.checked = !!i.dhcp6;
          form.elements.dns.value = (i.dns || []).join(', ');
          toggleIp();
          addressesTouched = true;
@@ -268,7 +276,7 @@
        };
        setTimeout(() => {
          if (kind === 'bond') toggle(); toggleIp();
          for (const n of ['address', 'gateway', 'address6', 'gateway6', 'ipv6AcceptRA', 'dns'])
          for (const n of ['address', 'gateway', 'address6', 'gateway6', 'ipv6AcceptRA', 'dhcp6', 'dns'])
            form.elements[n].addEventListener('input', () => { addressesTouched = true; });
          for (const r of form.querySelectorAll('input[name=ipmode]')) r.addEventListener('change', () => { addressesTouched = true; });
        });
@@ -829,7 +837,7 @@
        };
        // without an address: only an interface carrying VLANs
        const carries = (i.vlans || []).length > 0;
        const current = i.dhcp ? 'dhcp' : own && carries && !i.address && !i.address6 && i.ipv6AcceptRA !== 'yes' ? 'none' : 'static';
        const current = i.dhcp ? 'dhcp' : own && carries && ipModeOf(i, true) === 'none' ? 'none' : 'static';
        const mode = (value, text) => h('label', {class: 'check'},
          h('input', {type: 'radio', name: 'mode', value, checked: value === current, onchange: toggle}), text);
        setTimeout(toggle);
@@ -915,7 +923,10 @@
          {title: t('Status'), render: state},
          {title: t('Addresses'), render: i => i.addresses.length ? i.addresses.map(a => h('div', {class: 'mono'}, a))
                                                                  : h('span', {class: 'muted'}, '–')},
          {title: t('DNS'), render: i => (i.dns || []).join(', ')},
          // in use (DHCP, router advertisements); the configured ones too while it is down
          {title: t('DNS'), render: i => (i.liveDns || []).length
            ? i.liveDns.map(d => h('div', {class: 'mono'}, d))
            : (i.dns || []).length ? h('span', {class: 'muted'}, t('configured: {0}', i.dns.join(', '))) : ''},
          {title: t('Configuration'), render: config},
          {title: '', class: 'actions', render: i => i.name === 'lo' ? null : [
            i.stopped || i.operState !== 'up'