Commit c13956a4 authored by ibuler's avatar ibuler

Merge remote-tracking branch 'github/dev' into dev

parents 412b7f02 2df44d0b
...@@ -54,6 +54,7 @@ class Coco: ...@@ -54,6 +54,7 @@ class Coco:
'HEARTBEAT_INTERVAL': 5, 'HEARTBEAT_INTERVAL': 5,
'MAX_CONNECTIONS': 500, 'MAX_CONNECTIONS': 500,
'ADMINS': '', 'ADMINS': '',
'SSH_TIMEOUT': 15,
'COMMAND_STORAGE': {'TYPE': 'server'}, # server 'COMMAND_STORAGE': {'TYPE': 'server'}, # server
'REPLAY_STORAGE': {'TYPE': 'server'}, 'REPLAY_STORAGE': {'TYPE': 'server'},
} }
......
...@@ -10,11 +10,11 @@ import telnetlib ...@@ -10,11 +10,11 @@ import telnetlib
import paramiko import paramiko
from paramiko.ssh_exception import SSHException from paramiko.ssh_exception import SSHException
from .ctx import app_service from .ctx import app_service, current_app
from .utils import get_logger, get_private_key_fingerprint, net_input from .utils import get_logger, get_private_key_fingerprint, net_input
logger = get_logger(__file__) logger = get_logger(__file__)
TIMEOUT = 10
BUF_SIZE = 1024 BUF_SIZE = 1024
MANUAL_LOGIN = 'manual' MANUAL_LOGIN = 'manual'
AUTO_LOGIN = 'auto' AUTO_LOGIN = 'auto'
...@@ -46,7 +46,8 @@ class SSHConnection: ...@@ -46,7 +46,8 @@ class SSHConnection:
ssh.connect( ssh.connect(
asset.ip, port=asset.port, username=system_user.username, asset.ip, port=asset.port, username=system_user.username,
password=system_user.password, pkey=system_user.private_key, password=system_user.password, pkey=system_user.private_key,
timeout=TIMEOUT, compress=True, auth_timeout=TIMEOUT, timeout=current_app.config['SSH_TIMEOUT'],
compress=True, auth_timeout=current_app.config['SSH_TIMEOUT'],
look_for_keys=False, sock=sock look_for_keys=False, sock=sock
) )
except (paramiko.AuthenticationException, except (paramiko.AuthenticationException,
...@@ -111,7 +112,7 @@ class SSHConnection: ...@@ -111,7 +112,7 @@ class SSHConnection:
username=gateway.username, username=gateway.username,
password=gateway.password, password=gateway.password,
pkey=gateway.private_key_obj, pkey=gateway.private_key_obj,
timeout=TIMEOUT) timeout=current_app.config['SSH_TIMEOUT'])
except(paramiko.AuthenticationException, except(paramiko.AuthenticationException,
paramiko.BadAuthenticationType, paramiko.BadAuthenticationType,
SSHException): SSHException):
......
...@@ -16,7 +16,6 @@ from .utils import wrap_with_line_feed as wr, wrap_with_warning as warning, \ ...@@ -16,7 +16,6 @@ from .utils import wrap_with_line_feed as wr, wrap_with_warning as warning, \
logger = get_logger(__file__) logger = get_logger(__file__)
TIMEOUT = 10
BUF_SIZE = 4096 BUF_SIZE = 4096
MANUAL_LOGIN = 'manual' MANUAL_LOGIN = 'manual'
AUTO_LOGIN = 'auto' AUTO_LOGIN = 'auto'
...@@ -156,8 +155,11 @@ class ProxyServer: ...@@ -156,8 +155,11 @@ class ProxyServer:
self.client.send('Connecting to {}@{} {:.1f}'.format( self.client.send('Connecting to {}@{} {:.1f}'.format(
system_user, asset, delay) system_user, asset, delay)
) )
while self.connecting and delay < TIMEOUT: while self.connecting and delay < current_app.config['SSH_TIMEOUT']:
self.client.send('\x08\x08\x08{:.1f}'.format(delay).encode()) if 0 <= delay < 10:
self.client.send('\x08\x08\x08{:.1f}'.format(delay).encode())
else:
self.client.send('\x08\x08\x08\x08{:.1f}'.format(delay).encode())
time.sleep(0.1) time.sleep(0.1)
delay += 0.1 delay += 0.1
thread = threading.Thread(target=func) thread = threading.Thread(target=func)
......
...@@ -66,5 +66,8 @@ class Config: ...@@ -66,5 +66,8 @@ class Config:
"TYPE": "server" "TYPE": "server"
} }
# SSH connection timeout (default 15 seconds)
# SSH_TIMEOUT = 15
config = Config() config = Config()
libffi-devel sshpass libffi-devel sshpass krb5-devel
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment