Unverified Commit ff28d9a3 authored by BaiJiangJie's avatar BaiJiangJie Committed by GitHub

Merge pull request #245 from jumpserver/dev_bai

[Update] sftp获取资产优先使用InteractiveServer缓存
parents a70156a1 8b1eab83
...@@ -11,6 +11,7 @@ from coco.utils import get_logger ...@@ -11,6 +11,7 @@ from coco.utils import get_logger
from .conf import config from .conf import config
from .service import app_service from .service import app_service
from .connection import SSHConnection from .connection import SSHConnection
from .interactive import InteractiveServer
from .const import ( from .const import (
PERMS_ACTION_NAME_DOWNLOAD_FILE, PERMS_ACTION_NAME_UPLOAD_FILE, PERMS_ACTION_NAME_DOWNLOAD_FILE, PERMS_ACTION_NAME_UPLOAD_FILE,
) )
...@@ -73,11 +74,18 @@ class SFTPServer(paramiko.SFTPServerInterface): ...@@ -73,11 +74,18 @@ class SFTPServer(paramiko.SFTPServerInterface):
self.hosts = self.get_permed_hosts() self.hosts = self.get_permed_hosts()
self.is_finished = False self.is_finished = False
def get_user_assets(self):
user_id = self.server.connection.user.id
assets = InteractiveServer._user_assets_cached.get(user_id)
if assets is None:
assets, new_etag = app_service.get_user_assets(
self.server.connection.user, cache_policy='1'
)
return assets
def get_permed_hosts(self): def get_permed_hosts(self):
hosts = {} hosts = {}
assets = app_service.get_user_assets( assets = self.get_user_assets()
self.server.connection.user, cache_policy='1',
)
for asset in assets: for asset in assets:
if not asset.has_protocol('ssh'): if not asset.has_protocol('ssh'):
continue continue
......
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