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

Updater: Uses wrong local IP address for HTTP server #571

Closed
benbucksch opened this issue Nov 1, 2019 · 1 comment
Closed

Updater: Uses wrong local IP address for HTTP server #571

benbucksch opened this issue Nov 1, 2019 · 1 comment
Labels

Comments

@benbucksch
Copy link

benbucksch commented Nov 1, 2019

Reproduction:

  1. Use Linux
  2. Connect your computer to a local network using Ethernet. Your computer will have IP address 10.10.10.100. This must be the first network.
  3. Connect your computer to the Roborock using Wifi. Your computer will have IP address 192.168.8.100, whereas Roborock is 192.168.8.1.
  4. Run mirobo --ip 192.168.8.1 --token A123 update-firmware v.pkg

Actual result:

Going to update from ../v.pkg
INFO:miio.updater:Serving on 0.0.0.0:45173, timeout 10
INFO:miio.updater:Using local ../v.pkg (md5: ...)
Hosting file at http://10.10.10.100:45173/v.pkg
Update started!
  0%|                                                   | 0/100 [00:05<?, ?it/s]
ERROR:miio.updater:No request was made..

Note that the web server serves from 10.10.10.100. That's the wrong IP address. It cannot work from 192.168.8.1.

Expected result:

oing to update from ../v.pkg
INFO:miio.updater:Serving on 0.0.0.0:36729, timeout 10
INFO:miio.updater:Using local ../v.pkg (md5: ...)
Hosting file at http://192.168.8.100:36729/v.pkg
Update started!
  0%|                                                   | 0/100 [00:00<?, ?it/s]192.168.8.1 - - [01/Nov/2019 06:01:24] "GET /v.pkg HTTP/1.1" 200 -
INFO:miio.updater:Got a request, should be downloading now.
Installation started, please wait until the vacuum reboots
Downloading:  98%|████████████████████████████▍| 98/100 [04:35<00:05,  2.82s/it]

The HTTP server must use the local IP address on the network interface on which the roborock is connected.

Code:
miio/updater.py find_local_ip()

    def find_local_ip():
        ...
        for iface in ifaces_without_lo:
            addresses = netifaces.ifaddresses(iface)
            ...
            for entry in addresses[netifaces.AF_INET]:
                _LOGGER.debug("Got addr: %s" % entry["addr"])
                return entry["addr"]

There is no consideration of the network or IP address on which the Roborock is. It just takes the first non-local network. That's the bug.

Fix:

  1. Pass in the Roborock IP address
  2. Select the local address that is in the same subnet as the Roborock IP.
    You may cheat and assume that the network has a netmask of /24 = 255.255.255.0, which means you can just strip after the last dot and match the local address for that.
    E.g. select addresses that start with 192.168.8..
@rytilahti
Copy link
Owner

You can pass --ip to the update-firmware command to choose which IP address is used for the download URL, so in your case this should work:

mirobo --ip 192.168.8.1 --token A123 update-firmware --ip 192.168.8.100 v.pkg

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

2 participants