From f4888304bc442f3932781f8be681bbccce25e841 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 15 Feb 2023 18:16:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20koko=20ssh=20?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E7=9A=84=E8=BF=9E=E6=8E=A5=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/terminal/connect_methods.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/apps/terminal/connect_methods.py b/apps/terminal/connect_methods.py index c2d69322c..5238715da 100644 --- a/apps/terminal/connect_methods.py +++ b/apps/terminal/connect_methods.py @@ -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: