fix: 修复 koko ssh 方式的连接开关

pull/9568/head
Eric 2023-02-15 18:16:56 +08:00
parent 9339cd271a
commit f4888304bc
1 changed files with 15 additions and 0 deletions

View File

@ -214,6 +214,12 @@ class ConnectMethodUtil:
@classmethod
def get_filtered_protocols_connect_methods(cls, os):
methods = dict(cls.get_protocols_connect_methods(os))
methods = cls._filter_disable_components_connect_methods(methods)
methods = cls._filter_disable_protocols_connect_methods(methods)
return methods
@classmethod
def _filter_disable_components_connect_methods(cls, methods):
component_setting = {
'razor': 'TERMINAL_RAZOR_ENABLED',
'magnus': 'TERMINAL_MAGNUS_ENABLED',
@ -227,6 +233,15 @@ class ConnectMethodUtil:
methods[protocol] = filtered_methods
return methods
@classmethod
def _filter_disable_protocols_connect_methods(cls, methods):
# 过滤一些特殊的协议方式
if not getattr(settings, 'TERMINAL_KOKO_SSH_ENABLED'):
protocol = Protocol.ssh
methods[protocol] = [m for m in methods[protocol] if m['type'] != 'native']
return methods
@classmethod
def get_protocols_connect_methods(cls, os):
if cls._all_methods is not None: