toltec icon indicating copy to clipboard operation
toltec copied to clipboard

rmfakecloudctl: set-upstream does not validate that URL is valid

Open loughnane opened this issue 1 year ago • 7 comments

Describe the issue Upon installation status is listed as Status: enabled (failed) on RM1

To Reproduce Steps to reproduce the behaviour:

  1. Install toltec per instructions at https://toltec-dev.org/
  2. opkg install rmfakecloud-proxy
  3. rmfakecloudctl set-upstream 192.168.1.100
  4. rmfakecloudctl enable

Expected behaviour I expected the status to be enabled (active)

Screenshots

Device information (please complete the following information):

  • Device: reMarkable1
  • OS version: 2.15.1.1189

Additional context

Installing on two RM1s. The first installation went swimmingly and is working just fine, but I get a Status: enabled (failed) on the second RM1 device. My server is also playing nicely with an RM2.

Generating RSA private key, 2048 bit long modulus (2 primes)
................................................................+++++
.......................+++++
e is 65537 (0x010001)
writing RSA key
Signature ok
subject=C = AA, ST = QQ, L = JJ, O = the culture, CN = *.appspot.com
Getting CA Private Key
Created symlink /etc/systemd/system/multi-user.target.wants/rmfakecloud-proxy.service → /lib/systemd/system/rmfakecloud-proxy.service.
rmfakecloud-proxy is now enabled.
reMarkable: ~/ rmfakecloudctl status
Status: enabled (failed)
Upstream server: 192.168.3.100:8000 (working)
Run `rmfakecloudctl disable` to disable rmfakecloud-proxy.
Run `rmfakecloudctl set-upstream https://<server>` to set the upstream server.

Looking in log.txt I see an error about not having a device token

4580 Dec 19 02:13:19.374 Info: wlan0: Link is up (:0, )
4581 Dec 19 02:13:21.230 Info: wlan0: Address added: fe80::d612:43ff:fe25:6ec2 (:0, )
4582 Dec 19 02:13:25.335 Info: wlan0: Address added: 192.168.1.117 (:0, )
4583 Dec 19 02:13:25.361 Info: Got gateway: 192.168.1.1 (:0, )
4584 Dec 19 02:13:25.367 Warning: Can't fetch user token without device token (:0, )
4585 Dec 19 02:13:25.399 Warning: Can't fetch user token without device token (:0, )
4586 Dec 19 02:13:25.420 Warning: Can't fetch user token without device token (:0, )
4587 Dec 19 02:13:25.448 Warning: Can't fetch user token without device token (:0, )
4588 Dec 19 02:13:25.468 Info: We probably have Internet (:0, )

I'm not sure what to do. I've tried reinstalling (I'm on 2.15.1.1189) and like I said the install worked well on the other RM1. Any suggestions on where to look?

loughnane avatar Dec 19 '23 02:12 loughnane

What does systemctl status rmfakecloud-proxy output?

Eeems avatar Dec 19 '23 02:12 Eeems

[[0;1;31m●[[0m rmfakecloud-proxy.service - rmfakecloud reverse proxy
     Loaded: loaded (/lib/systemd/system/rmfakecloud-proxy.service; enabled; vendor preset: disabled)
     Active: [[0;1;31mfailed[[0m (Result: exit-code) since Tue 2023-12-19 02:15:36 UTC; 26min ago
       Docs: https://github.com/ddvk/rmfakecloud-proxy
    Process: 2599 ExecStart=/opt/bin/rmfakecloud-proxy -c /opt/etc/rmfakecloud-proxy/config [[0;1;31m(code=exited, status=1/FAILURE)[[0m
   Main PID: 2599 (code=exited, status=1/FAILURE)

Dec 19 02:15:36 reMarkable systemd[1]: rmfakecloud-proxy.service: Scheduled restart job, restart counter is at 5.
Dec 19 02:15:36 reMarkable systemd[1]: Stopped rmfakecloud reverse proxy.
Dec 19 02:15:36 reMarkable systemd[1]: [[0;1;38;5;185m[[0;1;39m[[0;1;38;5;185mrmfakecloud-proxy.service: Start request repeated too quickly.[[
0m
Dec 19 02:15:36 reMarkable systemd[1]: [[0;1;38;5;185m[[0;1;39m[[0;1;38;5;185mrmfakecloud-proxy.service: Failed with result 'exit-code'.[[0m
Dec 19 02:15:36 reMarkable systemd[1]: [[0;1;31m[[0;1;39m[[0;1;31mFailed to start rmfakecloud reverse proxy.[[0m

Another thing I just took a peek at was my /home/root/.config/remarkable/xochitl.conf and my deviceeToken and UserToken are null. On the devices that work they're populated. Not sure why.

devicetoken=@ByteArray()
UserToken=@ByteArray()

loughnane avatar Dec 19 '23 02:12 loughnane

The device token is unrelated to if the proxy is able to run or not. The issue you have right now is that the proxy isn't running, so the device isn't able to communicate with your rmfakecloud instance.

What happens if you try to run /opt/bin/rmfakecloud-proxy -c /opt/etc/rmfakecloud-proxy/config manually? I would expect it to crash, but I'm surprised at the lack of output in the logs.

Eeems avatar Dec 19 '23 02:12 Eeems

Got it. Here's the output.

invalid upstream address: parse "192.168.3.100:8000": first path segment in URL cannot contain colon

loughnane avatar Dec 19 '23 02:12 loughnane

Got it. Here's the output.

invalid upstream address: parse "192.168.3.100:8000": first path segment in URL cannot contain colon

Oh, you should set your upstream address to be a valid url. I assume it should be http://192.168.3.100:8000

Eeems avatar Dec 19 '23 02:12 Eeems

Oh my goodness. That's it. Thanks. :man_facepalming:

loughnane avatar Dec 19 '23 03:12 loughnane

Oh my goodness. That's it. Thanks. 🤦‍♂️

No worries, this does show that rmfakecloudctl should do a tiny bit of validation on the URL provided and give a bit of insight into why it isn't valid if you miss something it expects.

Eeems avatar Dec 19 '23 03:12 Eeems