mirror of https://github.com/jumpserver/jumpserver
perf: 修改 sftp 协议
parent
48510e98a2
commit
b0b6d19bc0
|
@ -52,7 +52,6 @@ class NativeClient(TextChoices):
|
|||
Protocol.mariadb: [cls.db_client],
|
||||
Protocol.redis: [cls.db_client],
|
||||
Protocol.mongodb: [cls.db_client],
|
||||
|
||||
Protocol.oracle: [cls.db_client],
|
||||
Protocol.postgresql: [cls.db_client],
|
||||
}
|
||||
|
@ -96,7 +95,6 @@ class NativeClient(TextChoices):
|
|||
'label': client.label,
|
||||
'type': 'native',
|
||||
})
|
||||
print("Methods: ", methods)
|
||||
return methods
|
||||
|
||||
@classmethod
|
||||
|
@ -150,12 +148,18 @@ class ConnectMethodUtil:
|
|||
protocols = {
|
||||
TerminalType.koko: {
|
||||
'web_methods': [WebMethod.web_cli],
|
||||
'listen': [Protocol.http, Protocol.ssh],
|
||||
'listen': [Protocol.http, Protocol.ssh, Protocol.sftp],
|
||||
'support': [
|
||||
Protocol.ssh, Protocol.sftp, Protocol.telnet,
|
||||
Protocol.ssh, Protocol.telnet, Protocol.sftp,
|
||||
Protocol.redis, Protocol.mongodb,
|
||||
Protocol.k8s, Protocol.clickhouse,
|
||||
],
|
||||
# 限制客户端的协议,比如 koko 虽然也支持 数据库的 ssh 连接,但是不再这里拉起
|
||||
# Listen协议: [Asset协议]
|
||||
'client_limits': {
|
||||
Protocol.sftp: [Protocol.sftp],
|
||||
Protocol.ssh: [Protocol.ssh, Protocol.telnet],
|
||||
},
|
||||
'match': 'm2m'
|
||||
},
|
||||
TerminalType.chen: {
|
||||
|
@ -262,20 +266,20 @@ class ConnectMethodUtil:
|
|||
|
||||
methods = defaultdict(list)
|
||||
spec_web_methods = WebMethod.get_spec_methods()
|
||||
native_methods = NativeClient.get_methods(os)
|
||||
applet_methods = AppletMethod.get_methods()
|
||||
native_methods = NativeClient.get_methods(os=os)
|
||||
|
||||
for component, component_protocol in cls.components().items():
|
||||
support = component_protocol['support']
|
||||
component_web_methods = component_protocol.get('web_methods', [])
|
||||
default_web_methods = component_protocol.get('web_methods', [])
|
||||
client_limits = component_protocol.get('client_limits', {})
|
||||
|
||||
for protocol in support:
|
||||
for asset_protocol in support:
|
||||
# Web 方式
|
||||
web_methods = spec_web_methods.get(protocol, None)
|
||||
if web_methods is None:
|
||||
web_methods = component_web_methods
|
||||
|
||||
methods[str(protocol)].extend([
|
||||
web_methods = spec_web_methods.get(asset_protocol, [])
|
||||
if not web_methods:
|
||||
web_methods = default_web_methods
|
||||
methods[str(asset_protocol)].extend([
|
||||
{
|
||||
'component': component.value,
|
||||
'type': 'web',
|
||||
|
@ -288,31 +292,32 @@ class ConnectMethodUtil:
|
|||
|
||||
# 客户端方式
|
||||
if component_protocol['match'] == 'map':
|
||||
listen = [protocol]
|
||||
listen = [asset_protocol]
|
||||
else:
|
||||
listen = component_protocol['listen']
|
||||
|
||||
for listen_protocol in listen:
|
||||
# Native method
|
||||
if component == TerminalType.koko and protocol.value not in [Protocol.ssh, Protocol.sftp]:
|
||||
# koko 仅支持 ssh 的 native 方式,其他数据库的 native 方式不提供
|
||||
limits = client_limits.get(listen_protocol, [])
|
||||
if limits and asset_protocol not in limits:
|
||||
continue
|
||||
methods[str(protocol)].extend([
|
||||
# Native method
|
||||
client_methods = native_methods.get(listen_protocol, [])
|
||||
methods[str(asset_protocol)].extend([
|
||||
{
|
||||
'component': component.value,
|
||||
'type': 'native',
|
||||
'endpoint_protocol': listen_protocol,
|
||||
**method
|
||||
}
|
||||
for method in native_methods[listen_protocol]
|
||||
for method in client_methods
|
||||
])
|
||||
|
||||
# 远程应用方式,这个只有 tinker 提供,并且协议可能是自定义的
|
||||
for protocol, applet_methods in applet_methods.items():
|
||||
for asset_protocol, applet_methods in applet_methods.items():
|
||||
for method in applet_methods:
|
||||
method['listen'] = 'rdp'
|
||||
method['component'] = TerminalType.tinker.value
|
||||
methods[protocol].extend(applet_methods)
|
||||
methods[asset_protocol].extend(applet_methods)
|
||||
|
||||
cls._all_methods[os] = methods
|
||||
return methods
|
||||
|
|
Loading…
Reference in New Issue