Skip to content

Commit beea715

Browse files
authored
Merge pull request #135 from jumpserver/dev
Dev
2 parents 572e855 + 42fbefd commit beea715

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

coco/connection.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,16 @@ def get_ssh_client(self, asset, system_user):
3737
ssh = paramiko.SSHClient()
3838
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
3939
sock = None
40+
error = ''
4041

4142
if not system_user.password and not system_user.private_key:
4243
self.get_system_user_auth(system_user)
4344

4445
if asset.domain:
4546
sock = self.get_proxy_sock_v2(asset)
47+
if not sock:
48+
error = 'Connect gateway failed;'
49+
logger.error(error)
4650

4751
try:
4852
try:
@@ -81,9 +85,9 @@ def get_ssh_client(self, asset, system_user):
8185
system_user.username, asset.ip, asset.port,
8286
password_short, key_fingerprint,
8387
))
84-
return None, None, str(e)
88+
return None, None, error + '\n' + str(e)
8589
except (socket.error, TimeoutError) as e:
86-
return None, None, str(e)
90+
return None, None, error + '\n' + str(e)
8791
return ssh, sock, None
8892

8993
def get_transport(self, asset, system_user):
@@ -126,9 +130,9 @@ def get_proxy_sock_v2(asset):
126130
password=gateway.password,
127131
pkey=gateway.private_key_obj,
128132
timeout=config['SSH_TIMEOUT'])
129-
except(paramiko.AuthenticationException,
130-
paramiko.BadAuthenticationType,
131-
SSHException):
133+
except (paramiko.AuthenticationException,
134+
paramiko.BadAuthenticationType,
135+
SSHException, socket.error):
132136
continue
133137
sock = ssh.get_transport().open_channel(
134138
'direct-tcpip', (asset.ip, asset.port), ('127.0.0.1', 0)

coco/httpd/elfinder/connector.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ def get_request_commands(self):
136136
return cmd
137137
else:
138138
self.response['error'] = 'No valid command found'
139+
return None, None
139140

140141
def run(self, request):
141142
""" Main entry point for running commands. Attemps to run a command

0 commit comments

Comments
 (0)