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