Unverified Commit fdc95a90 authored by 老广's avatar 老广 Committed by GitHub

Merge pull request #278 from jumpserver/dev

Dev
parents cbc752df b72ba6b6
.git .git
logs/* logs/*
keys/* keys/*
data
...@@ -29,10 +29,14 @@ socket_io.on_error_default(lambda x: logger.exception(x)) ...@@ -29,10 +29,14 @@ socket_io.on_error_default(lambda x: logger.exception(x))
class HttpServer: class HttpServer:
@staticmethod @staticmethod
def run(): def run():
import time
host = config["BIND_HOST"] host = config["BIND_HOST"]
port = config["HTTPD_PORT"] port = config["HTTPD_PORT"]
print('Starting websocket server at {}:{}'.format(host, port)) print('Starting websocket server at {}:{}'.format(host, port))
while True:
socket_io.run(app, port=port, host=host, debug=False) socket_io.run(app, port=port, host=host, debug=False)
time.sleep(60)
print("Error occur, rerun websocket server")
@staticmethod @staticmethod
def shutdown(): def shutdown():
......
...@@ -14230,6 +14230,8 @@ $.fn.elfindercwd = function(fm, options) { ...@@ -14230,6 +14230,8 @@ $.fn.elfindercwd = function(fm, options) {
selectCheckbox && selectAllCheckbox.find('input').prop('checked', true); selectCheckbox && selectAllCheckbox.find('input').prop('checked', true);
fm.lazy(function() { fm.lazy(function() {
var files; var files;
// fix select all display; remove cwd disable status
cwd.find('[id]:not(.'+clSelected+'):not(.elfinder-cwd-parent)').removeClass(clDisabled);
cwd.find('[id]:not(.'+clSelected+'):not(.elfinder-cwd-parent)').trigger(evtSelect); cwd.find('[id]:not(.'+clSelected+'):not(.elfinder-cwd-parent)').trigger(evtSelect);
if (fm.maxTargets && (incHashes || cwdHashes).length > fm.maxTargets) { if (fm.maxTargets && (incHashes || cwdHashes).length > fm.maxTargets) {
files = $.map(incHashes || cwdHashes, function(hash) { return fm.file(hash) || null; }); files = $.map(incHashes || cwdHashes, function(hash) { return fm.file(hash) || null; });
......
...@@ -142,6 +142,9 @@ class InteractiveServer: ...@@ -142,6 +142,9 @@ class InteractiveServer:
self.refresh_assets_nodes() self.refresh_assets_nodes()
elif opt in ['h', 'H']: elif opt in ['h', 'H']:
self.display_banner() self.display_banner()
elif opt == '#*32789':
from .logger import append_engineio_logger
append_engineio_logger()
else: else:
self.search_and_proxy_assets(opt) self.search_and_proxy_assets(opt)
......
...@@ -9,7 +9,7 @@ from logging.config import dictConfig ...@@ -9,7 +9,7 @@ from logging.config import dictConfig
from .conf import config as app_config from .conf import config as app_config
def create_logger(): def get_logger_config():
level = app_config['LOG_LEVEL'] level = app_config['LOG_LEVEL']
log_dir = app_config['LOG_DIR'] log_dir = app_config['LOG_DIR']
filename = 'coco-{}.log'.format(socket.gethostname()) filename = 'coco-{}.log'.format(socket.gethostname())
...@@ -21,6 +21,7 @@ def create_logger(): ...@@ -21,6 +21,7 @@ def create_logger():
'level': level, 'level': level,
'propagate': False, 'propagate': False,
} }
config = dict( config = dict(
version=1, version=1,
formatters={ formatters={
...@@ -48,7 +49,7 @@ def create_logger(): ...@@ -48,7 +49,7 @@ def create_logger():
'class': 'logging.handlers.RotatingFileHandler', 'class': 'logging.handlers.RotatingFileHandler',
'formatter': 'main', 'formatter': 'main',
'filename': log_path, 'filename': log_path,
'maxBytes': 1024*1024*100, 'maxBytes': 1024 * 1024 * 100,
'backupCount': 7, 'backupCount': 7,
}, },
}, },
...@@ -61,6 +62,26 @@ def create_logger(): ...@@ -61,6 +62,26 @@ def create_logger():
) )
if level.lower() == 'debug': if level.lower() == 'debug':
config['loggers']['paramiko'] = main_setting config['loggers']['paramiko'] = main_setting
# config['loggers']['socket.io'] = main_setting
# config['loggers']['engineio'] = main_setting
return config
def create_logger():
config = get_logger_config()
dictConfig(config)
logger = logging.getLogger()
return logger
def append_engineio_logger():
main_setting = {
'handlers': ['console', 'file'],
'level': 'DEBUG',
'propagate': False,
}
config = get_logger_config()
config['loggers']['engineio'] = main_setting
dictConfig(config) dictConfig(config)
logger = logging.getLogger() logger = logging.getLogger()
return logger return logger
......
...@@ -118,14 +118,15 @@ class ProxyServer: ...@@ -118,14 +118,15 @@ class ProxyServer:
self.get_system_user_username_if_need() self.get_system_user_username_if_need()
self.get_system_user_auth_or_manual_set() self.get_system_user_auth_or_manual_set()
self.send_connecting_message() self.send_connecting_message()
logger.info("Connect to {}:{} ...".format(self.asset.hostname, self.asset.ssh_port))
if not self.validate_permission(): if not self.validate_permission():
msg = _('No permission') msg = _('No permission')
self.client.send_unicode(warning(wr(msg, before=2, after=0))) self.client.send_unicode(warning(wr(msg, before=2, after=0)))
server = None server = None
elif self.system_user.protocol == 'telnet': elif self.system_user.protocol == 'telnet':
logger.info("Connect to {}:{} ...".format(self.asset.hostname, self.asset.telnet_port))
server = self.get_telnet_server_conn() server = self.get_telnet_server_conn()
elif self.system_user.protocol == 'ssh': elif self.system_user.protocol == 'ssh':
logger.info("Connect to {}:{} ...".format(self.asset.hostname, self.asset.ssh_port))
server = self.get_ssh_server_conn() server = self.get_ssh_server_conn()
else: else:
server = None server = None
......
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