Commit a8b07acb authored by ibuler's avatar ibuler

Merge branch 'dev' of github.com:jumpserver/coco into dev

parents 021f9193 511f6c30
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
from .app import Coco from .app import Coco
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import datetime import datetime
import os import os
import time import time
......
#!coding: utf-8 #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
BACKSPACE_CHAR = {b'\x08': b'\x08\x1b[K', b'\x7f': b'\x08\x1b[K'} BACKSPACE_CHAR = {b'\x08': b'\x08\x1b[K', b'\x7f': b'\x08\x1b[K'}
ENTER_CHAR = [b'\r', b'\n', b'\r\n'] ENTER_CHAR = [b'\r', b'\n', b'\r\n']
......
#!/usr/bin/env python #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
......
#!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
#
""" """
coco.config coco.config
~~~~~~~~~~~~ ~~~~~~~~~~~~
......
# coding: utf-8 #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
class PermissionFailed(Exception): class PermissionFailed(Exception):
......
# coding: utf-8 #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import socket import socket
import threading import threading
import logging import logging
......
# coding: utf-8 #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import socket import socket
import json import json
import logging import logging
...@@ -14,11 +17,10 @@ from jms.models import User ...@@ -14,11 +17,10 @@ from jms.models import User
from .models import Request, Client, WSProxy from .models import Request, Client, WSProxy
from .interactive import InteractiveServer from .interactive import InteractiveServer
logger = logging.getLogger(__file__) logger = logging.getLogger(__file__)
class BaseWehSocketHandler: class BaseWebSocketHandler:
def prepare(self): def prepare(self):
self.app = self.settings["app"] self.app = self.settings["app"]
child, parent = socket.socketpair() child, parent = socket.socketpair()
...@@ -36,7 +38,7 @@ class BaseWehSocketHandler: ...@@ -36,7 +38,7 @@ class BaseWehSocketHandler:
return True return True
class InteractiveWehSocketHandler(BaseWehSocketHandler, tornado.websocket.WebSocketHandler): class InteractiveWebSocketHandler(BaseWebSocketHandler, tornado.websocket.WebSocketHandler):
@tornado.web.authenticated @tornado.web.authenticated
def open(self): def open(self):
InteractiveServer(self.app, self.client).interact_async() InteractiveServer(self.app, self.client).interact_async()
...@@ -66,19 +68,19 @@ class InteractiveWehSocketHandler(BaseWehSocketHandler, tornado.websocket.WebSoc ...@@ -66,19 +68,19 @@ class InteractiveWehSocketHandler(BaseWehSocketHandler, tornado.websocket.WebSoc
pass pass
class ProxyWehSocketHandler(BaseWehSocketHandler): class ProxyWebSocketHandler(BaseWebSocketHandler):
pass pass
class MonitorWehSocketHandler(BaseWehSocketHandler): class MonitorWebSocketHandler(BaseWebSocketHandler):
pass pass
class HttpServer: class HttpServer:
routers = [ routers = [
(r'/ws/interactive/', InteractiveWehSocketHandler), (r'/ws/interactive/', InteractiveWebSocketHandler),
(r'/ws/proxy/(?P<asset_id>[0-9]+)/(?P<system_user_id>[0-9]+)/', ProxyWehSocketHandler), (r'/ws/proxy/(?P<asset_id>[0-9]+)/(?P<system_user_id>[0-9]+)/', ProxyWebSocketHandler),
(r'/ws/session/(?P<session_id>[0-9]+)/monitor/', MonitorWehSocketHandler), (r'/ws/session/(?P<session_id>[0-9]+)/monitor/', MonitorWebSocketHandler),
] ]
# prepare may be rewrite it # prepare may be rewrite it
......
#!coding: utf-8 #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import logging import logging
import socket import socket
import threading import threading
......
#!coding: utf-8 #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import logging import logging
import paramiko import paramiko
......
#!/usr/bin/env python #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
......
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json import json
import threading import threading
import datetime import datetime
......
#!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
......
#!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
......
#!coding: utf-8 #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import threading import threading
import uuid import uuid
......
#! coding: utf-8 #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import os import os
import logging import logging
......
#!coding: utf-8 #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
from __future__ import unicode_literals from __future__ import unicode_literals
...@@ -193,7 +195,8 @@ def is_obj_attr_has(obj, val, attrs=("hostname", "ip", "comment")): ...@@ -193,7 +195,8 @@ def is_obj_attr_has(obj, val, attrs=("hostname", "ip", "comment")):
if not attrs: if not attrs:
vals = [val for val in obj.__dict__.values() if isinstance(val, (str, int))] vals = [val for val in obj.__dict__.values() if isinstance(val, (str, int))]
else: else:
vals = [getattr(obj, attr) for attr in attrs if hasattr(obj, attr) and isinstance(hasattr(obj, attr), (str, int))] vals = [getattr(obj, attr) for attr in attrs if
hasattr(obj, attr) and isinstance(hasattr(obj, attr), (str, int))]
for v in vals: for v in vals:
if str(v).find(val) != -1: if str(v).find(val) != -1:
...@@ -363,5 +366,4 @@ def compile_message(): ...@@ -363,5 +366,4 @@ def compile_message():
pass pass
ugettext = _gettext() ugettext = _gettext()
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import os import os
BASE_DIR = os.path.dirname(__file__) BASE_DIR = os.path.dirname(__file__)
......
#!/usr/bin/python #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# #
import os import os
......
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