Make sshtunnel optional

This commit is contained in:
Emanuele 2021-03-25 19:41:12 +01:00
parent b872a37789
commit 455398faa0
3 changed files with 22 additions and 15 deletions

View file

@ -42,6 +42,9 @@ The easiest installation method is by using `pip`, from the root folder of this
(please note the command ends with a dot)
which will install all required dependencies and install a new `rmview` command.
If you want to use the SSH tunnel feature, install with
pip install ".[tunnel]"
Then, from anywhere, you can execute `rmview` from the command line.
The tool will ask for the connection parameters and then ask permission to install the VNC server on the tablet.
@ -54,7 +57,8 @@ If you plan to modify the source code, use `pip install -e .` so that when execu
Install the dependencies ([PyQt5][pyqt5], [Paramiko][paramiko], [Twisted][twisted]) with `pip` or `conda` manually:
# install dependencies
pip install pyqt5 paramiko twisted sshtunnel
pip install pyqt5 paramiko twisted
pip install sshtunnel # optional
# build resources file
pyrcc5 -o src/rmview/resources.py resources.qrc

View file

@ -41,7 +41,8 @@ setup(
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
],
packages=['rmview'],
install_requires=['pyqt5', 'paramiko', 'twisted', 'sshtunnel'],
install_requires=['pyqt5', 'paramiko', 'twisted'],
extras_require = { 'tunnel': ['sshtunnel'] },
entry_points={
'console_scripts':['rmview = rmview.rmview:rmViewMain']
},

View file

@ -7,7 +7,6 @@ from PyQt5.QtCore import *
from .rmparams import *
import paramiko
import sshtunnel
import struct
import time
@ -85,7 +84,7 @@ class RFBFactory(RFBFactory):
return self.instance
def clientConnectionLost(self, connector, reason):
log.warning("Connection lost: %s", reason.getErrorMessage())
log.warning("Disconnected: %s", reason.getErrorMessage())
reactor.callFromThread(reactor.stop)
def clientConnectionFailed(self, connector, reason):
@ -238,20 +237,19 @@ class FrameBufferWorker(QRunnable):
Set up and start SSH tunnel (if configured).
"""
if self.use_ssh_tunnel:
tunnel = self._get_ssh_tunnel()
tunnel.start()
tunnel = self._get_ssh_tunnel()
tunnel.start()
self.sshTunnel = tunnel
self.sshTunnel = tunnel
log.info("Setting up SSH tunnel %s:%s (rm) <-> %s:%s (localhost)" % ("127.0.0.1", 5900,
tunnel.local_bind_host,
tunnel.local_bind_port))
log.info("Setting up SSH tunnel %s:%s (rm) <-> %s:%s (localhost)" % ("127.0.0.1", 5900,
tunnel.local_bind_host,
tunnel.local_bind_port))
vnc_server_host = tunnel.local_bind_host
vnc_server_port = tunnel.local_bind_port
vnc_server_host = tunnel.local_bind_host
vnc_server_port = tunnel.local_bind_port
else:
vnc_server_host = self.ssh.hostname
vnc_server_port = 5900
vnc_server_host = self.ssh.hostname
vnc_server_port = 5900
return (vnc_server_host, vnc_server_port)
@ -269,6 +267,10 @@ class FrameBufferWorker(QRunnable):
else:
open_tunnel_kwargs["ssh_password"] = self.ssh_config["password"]
try:
import sshtunnel
except ModuleNotFoundError:
raise Exception("You need to install `sshtunnel` to use the tunnel feature")
tunnel = sshtunnel.open_tunnel(
(self.ssh.hostname, 22),
remote_bind_address=("127.0.0.1", 5900),