majestrate / XD

meme bittorrent client
https://xd-torrent.github.io/
MIT License
233 stars 25 forks source link

Console interface does not work on a remote machine #77

Closed dbermond closed 4 years ago

dbermond commented 4 years ago

info

git revision / version: git master (currently at XD-0.3.3-d79ff87)

OS: Arch Linux

Architecture: x86_64

problem

The console interface does not work when XD is running at a remote machine (for example, at remote IP 192.168.1.74). Setting bind to 192.168.1.74:1488 and host to 192.168.1.74 at the config file makes the webui to work, but breaks the console interface, which makes it unsuitable for scripting and secure access over ssh.

Can the console interface be used alongside the webui when running at a remote machine? This works nice on a local machine.

backtrace / error messages

Error messages: yes

$ ssh -q 192.168.1.74 grep -A3 'rpc' /etc/xd.conf
[rpc]
enabled=1
bind=192.168.1.74:1488
host=192.168.1.74
$ ssh -q 192.168.1.74 XD-cli list
[ERR] 2019-09-27 00:08:00.790587381 -0300 -03 m=+0.004123558    rpc error: Post http://127.0.0.1:1488/ecksdee/api: dial tcp 127.0.0.1:1488: connect: connection refused

When experimenting with different values in the bind and host options it also does not work. Here are the outputs, adding also curl to test the webui:

$ ssh -q 192.168.1.74 grep -A3 'rpc' /etc/xd.conf
[rpc]
enabled=1
bind=127.0.0.1:1488
host=192.168.1.74
$ ssh -q 192.168.1.74 XD-cli list
[ERR] 2019-09-27 00:11:20.370132381 -0300 -03 m=+0.003360753    rpc error: invalid character 'e' looking for beginning of value
$ curl http://192.168.1.74:1488
curl: (7) Failed to connect to 192.168.1.74 port 1488: Connection refused
$ ssh -q 192.168.1.74 grep -A3 'rpc' /etc/xd.conf
[rpc]
enabled=1
bind=192.168.1.74:1488
host=127.0.0.1
$ ssh -q 192.168.1.74 XD-cli list
[ERR] 2019-09-27 00:13:44.432490532 -0300 -03 m=+0.002866139    rpc error: Post http://127.0.0.1:1488/ecksdee/api: dial tcp 127.0.0.1:1488: connect: connection refused
$ curl http://192.168.1.74:1488
expected host 127.0.0.1 but got 192.168.1.74
$ ssh -q 192.168.1.74 grep -A3 'rpc' /etc/xd.conf
[rpc]
bind=0.0.0.0:1488
host=0.0.0.0
enabled=1
$ ssh -q 192.168.1.74 XD-cli list
[ERR] 2019-09-27 00:50:49.073575364 -0300 -03 m=+0.004247736    rpc error: invalid character 'e' looking for beginning of value
$ curl http://192.168.1.74:1488
expected host 0.0.0.0 but got 192.168.1.74

Backtrace: no

majestrate commented 4 years ago

This means the dns rebinding protection works. see https://en.wikipedia.org/wiki/DNS_rebinding

solution with ssh tunnel would be to bind XD's rpc to loopback address whenever used over a ssh.

dbermond commented 4 years ago

Using 127.0.0.1 makes the console interface to work on a remote machine but blocks the webui to be accessed remotely. In this way, it looks like that only one type of user interface have to be chosen when doing remote access.

Is there a way to use both the web and console interfaces on a remote machine at the same time like it's possible on a local machine?

majestrate commented 4 years ago

you could put XD's webui behind nginx or apache.

dbermond commented 4 years ago

It works nice by placing XD behind nginx with the host setted to 127.0.0.1, making it also to work at the console. Thanks for the tip.

Since this is by design I will close this issue.

Maybe adding an option for listening on all interfaces like setting to it 0.0.0.0 would be a good idea. Please consider.

Thanks for making this torrent client.