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:
'HEARTBEAT_INTERVAL': 5,
'MAX_CONNECTIONS': 500,
'ADMINS': '',
'SSH_TIMEOUT': 15,
'COMMAND_STORAGE': {'TYPE': 'server'}, # server
'REPLAY_STORAGE': {'TYPE': 'server'},
}
......
......@@ -10,11 +10,11 @@ import telnetlib
import paramiko
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
logger = get_logger(__file__)
TIMEOUT = 10
BUF_SIZE = 1024
MANUAL_LOGIN = 'manual'
AUTO_LOGIN = 'auto'
......@@ -46,7 +46,8 @@ class SSHConnection:
ssh.connect(
asset.ip, port=asset.port, username=system_user.username,
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
)
except (paramiko.AuthenticationException,
......@@ -111,7 +112,7 @@ class SSHConnection:
username=gateway.username,
password=gateway.password,
pkey=gateway.private_key_obj,
timeout=TIMEOUT)
timeout=current_app.config['SSH_TIMEOUT'])
except(paramiko.AuthenticationException,
paramiko.BadAuthenticationType,
SSHException):
......
......@@ -16,7 +16,6 @@ from .utils import wrap_with_line_feed as wr, wrap_with_warning as warning, \
logger = get_logger(__file__)
TIMEOUT = 10
BUF_SIZE = 4096
MANUAL_LOGIN = 'manual'
AUTO_LOGIN = 'auto'
......@@ -156,8 +155,11 @@ class ProxyServer:
self.client.send('Connecting to {}@{} {:.1f}'.format(
system_user, asset, delay)
)
while self.connecting and delay < TIMEOUT:
self.client.send('\x08\x08\x08{:.1f}'.format(delay).encode())
while self.connecting and delay < current_app.config['SSH_TIMEOUT']:
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)
delay += 0.1
thread = threading.Thread(target=func)
......
......@@ -66,5 +66,8 @@ class Config:
"TYPE": "server"
}
# SSH connection timeout (default 15 seconds)
# SSH_TIMEOUT = 15
config = Config()
libffi-devel sshpass
\ No newline at end of file
libffi-devel sshpass krb5-devel
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