|
26 | 26 | monkey.patch_all() |
27 | 27 | import logging |
28 | 28 | import paramiko |
| 29 | +from paramiko import ssh_exception.ChannelException as channel_exception |
29 | 30 | import os |
30 | 31 | from socket import gaierror as sock_gaierror, error as sock_error |
31 | 32 | from .exceptions import UnknownHostException, AuthenticationException, \ |
@@ -134,11 +135,16 @@ def _connect_tunnel(self): |
134 | 135 | self._connect(self.proxy_client, self.proxy_host, self.proxy_port) |
135 | 136 | logger.info("Connecting via SSH proxy %s:%s -> %s:%s", self.proxy_host, |
136 | 137 | self.proxy_port, self.host, self.port,) |
137 | | - proxy_channel = self.proxy_client.get_transport().\ |
138 | | - open_channel('direct-tcpip', (self.host, self.port,), |
139 | | - ('127.0.0.1', 0)) |
| 138 | + try: |
| 139 | + proxy_channel = self.proxy_client.get_transport().\ |
| 140 | + open_channel('direct-tcpip', (self.host, self.port,), |
| 141 | + ('127.0.0.1', 0)) |
140 | 142 | return self._connect(self.client, self.host, self.port, sock=proxy_channel) |
141 | | - |
| 143 | + except channel_exception, ex: |
| 144 | + error_type = ex.args[1] if len(ex.args) > 1 else ex.args[0] |
| 145 | + raise ConnectionErrorException("Error connecting to host '%s:%s' - %s", |
| 146 | + self.host, self.port, |
| 147 | + str(error_type)) |
142 | 148 | def _connect(self, client, host, port, sock=None, retries=1): |
143 | 149 | """Connect to host |
144 | 150 | |
|
0 commit comments