Commit 80afe455 authored by BaiJiangJie's avatar BaiJiangJie

[Update] 在线会话,历史会话显示登录来源 Web/SSH Terminal

parent f6ca83c2
......@@ -166,7 +166,7 @@ class TelnetConnection:
self.sock = None
self.sel = selectors.DefaultSelector()
self.incorrect_pattern = re.compile(
r'incorrect|failed|失败', re.I
r'incorrect|failed|失败|错误', re.I
)
self.username_pattern = re.compile(
r'login:\s*$|username:\s*$|用户名:\s*$|账\s*号:\s*$', re.I
......
......@@ -127,7 +127,7 @@ class ProxyNamespace(BaseNamespace):
child, parent = socket.socketpair()
client = Client(parent, room["request"])
forwarder = ProxyServer(client)
forwarder = ProxyServer(client, login_from='WT')
room["client"] = client
room["forwarder"] = forwarder
room["proxy"] = WSProxy(self, child, room["id"])
......
......@@ -260,7 +260,7 @@ class InteractiveServer:
if system_user is None:
self.client.send(_("没有系统用户"))
return
forwarder = ProxyServer(self.client)
forwarder = ProxyServer(self.client, login_from='ST')
forwarder.proxy(asset, system_user)
def interact(self):
......
......@@ -23,9 +23,10 @@ AUTO_LOGIN = 'auto'
class ProxyServer:
def __init__(self, client):
def __init__(self, client, login_from):
self.client = client
self.server = None
self.login_from = login_from
self.connecting = True
self.stop_event = threading.Event()
......@@ -62,7 +63,7 @@ class ProxyServer:
command_recorder = current_app.new_command_recorder()
replay_recorder = current_app.new_replay_recorder()
session = Session(
self.client, self.server,
self.client, self.server, self.login_from,
command_recorder=command_recorder,
replay_recorder=replay_recorder,
)
......
......@@ -14,10 +14,11 @@ logger = get_logger(__file__)
class Session:
def __init__(self, client, server, command_recorder=None, replay_recorder=None):
def __init__(self, client, server, login_from, command_recorder=None, replay_recorder=None):
self.id = str(uuid.uuid4())
self.client = client # Master of the session, it's a client sock
self.server = server # Server channel
self.login_from = login_from # Login from
self._watchers = [] # Only watch session
self._sharers = [] # Join to the session, read and write
self.replaying = True
......@@ -174,7 +175,7 @@ class Session:
"user": self.client.user.username,
"asset": self.server.asset.hostname,
"system_user": self.server.system_user.username,
"login_from": "ST",
"login_from": self.login_from,
"remote_addr": self.client.addr[0],
"is_finished": True if self.stop_evt.is_set() else False,
"date_last_active": self.date_last_active.strftime("%Y-%m-%d %H:%M:%S") + " +0000",
......
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