Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

static Ethernet settings not shown #3079

Open
adioanca-rpma opened this issue Mar 21, 2023 · 5 comments
Open

static Ethernet settings not shown #3079

adioanca-rpma opened this issue Mar 21, 2023 · 5 comments
Labels

Comments

@adioanca-rpma
Copy link

this.elements.network.client.ethernet.ip.value = body.ipdaddr || '';

Issues:

  1. ipdaddr instead of ipaddr
  2. .options is missing. should be body.options.[ipaddr | netmask | gateway]
  3. default values for ipaddr| netmask| gateway should be '' and this.elements.network.client.ethernet.netmask.value = '255.255.255.0'; line be removed IMO.

also the elements are hidden so my ugly workaround was to add:

    this.ethernetEls = ethernetEls;

in setupNetworkElements and

      if (body.mode === 'static') {
        this.ethernetEls.forEach((el) => el.classList.remove('hidden'));
      }

in showEthernetSettings which now looks like this:

  showEthernetSettings: function () {
    this.backButton.href = '/settings/network';
    this.view.classList.add('dark');
    this.hideNetworkElements();
    this.elements.network.main.classList.remove('hidden');

    this.elements.network.client.ethernet.main.classList.remove('hidden');

    API.getLanSettings().then((body) => {
      body = {mode: body.mode, ...body.options}; // <--- ugly but small change
      if (body.mode === 'static') {
        this.ethernetEls.forEach((el) => el.classList.remove('hidden'));
      }
      this.elements.network.client.ethernet.mode.value = body.mode || 'dhcp';
      this.elements.network.client.ethernet.ip.value = body.ipaddr || '';
      this.elements.network.client.ethernet.netmask.value = body.netmask || '';
      this.elements.network.client.ethernet.gateway.value = body.gateway || '';
      this.titlebar.setAttribute("data-l10n-id", "ethernet");
    }).catch((e) => {
      console.error(`Failed to get ethernet config: ${e}`);
    }).then(() => {
      this.validateEthernet();
    });
  },
@benfrancis benfrancis added the bug label Mar 21, 2023
@benfrancis
Copy link
Member

@adioanca-rpma Thanks very much for taking the time to look into this. Would you be willing to put together a pull request with your proposed patch?

Thanks

adioanca-rpma added a commit to adioanca-rpma/gateway that referenced this issue Mar 22, 2023
@adioanca-rpma
Copy link
Author

Done.

@benfrancis @tim-hellhake could you please help with NodeJS 16 build tools docker image?
alongside these:
webthingsio/toolchain-linux-[ARCH]-node-[8|10|12|14]

Thank you

@adioanca-rpma
Copy link
Author

adioanca-rpma commented Mar 22, 2023

Another thing that I observed was that if one presses Done in /settings/network/ethernet screen and dhcp is the selected option, if there is no Ethernet cable plugged in (or no dhcp server on LAN) it will take 1 minute to get back to /settings/network screen.

My solution was to add this to image/stage3/02-systemd-units/00-run.sh:

on_chroot << EOF
# ...

# Faster DHCP for eth0 if there is no link or DHCP server
echo -e "timeout 5;\nretry 1;\npre-up ethtool eth0 | grep -q 'Link detected: yes' || { exit 0; };" >> /etc/dhcp/dhclient.conf

#...

If you want this fix or have a better solution, please let me know.

Thanks

@benfrancis
Copy link
Member

If you want this fix or have a better solution, please let me know.

@adioanca-rpma I don't have another suggestion, no, but please feel free to file a separate issue for that.

I've just noticed that I can't reproduce the bug about static Ethernet settings not being shown in WebThings Gateway 1.1 on a Raspberry Pi, where it seems to work fine. I don't have the current master branch installed on a platform which supports network settings so I can't test that.

Can you confirm which platform you're running on when you experience this bug so that I can try to reproduce it? Is it Raspberry Pi?

I find it odd if this is a regression between 1.1 and master because as far as I'm aware this code hasn't been touched.

Thanks

@adioanca
Copy link

adioanca commented Mar 30, 2023

yes, RPi.

I can reproduce it. branch/commit:

commit 4dadba9a11ec2cadd30353eb9b227bccd5b2b655 (HEAD -> master, origin/master, origin/HEAD)
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Wed Mar 15 05:56:04 2023 +0000

I've just retested now.

To reproduce, try realoading the browser page while in Network (and/or Ethernet page). If you have a static configuration you won't see any of the 3 fields.

Note that once you've changed from dhcp to static, you'll be redirected to network page, and if you go into Ethernet page again - the fields will be visible. And if you change to dhcp, the static fields will remain visible - although they shouldn't.

Try playing static<->dhcp, Network<->Ethernet screens, back and forth and you'll see the issues. Remember to also play with browser page reload.

...

also search the master branch for ipdaddr and ipaddr and you'll see that

this.elements.network.client.ethernet.ip.value = body.ipdaddr || '';
has the extra d typo and it's the only place in the project where it appears - which means a static IP is never shown. I don't understand how it works for you... are you seeing the static IP that you have configured? what about after browser page reload or GW restart?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants