[X2Go-Commits] [python-x2go] 06/07: Newly understand our own Paramiko/SSH forwarding tunnel code. Become aware of handling multiple connects on the same tunnel.
git-admin at x2go.org
git-admin at x2go.org
Wed Jun 25 01:30:12 CEST 2014
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch master
in repository python-x2go.
commit cea41b3ca3dc7be6baa68eecead6d7c3877d2669
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date: Wed Jun 25 01:19:20 2014 +0200
Newly understand our own Paramiko/SSH forwarding tunnel code. Become aware of handling multiple connects on the same tunnel.
---
debian/changelog | 2 ++
x2go/forward.py | 51 ++++++++++++++++++++++++++-------------------------
2 files changed, 28 insertions(+), 25 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 8e0a24c..f63c5e7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -74,6 +74,8 @@ python-x2go (0.5.0.0-0x2go1) UNRELEASED; urgency=low
good idea. NX should handle that instead (and does).
- Better control the startup bootstrap of the Telekinesis client
subsystem.
+ - Newly understand our own Paramiko/SSH forwarding tunnel code. Become
+ aware of handling multiple connects on the same tunnel.
* debian/control:
+ Add dependencies: python-requests, python-simplejson.
* python-x2go.spec:
diff --git a/x2go/forward.py b/x2go/forward.py
index 89f5df9..b633a50 100644
--- a/x2go/forward.py
+++ b/x2go/forward.py
@@ -43,7 +43,10 @@ class X2GoFwServer(StreamServer):
through an external proxy command launched by a C{X2GoProxy*} backend.
"""
- def __init__ (self, listener, remote_host, remote_port, ssh_transport, session_instance=None, session_name=None, subsystem=None, logger=None, loglevel=log.loglevel_DEFAULT,):
+ def __init__ (self, listener,
+ remote_host, remote_port,
+ ssh_transport, session_instance=None, session_name=None,
+ subsystem=None, logger=None, loglevel=log.loglevel_DEFAULT,):
"""\
@param listener: listen on TCP/IP socket C{(<IP>, <Port>)}
@type listener: C{tuple}
@@ -75,7 +78,7 @@ class X2GoFwServer(StreamServer):
self.chan = None
self.is_active = False
self.failed = False
- self.keepalive = False
+ self.keepalive = None
self.listener = listener
self.chain_host = remote_host
self.chain_port = remote_port
@@ -88,6 +91,10 @@ class X2GoFwServer(StreamServer):
StreamServer.__init__(self, self.listener, self.x2go_forward_tunnel_handle)
+ def start(self):
+ self.keepalive = True
+ return StreamServer.start(self)
+
def x2go_forward_tunnel_handle(self, fw_socket, address):
"""\
Handle for SSH/Paramiko forwarding tunnel.
@@ -107,12 +114,7 @@ class X2GoFwServer(StreamServer):
_count = 0
_maxwait = 20
- while not _success and _count < _maxwait:
-
- # it is recommended here to have passed on the session instance to this object...
- if self.session_instance:
- if not self.session_instance.is_connected():
- break
+ while not _success and _count < _maxwait and self.keepalive:
_count += 1
try:
@@ -122,35 +124,34 @@ class X2GoFwServer(StreamServer):
chan_peername = self.chan.getpeername()
_success = True
except Exception, e:
- self.logger('incoming request to %s:%d failed on attempt %d of %d: %s' % (self.chain_host,
- self.chain_port,
- _count,
- _maxwait,
- repr(e)),
- loglevel=log.loglevel_WARN)
+ if self.keepalive:
+ self.logger('incoming request to %s:%d failed on attempt %d of %d: %s' % (self.chain_host,
+ self.chain_port,
+ _count,
+ _maxwait,
+ repr(e)),
+ loglevel=log.loglevel_WARN)
gevent.sleep(.4)
if not _success:
- self.logger('incoming request to %s:%d failed after %d attempts' % (self.chain_host,
- self.chain_port,
- _count),
- loglevel=log.loglevel_ERROR)
- if self.session_instance:
- self.session_instance.set_session_name(self.session_name)
- self.session_instance.HOOK_forwarding_tunnel_setup_failed(chain_host=self.chain_host, chain_port=self.chain_port, subsystem=self.subsystem)
+ if self.keepalive:
+ self.logger('incoming request to %s:%d failed after %d attempts' % (self.chain_host,
+ self.chain_port,
+ _count),
+ loglevel=log.loglevel_ERROR)
+ if self.session_instance:
+ self.session_instance.set_session_name(self.session_name)
+ self.session_instance.HOOK_forwarding_tunnel_setup_failed(chain_host=self.chain_host, chain_port=self.chain_port, subsystem=self.subsystem)
self.failed = True
else:
-
self.logger('connected! Tunnel open %r -> %r (on master connection %r -> %r)' % (
self.listener, (self.chain_host, self.chain_port),
self.fw_socket.getpeername(), chan_peername),
loglevel=log.loglevel_INFO)
-
# once we are here, we can presume the tunnel to be active...
self.is_active = True
- self.keepalive = True
try:
while self.keepalive:
r, w, x = select.select([self.fw_socket, self.chan], [], [])
@@ -169,7 +170,6 @@ class X2GoFwServer(StreamServer):
except socket.error:
pass
- self.is_active = False
self.logger('Tunnel closed from %r' % (chan_peername,),
loglevel=log.loglevel_INFO)
@@ -216,6 +216,7 @@ class X2GoFwServer(StreamServer):
Stop the forwarding tunnel.
"""
+ self.is_active = False
self.close_socket()
StreamServer.stop(self)
--
Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/python-x2go.git
More information about the x2go-commits
mailing list