From c4fef5899c74212040e26d42a16fbc0aca2026b6 Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Wed, 13 Dec 2023 15:51:22 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E8=BF=9E=E6=8E=A5=20RDP=20=E5=8D=8F?= =?UTF-8?q?=E8=AE=AE=E4=BC=9A=E8=AF=9D=E6=97=B6=EF=BC=8C=E9=AB=98=E7=BA=A7?= =?UTF-8?q?=E9=80=89=E9=A1=B9=E6=94=AF=E6=8C=81=20session=20bpp:i=20=20?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=85=8D=E7=BD=AE=EF=BC=9B=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=2032=EF=BC=9B=20(#12319)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: feng <1304903146@qq.com> --- apps/authentication/api/connection_token.py | 10 ++++++---- apps/users/const.py | 5 +++++ apps/users/serializers/preference/luna.py | 6 +++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/apps/authentication/api/connection_token.py b/apps/authentication/api/connection_token.py index 2158a25f1..bc79d26a2 100644 --- a/apps/authentication/api/connection_token.py +++ b/apps/authentication/api/connection_token.py @@ -27,7 +27,7 @@ from perms.models import ActionChoices from terminal.connect_methods import NativeClient, ConnectMethodUtil from terminal.models import EndpointRule, Endpoint from users.const import FileNameConflictResolution -from users.const import RDPSmartSize +from users.const import RDPSmartSize, RDPColorQuality from users.models import Preference from ..models import ConnectionToken, date_expired_default from ..serializers import ( @@ -49,7 +49,6 @@ class RDPFileClientProtocolURLMixin: 'full address:s': '', 'username:s': '', 'use multimon:i': '0', - 'session bpp:i': '32', 'audiomode:i': '0', 'disable wallpaper:i': '0', 'disable full window drag:i': '0', @@ -100,10 +99,13 @@ class RDPFileClientProtocolURLMixin: rdp_options['winposstr:s'] = f'0,1,0,0,{width},{height}' rdp_options['dynamic resolution:i'] = '0' + color_quality = self.request.query_params.get('rdp_color_quality') + color_quality = color_quality if color_quality else os.getenv('JUMPSERVER_COLOR_DEPTH', RDPColorQuality.HIGH) + # 设置其他选项 - rdp_options['smart sizing:i'] = self.request.query_params.get('rdp_smart_size', RDPSmartSize.DISABLE) - rdp_options['session bpp:i'] = os.getenv('JUMPSERVER_COLOR_DEPTH', '32') + rdp_options['session bpp:i'] = color_quality rdp_options['audiomode:i'] = self.parse_env_bool('JUMPSERVER_DISABLE_AUDIO', 'false', '2', '0') + rdp_options['smart sizing:i'] = self.request.query_params.get('rdp_smart_size', RDPSmartSize.DISABLE) # 设置远程应用, 不是 Mstsc if token.connect_method != NativeClient.mstsc: diff --git a/apps/users/const.py b/apps/users/const.py index 6b6fd5fa8..38edeaf2d 100644 --- a/apps/users/const.py +++ b/apps/users/const.py @@ -38,6 +38,11 @@ class RDPSmartSize(TextChoices): ENABLE = '1', _('Enable') +class RDPColorQuality(TextChoices): + HIGH = '32', 'High(32 bit)' + MEDIUM = '16', 'Medium(16 bit)' + + class KeyboardLayout(TextChoices): EN_US_QWERTY = 'en-us-qwerty', 'US English (Qwerty)' EN_UK_QWERTY = 'en-gb-qwerty', 'UK English (Qwerty)' diff --git a/apps/users/serializers/preference/luna.py b/apps/users/serializers/preference/luna.py index 2df89f7bc..b89bf4b36 100644 --- a/apps/users/serializers/preference/luna.py +++ b/apps/users/serializers/preference/luna.py @@ -5,7 +5,7 @@ from rest_framework import serializers from users.const import ( RDPResolution, RDPSmartSize, KeyboardLayout, - RDPClientOption, AppletConnectionMethod + RDPClientOption, AppletConnectionMethod, RDPColorQuality, ) @@ -40,6 +40,10 @@ class GraphicsSerializer(serializers.Serializer): choices=RDPClientOption.choices, default={RDPClientOption.FULL_SCREEN}, label=_('RDP client option'), required=False ) + rdp_color_quality = serializers.ChoiceField( + choices=RDPColorQuality.choices, default=RDPColorQuality.HIGH, + label=_('RDP color quality'), required=False + ) rdp_smart_size = serializers.ChoiceField( RDPSmartSize.choices, default=RDPSmartSize.DISABLE, required=False, label=_('Rdp smart size'),