From 4591b03e170a2393bb607dff448dd3f1afe7e341 Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 17 Nov 2022 11:46:35 +0800 Subject: [PATCH] =?UTF-8?q?pref:=20=E4=BF=AE=E6=94=B9=20terminal=20methods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/terminal/const.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/apps/terminal/const.py b/apps/terminal/const.py index d44303f9f..1b39763e0 100644 --- a/apps/terminal/const.py +++ b/apps/terminal/const.py @@ -76,8 +76,14 @@ class NativeClient: mstsc = 'mstsc', 'Remote Desktop' @classmethod - def commands(cls, name, os): - return { + def get_native_clients(cls, p, os='windows'): + clients = { + '' + } + + @classmethod + def get_launch_command(cls, name, os='windows'): + commands = { 'ssh': 'ssh {username}@{hostname} -p {port}', 'putty': 'putty -ssh {username}@{hostname} -P {port}', 'xshell': '-url ssh://root:passwd@192.168.10.100', @@ -90,12 +96,25 @@ class NativeClient: 'redis': 'redis-cli -h {hostname} -p {port} -a {password}', 'mstsc': 'mstsc /v:{hostname}:{port}', } + command = commands.get(name) + if isinstance(command, dict): + command = command.get(os, command.get('default')) + return command + + +class RemoteAppMethod: + @classmethod + def get_remote_app_methods(cls, protocol): + from .models import Applet + applets = Applet.objects.filter(protocol=protocol) + return applets class ConnectMethod(TextChoices): web_cli = 'web_cli', _('Web CLI') web_gui = 'web_gui', _('Web GUI') native_client = 'native_client', _('Native Client') + remote_app = 'remote_app', _('Remote App') @classmethod def methods(cls): @@ -104,6 +123,14 @@ class ConnectMethod(TextChoices): Protocol.rdp: ([cls.web_gui], [cls.native_client]), Protocol.vnc: [cls.web_gui], Protocol.telnet: [cls.web_cli, cls.native_client], + Protocol.mysql: [cls.web_cli, cls.web_gui, cls.native_client], Protocol.sqlserver: [cls.web_cli, cls.web_gui], + Protocol.oracle: [cls.web_cli, cls.web_gui], + Protocol.postgresql: [cls.web_cli, cls.web_gui], + Protocol.redis: [cls.web_cli, cls.web_gui, cls.native_client], + Protocol.mongodb: [cls.web_cli, cls.web_gui], + + Protocol.k8s: [cls.web_cli], + Protocol.http: [], }