警告

注意!建议下载到本地修改,并且做好原文件的备份,如果有错误方便直接替换恢复!!!

提示

原生的RDP控制台,没有桌面壁纸渲染,禁用了全部主题,一切为了减小带宽传输,但是开启这些特效、动画后实际速度也没有明显变化,所以个人或使用人数较少则建议开启。

修改下方的php文件,将if ($type == "rdp")if ($type == "rdp-tls")的内容进行替换

/opt/unetlab/html/includes/functions.php
    if ($type == "rdp") {
        $connectionData = [
            //参数参考:https://guacamole.apache.org/doc/gug/configuring-guacamole.html#rdp
            //参数参考:https://github.com/TelDragon/guacamole/blob/master/docs/%E9%85%8D%E7%BD%AE%E9%93%BE%E6%8E%A5RDP%E5%8F%82%E6%95%B0_zh.md
            // RDP连接基本设置
            "( " . $connectionId . ",'ignore-cert','true' )", // 是否忽略服务器证书
            "( " . $connectionId . ", 'hostname', '" . $hostname . "' )", // RDP服务器主机名或IP地址
            "( " . $connectionId . ", 'port', '" . $servicePort . "' )", // RDP服务器端口

            // 性能标识
            "( " . $connectionId . ",'enable-wallpaper', 'true' )", // 开启桌面壁纸渲染
            "( " . $connectionId . ",'enable-theming', 'true' )", // 开启窗口和控件的主题
            "( " . $connectionId . ",'enable-font-smoothing', 'true' )", // 文本将以平滑的边缘呈现
            //"( " . $connectionId . ",'enable-full-window-drag', 'true' )", // 窗口的内容将随着窗口的移动而显示
            "( " . $connectionId . ",'enable-desktop-composition', 'true' )", // 允许使用透明窗口和阴影等图形效果
            //"( " . $connectionId . ",'enable-menu-animations', 'true' )", // 菜单开启和关闭动画将被允许
            //"( " . $connectionId . ",'disable-glyph-caching', 'true' )", // 启用字形缓存
            //"( " . $connectionId . ",'disable-bitmap-caching', 'true' )", // 启用位图缓存*
            //"( " . $connectionId . ",'disable-offscreen-caching', 'true' )", // 启用离屏缓存*

            // 显示设置
            "( " . $connectionId . ",'color-depth', '32' )", // 要请求的颜色深度,以每像素位数为单位。此参数是可选的。 如果指定,则此值必须为 8、16 或 24、32。
            "( " . $connectionId . ",'resize-method', 'display-update' )", // 分辨率自适应,当客户端显示的宽度或高度发生变化时,用于更新RDP服务器的方法。可选参数:display-update、reconnect
            //"( " . $connectionId . ",'force-lossless', 'true' )", //设置无损传输图像

            //设备重定向
            "( " . $connectionId . ",'enable-printing','false' )", //禁用打印机
            "( " . $connectionId . ",'enable-drive','true' )", // 启用文件传输后,RDP用户可以将文件传输到持久存在于Guacamole服务器上的虚拟驱动器。
            "( " . $connectionId . ",'create-drive-path','true' )", // 如果设置为“true”,并且启用了文件传输,同时drive-path 该参数不存在,则该参数指定的目录将自动创建。
            "( " . $connectionId . ",'drive-path','/tmp/" . $connectionId . "' )",// Guacamole服务器上应存储传输文件的目录。该目录必须对guacd可访问,并且对运行guacd的用户可读写。
        ];

        if ($password != null && $username != null) {
            // 身份验证相关设置
            $connectionData[] = "( " . $connectionId . ",'disable-auth','false' )"; // 启用身份验证
            $connectionData[] = "( " . $connectionId . ",'username','" . $username . "' )"; // RDP连接用户名
            $connectionData[] = "( " . $connectionId . ",'password','" . $password . "' )"; // RDP连接密码
            $connectionData[] = "( " . $connectionId . ",'security','any' )"; // 安全性设置
        } else {
            // 未提供用户名和密码时的设置
            $connectionData[] = "( " . $connectionId . ",'disable-auth','true' )"; // 禁用身份验证
            $connectionData[] = "( " . $connectionId . ",'security', 'any' )"; // 安全性设置
        }
    }

    if ($type == "rdp-tls") {
        $connectionData = [
            //参数参考:https://guacamole.apache.org/doc/gug/configuring-guacamole.html#rdp
            //参数参考:https://github.com/TelDragon/guacamole/blob/master/docs/%E9%85%8D%E7%BD%AE%E9%93%BE%E6%8E%A5RDP%E5%8F%82%E6%95%B0_zh.md
            // RDP连接基本设置
            "( " . $connectionId . ",'ignore-cert','true' )", // 是否忽略服务器证书
            "( " . $connectionId . ", 'hostname', '" . $hostname . "' )", // RDP服务器主机名或IP地址
            "( " . $connectionId . ", 'port', '" . $servicePort . "' )", // RDP服务器端口

            // 性能标识
            "( " . $connectionId . ",'enable-wallpaper', 'true' )", // 开启桌面壁纸渲染
            "( " . $connectionId . ",'enable-theming', 'true' )", // 开启窗口和控件的主题
            "( " . $connectionId . ",'enable-font-smoothing', 'true' )", // 文本将以平滑的边缘呈现
            //"( " . $connectionId . ",'enable-full-window-drag', 'true' )", // 窗口的内容将随着窗口的移动而显示
            "( " . $connectionId . ",'enable-desktop-composition', 'true' )", // 允许使用透明窗口和阴影等图形效果
            //"( " . $connectionId . ",'enable-menu-animations', 'true' )", // 菜单开启和关闭动画将被允许
            //"( " . $connectionId . ",'disable-glyph-caching', 'true' )", // 启用字形缓存
            //"( " . $connectionId . ",'disable-bitmap-caching', 'true' )", // 启用位图缓存*
            //"( " . $connectionId . ",'disable-offscreen-caching', 'true' )", // 启用离屏缓存*

            // 显示设置
            "( " . $connectionId . ",'color-depth', '32' )", // 要请求的颜色深度,以每像素位数为单位。此参数是可选的。 如果指定,则此值必须为 8、16 或 24。
            "( " . $connectionId . ",'resize-method', 'display-update' )", // 分辨率自适应,当客户端显示的宽度或高度发生变化时,用于更新RDP服务器的方法。可选参数:display-update、reconnect
            //"( " . $connectionId . ",'force-lossless', 'true' )", //设置无损传输图像

            //设备重定向
            "( " . $connectionId . ",'enable-printing','false' )", //禁用打印机
            "( " . $connectionId . ",'enable-drive','true' )", // 启用文件传输后,RDP用户可以将文件传输到持久存在于Guacamole服务器上的虚拟驱动器。
            "( " . $connectionId . ",'drive-path','/tmp/" . $connectionId . "' )",// Guacamole服务器上应存储传输文件的目录。该目录必须对guacd可访问,并且对运行guacd的用户可读写。。
            "( " . $connectionId . ",'create-drive-path','true' )", // 如果设置为“true”,并且启用了文件传输,同时drive-path 该参数不存在,则该参数指定的目录将自动创建。
        ];

        if ($password != null && $username != null) {
            // 身份验证相关设置
            $connectionData[] = "( " . $connectionId . ",'disable-auth','false' )"; // 启用身份验证
            $connectionData[] = "( " . $connectionId . ",'username','" . $username . "' )"; // RDP连接用户名
            $connectionData[] = "( " . $connectionId . ",'password','" . $password . "' )"; // RDP连接密码
            $connectionData[] = "( " . $connectionId . ",'security','tls' )"; // 安全性设置
        } else {
            // 未提供用户名和密码时的设置
            $connectionData[] = "( " . $connectionId . ",'disable-auth','true' )"; // 禁用身份验证
            $connectionData[] = "( " . $connectionId . ",'security', 'tls' )"; // 安全性设置
        }
    }

image-20240113214902066

自适应分辨率还需要将下图$onresize变量的值修改为display-update

image-20240129184409015

警告

自适应分辨率功能需要RDP服务端8.1版本以上,否则无效

111