mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-27 20:00:51 +00:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b5143af1d | ||
|
|
29008d5d10 | ||
|
|
066241af89 | ||
|
|
0a209474d1 | ||
|
|
e85b726451 | ||
|
|
1bcf37d777 | ||
|
|
9f52799363 | ||
|
|
a0af73e458 |
No files matched your search
@@ -0,0 +1,72 @@
|
||||
# This file is machine-generated by `gh actions-lock`.
|
||||
# Do not edit by hand; run `gh actions-lock` to update.
|
||||
# Docs: https://gh.io/actions-lockfile
|
||||
version: 'v0.0.3'
|
||||
workflows:
|
||||
'.github/workflows/build-et-binaries.yml':
|
||||
- 'actions/cache@v6.1.0'
|
||||
- 'actions/checkout@v7.0.1'
|
||||
- 'actions/download-artifact@v8.0.2'
|
||||
- 'actions/upload-artifact@v7.0.2'
|
||||
- 'ilammy/msvc-dev-cmd@v1.13.0'
|
||||
'.github/workflows/build.yml':
|
||||
- 'actions/cache@v6.1.0'
|
||||
- 'actions/checkout@v7.0.1'
|
||||
- 'actions/download-artifact@v8.0.2'
|
||||
- 'actions/setup-node@v7.1.0'
|
||||
- 'actions/upload-artifact@v7.0.2'
|
||||
- 'ilammy/msvc-dev-cmd@v1.13.0'
|
||||
- 'softprops/action-gh-release@v2.6.2'
|
||||
'.github/workflows/grokbot-issue-relay.yml': []
|
||||
'.github/workflows/issue-format.yml':
|
||||
- 'actions/checkout@v7.0.1'
|
||||
- 'actions/github-script@v9.0.0'
|
||||
'.github/workflows/spam-comments.yml':
|
||||
- 'actions/checkout@v7.0.1'
|
||||
- 'actions/github-script@v9.0.0'
|
||||
'.github/workflows/star-history.yml':
|
||||
- 'actions/checkout@v7.0.1'
|
||||
'.github/workflows/test.yml':
|
||||
- 'actions/checkout@v7.0.1'
|
||||
- 'actions/setup-node@v7.1.0'
|
||||
dependencies:
|
||||
'actions/cache@v6.1.0':
|
||||
ref: 'v6.1.0'
|
||||
commit: 'sha1-55cc8345863c7cc4c66a329aec7e433d2d1c52a9'
|
||||
owner_id: 44036562
|
||||
repo_id: 215566462
|
||||
'actions/checkout@v7.0.1':
|
||||
ref: 'v7.0.1'
|
||||
commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1'
|
||||
owner_id: 44036562
|
||||
repo_id: 197814629
|
||||
'actions/download-artifact@v8.0.2':
|
||||
ref: 'v8.0.2'
|
||||
commit: 'sha1-9000827ccba6bdab643e8b6fd33ac0654aef8333'
|
||||
owner_id: 44036562
|
||||
repo_id: 192626254
|
||||
'actions/github-script@v9.0.0':
|
||||
ref: 'v9.0.0'
|
||||
commit: 'sha1-3a2844b7e9c422d3c10d287c895573f7108da1b3'
|
||||
owner_id: 44036562
|
||||
repo_id: 205262760
|
||||
'actions/setup-node@v7.1.0':
|
||||
ref: 'v7.1.0'
|
||||
commit: 'sha1-949feb2413d6458794dcd2491c4babbbce0c15c1'
|
||||
owner_id: 44036562
|
||||
repo_id: 189476904
|
||||
'actions/upload-artifact@v7.0.2':
|
||||
ref: 'v7.0.2'
|
||||
commit: 'sha1-cf430e030ddbb5b0abf93d22962f4752f3646cd9'
|
||||
owner_id: 44036562
|
||||
repo_id: 192625955
|
||||
'ilammy/msvc-dev-cmd@v1.13.0':
|
||||
ref: 'v1.13.0'
|
||||
commit: 'sha1-0b201ec74fa43914dc39ae48a89fd1d8cb592756'
|
||||
owner_id: 1256587
|
||||
repo_id: 212181767
|
||||
'softprops/action-gh-release@v2.6.2':
|
||||
ref: 'v2.6.2'
|
||||
commit: 'sha1-3bb12739c298aeb8a4eeaf626c5b8d85266b0e65'
|
||||
owner_id: 2242
|
||||
repo_id: 204253808
|
||||
@@ -48,6 +48,9 @@ concurrency:
|
||||
group: build-et-binaries-${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
ET_REF: ${{ inputs.et_ref || 'et-v6.2.10' }}
|
||||
|
||||
@@ -59,17 +62,19 @@ jobs:
|
||||
name: build-linux-x64
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Restore cached PR build
|
||||
id: et-build-cache
|
||||
if: github.event_name == 'pull_request'
|
||||
uses: actions/cache@v6
|
||||
uses: actions/cache@v6.1.0
|
||||
with:
|
||||
path: out/
|
||||
key: et-pr-build-v1-${{ runner.os }}-${{ runner.arch }}-${{ env.ET_REF }}-${{ hashFiles('.github/workflows/build-et-binaries.yml', 'scripts/build-et/**') }}
|
||||
- name: Restore vcpkg download cache
|
||||
if: github.event_name != 'pull_request' || steps.et-build-cache.outputs.cache-hit != 'true'
|
||||
uses: actions/cache@v6
|
||||
uses: actions/cache@v6.1.0
|
||||
with:
|
||||
path: .cache/vcpkg-downloads
|
||||
key: vcpkg-downloads-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('scripts/build-et/**') }}
|
||||
@@ -102,7 +107,7 @@ jobs:
|
||||
quay.io/pypa/manylinux2014_x86_64 \
|
||||
bash scripts/build-et/build-linux.sh
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v7.0.2
|
||||
with:
|
||||
name: et-linux-x64
|
||||
path: out/
|
||||
@@ -112,17 +117,19 @@ jobs:
|
||||
name: build-linux-arm64
|
||||
runs-on: ubuntu-24.04-arm
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Restore cached PR build
|
||||
id: et-build-cache
|
||||
if: github.event_name == 'pull_request'
|
||||
uses: actions/cache@v6
|
||||
uses: actions/cache@v6.1.0
|
||||
with:
|
||||
path: out/
|
||||
key: et-pr-build-v1-${{ runner.os }}-${{ runner.arch }}-${{ env.ET_REF }}-${{ hashFiles('.github/workflows/build-et-binaries.yml', 'scripts/build-et/**') }}
|
||||
- name: Restore vcpkg download cache
|
||||
if: github.event_name != 'pull_request' || steps.et-build-cache.outputs.cache-hit != 'true'
|
||||
uses: actions/cache@v6
|
||||
uses: actions/cache@v6.1.0
|
||||
with:
|
||||
path: .cache/vcpkg-downloads
|
||||
key: vcpkg-downloads-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('scripts/build-et/**') }}
|
||||
@@ -155,7 +162,7 @@ jobs:
|
||||
quay.io/pypa/manylinux2014_aarch64 \
|
||||
bash scripts/build-et/build-linux.sh
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v7.0.2
|
||||
with:
|
||||
name: et-linux-arm64
|
||||
path: out/
|
||||
@@ -168,17 +175,19 @@ jobs:
|
||||
name: build-macos-universal
|
||||
runs-on: macos-15
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Restore cached PR build
|
||||
id: et-build-cache
|
||||
if: github.event_name == 'pull_request'
|
||||
uses: actions/cache@v6
|
||||
uses: actions/cache@v6.1.0
|
||||
with:
|
||||
path: out/
|
||||
key: et-pr-build-v1-${{ runner.os }}-${{ runner.arch }}-${{ env.ET_REF }}-${{ hashFiles('.github/workflows/build-et-binaries.yml', 'scripts/build-et/**') }}
|
||||
- name: Restore vcpkg download cache
|
||||
if: github.event_name != 'pull_request' || steps.et-build-cache.outputs.cache-hit != 'true'
|
||||
uses: actions/cache@v6
|
||||
uses: actions/cache@v6.1.0
|
||||
with:
|
||||
path: ${{ runner.temp }}/vcpkg-downloads
|
||||
key: vcpkg-downloads-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('scripts/build-et/**') }}
|
||||
@@ -196,7 +205,7 @@ jobs:
|
||||
MACOSX_DEPLOYMENT_TARGET: "11.0"
|
||||
run: bash scripts/build-et/build-macos.sh
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v7.0.2
|
||||
with:
|
||||
name: et-darwin-universal
|
||||
path: out/
|
||||
@@ -209,17 +218,19 @@ jobs:
|
||||
name: build-windows-x64
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Restore cached PR build
|
||||
id: et-build-cache
|
||||
if: github.event_name == 'pull_request'
|
||||
uses: actions/cache@v6
|
||||
uses: actions/cache@v6.1.0
|
||||
with:
|
||||
path: out/
|
||||
key: et-pr-build-v1-${{ runner.os }}-${{ runner.arch }}-${{ env.ET_REF }}-${{ hashFiles('.github/workflows/build-et-binaries.yml', 'scripts/build-et/**') }}
|
||||
- name: Restore vcpkg download cache
|
||||
if: github.event_name != 'pull_request' || steps.et-build-cache.outputs.cache-hit != 'true'
|
||||
uses: actions/cache@v6
|
||||
uses: actions/cache@v6.1.0
|
||||
with:
|
||||
path: ${{ runner.temp }}\vcpkg-downloads
|
||||
key: vcpkg-downloads-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('scripts/build-et/**') }}
|
||||
@@ -236,7 +247,7 @@ jobs:
|
||||
run: choco install -y ninja
|
||||
- name: Set up MSVC developer command prompt
|
||||
if: github.event_name != 'pull_request' || steps.et-build-cache.outputs.cache-hit != 'true'
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
uses: ilammy/msvc-dev-cmd@v1.13.0
|
||||
with:
|
||||
arch: x64
|
||||
- name: Build et (win32-x64)
|
||||
@@ -247,7 +258,7 @@ jobs:
|
||||
shell: pwsh
|
||||
run: pwsh -File scripts/build-et/build-windows.ps1
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v7.0.2
|
||||
with:
|
||||
name: et-win32-x64
|
||||
path: out/
|
||||
@@ -272,9 +283,11 @@ jobs:
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v8.0.2
|
||||
with:
|
||||
path: artifacts
|
||||
- name: Stage release files
|
||||
|
||||
+36
-22
@@ -119,7 +119,9 @@ jobs:
|
||||
mosh_bin_release: ${{ steps.resolve.outputs.mosh_bin_release }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Resolve bundled mosh-client release
|
||||
id: resolve
|
||||
@@ -146,7 +148,9 @@ jobs:
|
||||
et_bin_release: ${{ steps.resolve.outputs.et_bin_release }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Resolve bundled et-client release
|
||||
id: resolve
|
||||
@@ -214,22 +218,24 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v7
|
||||
uses: actions/setup-node@v7.1.0
|
||||
with:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
|
||||
- name: Set up MSVC developer command prompt
|
||||
if: matrix.name == 'windows'
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
uses: ilammy/msvc-dev-cmd@v1.13.0
|
||||
with:
|
||||
arch: x64
|
||||
|
||||
- name: Restore Electron download cache
|
||||
uses: actions/cache@v6
|
||||
uses: actions/cache@v6.1.0
|
||||
with:
|
||||
path: |
|
||||
~/.cache/electron
|
||||
@@ -293,7 +299,7 @@ jobs:
|
||||
run: npm run ${{ matrix.pack_script }}
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v7.0.2
|
||||
with:
|
||||
name: netcatty-${{ matrix.name }}
|
||||
path: |
|
||||
@@ -333,7 +339,7 @@ jobs:
|
||||
# The GitHub runner already retries container pulls three times. Use the
|
||||
# official Quay mirror to avoid the Docker Hub endpoint that repeatedly
|
||||
# timed out in package validation.
|
||||
image: quay.io/almalinuxorg/almalinux:8
|
||||
image: quay.io/almalinuxorg/almalinux:8.10-20261114@sha256:e85b75cd6ce05cd1e7616d4b2590077e0acc395e7ee73a9f887b17d1591b6ef3
|
||||
env:
|
||||
MOSH_BIN_RELEASE: ${{ needs.resolve-mosh.outputs.mosh_bin_release }}
|
||||
ET_BIN_RELEASE: ${{ needs.resolve-et.outputs.et_bin_release }}
|
||||
@@ -517,10 +523,12 @@ jobs:
|
||||
echo "npm_config_python=/usr/bin/python3.11" >> "${GITHUB_ENV}"
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Restore Electron download cache
|
||||
uses: actions/cache@v6
|
||||
uses: actions/cache@v6.1.0
|
||||
with:
|
||||
path: |
|
||||
~/.cache/electron
|
||||
@@ -594,7 +602,7 @@ jobs:
|
||||
run: bash scripts/verify-linux-rpm-artifact.sh x86_64
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v7.0.2
|
||||
with:
|
||||
name: netcatty-linux-x64
|
||||
path: |
|
||||
@@ -618,7 +626,7 @@ jobs:
|
||||
&& (needs.resolve-et.result == 'success' || needs.resolve-et.result == 'skipped')
|
||||
runs-on: ubuntu-24.04-arm
|
||||
container:
|
||||
image: debian:bullseye
|
||||
image: debian:bullseye-20260824@sha256:6f519a81440354a85eb592c5f32109ab80605f6b892455983a6f618bf87fabe9
|
||||
env:
|
||||
MOSH_BIN_RELEASE: ${{ needs.resolve-mosh.outputs.mosh_bin_release }}
|
||||
ET_BIN_RELEASE: ${{ needs.resolve-et.outputs.et_bin_release }}
|
||||
@@ -670,10 +678,12 @@ jobs:
|
||||
apt-get -o Acquire::Retries=4 install -y nodejs
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Restore Electron download cache
|
||||
uses: actions/cache@v6
|
||||
uses: actions/cache@v6.1.0
|
||||
with:
|
||||
path: |
|
||||
~/.cache/electron
|
||||
@@ -728,7 +738,7 @@ jobs:
|
||||
run: bash scripts/verify-linux-rpm-artifact.sh aarch64
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v7.0.2
|
||||
with:
|
||||
name: netcatty-linux-arm64
|
||||
path: |
|
||||
@@ -755,7 +765,9 @@ jobs:
|
||||
actions: read
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Validate release tag
|
||||
shell: bash
|
||||
@@ -766,7 +778,7 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v8.0.2
|
||||
with:
|
||||
path: artifacts
|
||||
merge-multiple: true
|
||||
@@ -816,7 +828,7 @@ jobs:
|
||||
GITHUB_SHA: ${{ github.sha }}
|
||||
|
||||
- name: Create GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
uses: softprops/action-gh-release@v2.6.2
|
||||
with:
|
||||
body_path: release_notes.md
|
||||
prerelease: ${{ contains(github.ref_name, '-') }}
|
||||
@@ -848,13 +860,13 @@ jobs:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Checkout default branch
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
ref: ${{ github.event.repository.default_branch }}
|
||||
token: ${{ secrets.RELEASE_TOKEN }}
|
||||
|
||||
- name: Download Linux artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v8.0.2
|
||||
with:
|
||||
path: artifacts
|
||||
merge-multiple: true
|
||||
@@ -1010,10 +1022,12 @@ jobs:
|
||||
&& (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.publish_release))
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Download macOS artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v8.0.2
|
||||
with:
|
||||
name: netcatty-macos
|
||||
path: artifacts/
|
||||
|
||||
@@ -17,14 +17,15 @@ jobs:
|
||||
!contains(github.event.issue.labels.*.name, 'format-exempt')
|
||||
steps:
|
||||
- name: Checkout format helpers
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
sparse-checkout: |
|
||||
scripts/issue-format.cjs
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Validate title and body
|
||||
uses: actions/github-script@v9
|
||||
uses: actions/github-script@v9.0.0
|
||||
with:
|
||||
script: |
|
||||
const format = require(`${process.env.GITHUB_WORKSPACE}/scripts/issue-format.cjs`);
|
||||
|
||||
@@ -14,10 +14,12 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout filter rules
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Hide suspected malware spam
|
||||
uses: actions/github-script@v9
|
||||
uses: actions/github-script@v9.0.0
|
||||
with:
|
||||
script: |
|
||||
const path = require('node:path');
|
||||
|
||||
@@ -15,7 +15,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
# Same PAT used for releases — needs stargazers read (admin/collaborator)
|
||||
# plus contents/PR write so we can open an update PR against protected main.
|
||||
|
||||
@@ -20,10 +20,12 @@ jobs:
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v7
|
||||
uses: actions/setup-node@v7.1.0
|
||||
with:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
|
||||
@@ -1149,6 +1149,7 @@ export const enVaultMessages: Messages = {
|
||||
'hostDetails.rdp.resolutionMode.fixed': 'Fixed Size',
|
||||
'hostDetails.rdp.width': 'Width',
|
||||
'hostDetails.rdp.height': 'Height',
|
||||
'hostDetails.rdp.dimensionHint': 'Enter a whole number from 200 to 8192.',
|
||||
'hostDetails.rdp.colorDepth': 'Color Depth',
|
||||
'hostDetails.rdp.audio': 'Audio Output',
|
||||
'hostDetails.rdp.audioDesc': 'Play remote desktop sound locally',
|
||||
@@ -1262,6 +1263,9 @@ export const enVaultMessages: Messages = {
|
||||
'remoteDesktop.toolbar.display': 'Display Scaling',
|
||||
'remoteDesktop.toolbar.sshTunneled': 'Tunneled over SSH',
|
||||
'remoteDesktop.toolbar.encrypted': 'Encrypted TLS connection',
|
||||
'remoteDesktop.toolbar.standardRdpSecurity': 'Standard RDP Security ({{cipher}})',
|
||||
'remoteDesktop.rdp.fallbackStandardRdp': 'Connected using Standard RDP Security.',
|
||||
'remoteDesktop.rdp.fallbackStandardRdpWithCipher': 'Connected using Standard RDP Security ({{cipher}}).',
|
||||
'remoteDesktop.toolbar.viewOnly': 'View-Only Mode',
|
||||
'remoteDesktop.toolbar.viewOnlyBadge': 'View',
|
||||
'remoteDesktop.toolbar.audio': 'RDP Audio',
|
||||
|
||||
@@ -1151,6 +1151,7 @@ export const esVaultMessages: Messages = {
|
||||
'hostDetails.rdp.resolutionMode.fixed': 'Tamaño fijo',
|
||||
'hostDetails.rdp.width': 'Ancho',
|
||||
'hostDetails.rdp.height': 'Alto',
|
||||
'hostDetails.rdp.dimensionHint': 'Introduce un número entero entre 200 y 8192.',
|
||||
'hostDetails.rdp.colorDepth': 'Profundidad de color',
|
||||
'hostDetails.rdp.audio': 'Salida de audio',
|
||||
'hostDetails.rdp.audioDesc': 'Reproducir el audio del escritorio remoto localmente',
|
||||
@@ -1264,6 +1265,9 @@ export const esVaultMessages: Messages = {
|
||||
'remoteDesktop.toolbar.display': 'Escala de pantalla',
|
||||
'remoteDesktop.toolbar.sshTunneled': 'Tunelizado por SSH',
|
||||
'remoteDesktop.toolbar.encrypted': 'Conexión TLS cifrada',
|
||||
'remoteDesktop.toolbar.standardRdpSecurity': 'Seguridad RDP estándar ({{cipher}})',
|
||||
'remoteDesktop.rdp.fallbackStandardRdp': 'Conectado con seguridad RDP estándar.',
|
||||
'remoteDesktop.rdp.fallbackStandardRdpWithCipher': 'Conectado con seguridad RDP estándar ({{cipher}}).',
|
||||
'remoteDesktop.toolbar.viewOnly': 'Modo solo lectura',
|
||||
'remoteDesktop.toolbar.viewOnlyBadge': 'Ver',
|
||||
'remoteDesktop.toolbar.audio': 'Audio RDP',
|
||||
|
||||
@@ -134,3 +134,9 @@ test("every locale outside the pending list is at full parity with en", () => {
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("every locale explains the fixed RDP dimension limits", () => {
|
||||
for (const messages of [en, es, ru, zhCN, zhTW]) {
|
||||
assert.match(messages["hostDetails.rdp.dimensionHint"] ?? "", /200.*8192/);
|
||||
}
|
||||
});
|
||||
@@ -1167,6 +1167,7 @@ export const ruVaultMessages: Messages = {
|
||||
'hostDetails.rdp.resolutionMode.fixed': 'Фиксированный размер',
|
||||
'hostDetails.rdp.width': 'Ширина',
|
||||
'hostDetails.rdp.height': 'Высота',
|
||||
'hostDetails.rdp.dimensionHint': 'Введите целое число от 200 до 8192.',
|
||||
'hostDetails.rdp.colorDepth': 'Глубина цвета',
|
||||
'hostDetails.rdp.audio': 'Вывод звука',
|
||||
'hostDetails.rdp.audioDesc': 'Воспроизводить звук удалённого рабочего стола локально',
|
||||
@@ -1280,6 +1281,9 @@ export const ruVaultMessages: Messages = {
|
||||
'remoteDesktop.toolbar.display': 'Масштаб экрана',
|
||||
'remoteDesktop.toolbar.sshTunneled': 'Туннель через SSH',
|
||||
'remoteDesktop.toolbar.encrypted': 'Шифрованное TLS-соединение',
|
||||
'remoteDesktop.toolbar.standardRdpSecurity': 'Стандартная безопасность RDP ({{cipher}})',
|
||||
'remoteDesktop.rdp.fallbackStandardRdp': 'Подключено через стандартную безопасность RDP.',
|
||||
'remoteDesktop.rdp.fallbackStandardRdpWithCipher': 'Подключено через стандартную безопасность RDP ({{cipher}}).',
|
||||
'remoteDesktop.toolbar.viewOnly': 'Режим «Только просмотр»',
|
||||
'remoteDesktop.toolbar.viewOnlyBadge': 'Просмотр',
|
||||
'remoteDesktop.toolbar.audio': 'Звук RDP',
|
||||
|
||||
@@ -1113,6 +1113,7 @@ export const zhCNVaultMessages: Messages = {
|
||||
'hostDetails.rdp.resolutionMode.fixed': '固定尺寸',
|
||||
'hostDetails.rdp.width': '宽度',
|
||||
'hostDetails.rdp.height': '高度',
|
||||
'hostDetails.rdp.dimensionHint': '请输入 200 到 8192 之间的整数。',
|
||||
'hostDetails.rdp.colorDepth': '色深',
|
||||
'hostDetails.rdp.audio': '音频输出',
|
||||
'hostDetails.rdp.audioDesc': '在本地播放远程桌面声音',
|
||||
@@ -1226,6 +1227,9 @@ export const zhCNVaultMessages: Messages = {
|
||||
'remoteDesktop.toolbar.display': '显示缩放',
|
||||
'remoteDesktop.toolbar.sshTunneled': '通过 SSH 隧道加密转发',
|
||||
'remoteDesktop.toolbar.encrypted': 'TLS 加密连接',
|
||||
'remoteDesktop.toolbar.standardRdpSecurity': '标准 RDP 安全层({{cipher}})',
|
||||
'remoteDesktop.rdp.fallbackStandardRdp': '已回退并使用标准 RDP 安全层连接。',
|
||||
'remoteDesktop.rdp.fallbackStandardRdpWithCipher': '已回退并使用标准 RDP 安全层连接({{cipher}})。',
|
||||
'remoteDesktop.toolbar.viewOnly': '只读模式',
|
||||
'remoteDesktop.toolbar.viewOnlyBadge': '只读',
|
||||
'remoteDesktop.toolbar.audio': 'RDP 音频',
|
||||
|
||||
@@ -1113,6 +1113,7 @@ export const zhTWVaultMessages: Messages = {
|
||||
'hostDetails.rdp.resolutionMode.fixed': '固定尺寸',
|
||||
'hostDetails.rdp.width': '寬度',
|
||||
'hostDetails.rdp.height': '高度',
|
||||
'hostDetails.rdp.dimensionHint': '請輸入 200 到 8192 之間的整數。',
|
||||
'hostDetails.rdp.colorDepth': '色彩深度',
|
||||
'hostDetails.rdp.audio': '音訊輸出',
|
||||
'hostDetails.rdp.audioDesc': '在本機播放遠端桌面音效',
|
||||
@@ -1254,6 +1255,9 @@ export const zhTWVaultMessages: Messages = {
|
||||
'remoteDesktop.toolbar.display': '顯示縮放',
|
||||
'remoteDesktop.toolbar.sshTunneled': '透過 SSH 通道連線',
|
||||
'remoteDesktop.toolbar.encrypted': 'TLS 加密連線',
|
||||
'remoteDesktop.toolbar.standardRdpSecurity': '標準 RDP 安全層({{cipher}})',
|
||||
'remoteDesktop.rdp.fallbackStandardRdp': '已回退並使用標準 RDP 安全層連線。',
|
||||
'remoteDesktop.rdp.fallbackStandardRdpWithCipher': '已回退並使用標準 RDP 安全層連線({{cipher}})。',
|
||||
'remoteDesktop.toolbar.viewOnly': '唯讀檢視模式',
|
||||
'remoteDesktop.toolbar.viewOnlyBadge': '檢視',
|
||||
'remoteDesktop.toolbar.audio': 'RDP 音訊',
|
||||
|
||||
@@ -132,6 +132,8 @@ export const HostDetailsConnectionSections: React.FC<HostDetailsConnectionSectio
|
||||
onCreateIdentity,
|
||||
companionCredentialDrafts,
|
||||
onCompanionCredentialDraftChange,
|
||||
resolutionDraft,
|
||||
onResolutionDraftChange,
|
||||
effectiveTelnetPort,
|
||||
effectiveTelnetUsername,
|
||||
effectiveTelnetPassword,
|
||||
@@ -395,6 +397,8 @@ export const HostDetailsConnectionSections: React.FC<HostDetailsConnectionSectio
|
||||
identities={identities}
|
||||
availableKeys={availableKeys}
|
||||
onCreateIdentity={onCreateIdentity}
|
||||
resolutionDraft={resolutionDraft}
|
||||
onResolutionDraftChange={onResolutionDraftChange}
|
||||
credentialDraft={companionCredentialDrafts?.rdp}
|
||||
onCredentialDraftChange={(draft) => onCompanionCredentialDraftChange?.("rdp", draft)}
|
||||
t={t}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import React from "react";
|
||||
import { act, create, type ReactTestRenderer } from "react-test-renderer";
|
||||
import { I18nProvider } from "../application/i18n/I18nProvider";
|
||||
import type { Host } from "../types";
|
||||
import HostDetailsPanel from "./HostDetailsPanel";
|
||||
import { installDomEnvironment } from "./test-support/renderReactDom";
|
||||
import { Button } from "./ui/button";
|
||||
import { Input } from "./ui/input";
|
||||
import { Select } from "./ui/select";
|
||||
import { TooltipProvider } from "./ui/tooltip";
|
||||
|
||||
for (const kind of ["standalone", "companion", "new"] as const) {
|
||||
test(`${kind} RDP keeps invalid resolution drafts visible and blocks saving`, async () => {
|
||||
const dom = installDomEnvironment();
|
||||
const previousRaf = globalThis.requestAnimationFrame;
|
||||
const previousCancelRaf = globalThis.cancelAnimationFrame;
|
||||
globalThis.requestAnimationFrame = (callback) => setTimeout(() => callback(0), 0) as unknown as number;
|
||||
globalThis.cancelAnimationFrame = (id) => clearTimeout(id);
|
||||
let renderer: ReactTestRenderer | undefined;
|
||||
const saved: Host[] = [];
|
||||
const host: Host = {
|
||||
id: "rdp-host", label: "Desktop", hostname: "desktop.example.com",
|
||||
username: "root", password: "password", authMethod: "password",
|
||||
protocol: kind === "companion" ? "ssh" : "rdp", tags: [], os: "windows",
|
||||
rdpConfig: {
|
||||
enabled: true, defaultConnect: true, resolutionMode: "fixed", width: 1920, height: 1080,
|
||||
},
|
||||
};
|
||||
try {
|
||||
await act(async () => {
|
||||
renderer = create(
|
||||
<I18nProvider locale="en"><TooltipProvider>
|
||||
<HostDetailsPanel
|
||||
initialData={kind === "new" ? undefined : host}
|
||||
initialProtocol="rdp"
|
||||
availableKeys={[]} identities={[]} groups={[]}
|
||||
terminalThemeId="default" terminalFontSize={14} layout="inline"
|
||||
onSave={(value) => saved.push(value)} onCancel={() => {}}
|
||||
/>
|
||||
</TooltipProvider></I18nProvider>,
|
||||
);
|
||||
});
|
||||
if (kind === "new") {
|
||||
await act(async () => {
|
||||
const hostname = renderer!.root.findAllByType(Input).find((input) =>
|
||||
input.props.placeholder === "IP or Hostname");
|
||||
assert.ok(hostname);
|
||||
hostname.props.onChange({ target: { value: host.hostname } });
|
||||
const mode = renderer!.root.findAllByType(Select).find((select) => select.props.value === "dynamic");
|
||||
assert.ok(mode);
|
||||
mode.props.onValueChange("fixed");
|
||||
});
|
||||
}
|
||||
const input = (dimension: string) => renderer!.root.findAllByType(Input).find((field) =>
|
||||
field.props.id?.endsWith(`-${dimension}`))!;
|
||||
const change = async (dimension: string, value: string) => {
|
||||
await act(async () => { input(dimension).props.onChange({ target: { value } }); });
|
||||
};
|
||||
const save = async () => {
|
||||
await act(async () => {
|
||||
const button = renderer!.root.findAllByType(Button).find((item) => item.props["aria-label"] === "Save");
|
||||
assert.ok(button);
|
||||
await button.props.onClick();
|
||||
});
|
||||
};
|
||||
assert.equal(input("width").props.value, "1920");
|
||||
for (const value of ["192", "19", "", "199", "8193", "3840.5", "abc"]) {
|
||||
await change("width", value);
|
||||
assert.equal(input("width").props.value, value);
|
||||
assert.equal(input("width").props["aria-invalid"], true);
|
||||
assert.match(JSON.stringify(renderer!.toJSON()), /Enter a whole number from 200 to 8192/);
|
||||
await save();
|
||||
assert.equal(saved.length, 0);
|
||||
assert.equal(input("width").props.value, value, "save must preserve the invalid draft");
|
||||
}
|
||||
await change("width", "3840");
|
||||
assert.equal(input("width").props.value, "3840");
|
||||
assert.equal(input("width").props["aria-invalid"], false);
|
||||
await change("height", "192");
|
||||
await save();
|
||||
assert.equal(saved.length, 0);
|
||||
assert.equal(input("height").props.value, "192");
|
||||
await change("height", "2160");
|
||||
await save();
|
||||
assert.equal(saved.length, 1);
|
||||
assert.equal(saved[0].rdpConfig?.width, 3840);
|
||||
assert.equal(saved[0].rdpConfig?.height, 2160);
|
||||
} finally {
|
||||
if (renderer) await act(async () => { renderer!.unmount(); });
|
||||
globalThis.requestAnimationFrame = previousRaf;
|
||||
globalThis.cancelAnimationFrame = previousCancelRaf;
|
||||
dom.cleanup();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -87,11 +87,13 @@ import {
|
||||
DEFAULT_VNC_CONFIG,
|
||||
DEFAULT_VNC_PORT,
|
||||
getHostEnabledProtocols,
|
||||
hasValidRdpFixedResolution,
|
||||
isRemoteDesktopProtocol,
|
||||
resolveHostDefaultConnectProtocol,
|
||||
sanitizeRdpConfig,
|
||||
sanitizeVncConfig,
|
||||
shouldPromptHostProtocolOnConnect,
|
||||
type RdpResolutionDraft,
|
||||
} from "../domain/remoteDesktop";
|
||||
import { PluginConnectionSection } from "./PluginConnectionSection";
|
||||
import { useHostConnectionTest } from "../application/state/useHostConnectionTest";
|
||||
@@ -248,6 +250,15 @@ const HostDetailsPanel: React.FC<HostDetailsPanelPropsWithResize> = ({
|
||||
},
|
||||
);
|
||||
|
||||
const hasRdpConfig = Boolean(form.rdpConfig);
|
||||
const [resolutionDraft, setResolutionDraft] = useState<RdpResolutionDraft>({});
|
||||
useEffect(() => {
|
||||
setResolutionDraft({});
|
||||
}, [form.id, hasRdpConfig]);
|
||||
const onResolutionDraftChange = (dimension: "width" | "height", value: string) => {
|
||||
setResolutionDraft((prev) => ({ ...prev, [dimension]: value }));
|
||||
};
|
||||
|
||||
const [activeSubPanel, setActiveSubPanel] = useState<SubPanel>("none");
|
||||
|
||||
const [credentialPopoverOpen, setCredentialPopoverOpen] = useState(false);
|
||||
@@ -909,6 +920,12 @@ const HostDetailsPanel: React.FC<HostDetailsPanelPropsWithResize> = ({
|
||||
if (savingHostRef.current) return;
|
||||
savingHostRef.current = true;
|
||||
try {
|
||||
if (!pluginProtocolActive && (form.protocol === "rdp" || form.rdpConfig?.enabled)
|
||||
&& !hasValidRdpFixedResolution(form.rdpConfig, resolutionDraft)) {
|
||||
setActiveProtocolTab("rdp");
|
||||
toast.error(t("hostDetails.rdp.dimensionHint"));
|
||||
return;
|
||||
}
|
||||
const flushed = isRemoteDesktopPrimary ? undefined : await totpFlushRef.current?.();
|
||||
if (flushed && !flushed.ok) return;
|
||||
const hostname = form.hostname.trim()
|
||||
@@ -1626,6 +1643,8 @@ const HostDetailsPanel: React.FC<HostDetailsPanelPropsWithResize> = ({
|
||||
t={t}
|
||||
form={form}
|
||||
setForm={setForm}
|
||||
resolutionDraft={resolutionDraft}
|
||||
onResolutionDraftChange={onResolutionDraftChange}
|
||||
totpFlushRef={totpFlushRef}
|
||||
update={update}
|
||||
groupDefaults={effectiveGroupDefaults}
|
||||
@@ -1689,6 +1708,8 @@ const HostDetailsPanel: React.FC<HostDetailsPanelPropsWithResize> = ({
|
||||
|
||||
{isRemoteDesktopPrimary && isCurrentTabEnabled && (activeProtocolTab === "rdp" || activeProtocolTab === "vnc") ? (
|
||||
<RemoteDesktopOptionsSection
|
||||
resolutionDraft={resolutionDraft}
|
||||
onResolutionDraftChange={onResolutionDraftChange}
|
||||
form={form}
|
||||
setForm={setForm}
|
||||
t={t}
|
||||
|
||||
@@ -48,6 +48,7 @@ import { Switch } from "../ui/switch";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip";
|
||||
import { HostDetailsSettingRow } from "./HostDetailsSection";
|
||||
import { IdentitySuggestInput } from "./IdentitySuggestInput";
|
||||
import { RdpResolutionFields, type RdpResolutionDraftProps } from "./RdpResolutionFields";
|
||||
|
||||
type Translate = (key: string, params?: Record<string, unknown>) => string;
|
||||
|
||||
@@ -65,7 +66,7 @@ interface CompanionRemoteDesktopSectionsProps {
|
||||
t: Translate;
|
||||
}
|
||||
|
||||
interface CompanionRemoteDesktopInlineFieldsProps extends CompanionRemoteDesktopSectionsProps {
|
||||
interface CompanionRemoteDesktopInlineFieldsProps extends CompanionRemoteDesktopSectionsProps, RdpResolutionDraftProps {
|
||||
protocol: "vnc" | "rdp";
|
||||
credentialDraft?: CompanionCredentialDraft;
|
||||
onCredentialDraftChange?: (draft: CompanionCredentialDraft | undefined) => void;
|
||||
@@ -83,6 +84,8 @@ export const CompanionRemoteDesktopInlineFields: React.FC<CompanionRemoteDesktop
|
||||
availableKeys = [],
|
||||
credentialDraft,
|
||||
onCredentialDraftChange,
|
||||
resolutionDraft,
|
||||
onResolutionDraftChange,
|
||||
t,
|
||||
}) => {
|
||||
const [vncPortInput, setVncPortInput] = useState<string>(() =>
|
||||
@@ -543,6 +546,16 @@ export const CompanionRemoteDesktopInlineFields: React.FC<CompanionRemoteDesktop
|
||||
</Select>
|
||||
</HostDetailsSettingRow>
|
||||
|
||||
{rdpNormalized.resolutionMode === "fixed" && (
|
||||
<RdpResolutionFields
|
||||
form={form}
|
||||
setForm={setForm}
|
||||
t={t}
|
||||
resolutionDraft={resolutionDraft}
|
||||
onResolutionDraftChange={onResolutionDraftChange}
|
||||
/>
|
||||
)}
|
||||
|
||||
<HostDetailsSettingRow
|
||||
icon={<ShieldCheck />}
|
||||
label={t("hostDetails.rdp.securityMode")}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
import React, { useId, useState } from "react";
|
||||
import {
|
||||
DEFAULT_RDP_HEIGHT,
|
||||
DEFAULT_RDP_WIDTH,
|
||||
parseRdpDimensionDraft,
|
||||
type RdpResolutionDraft,
|
||||
} from "../../domain/remoteDesktop";
|
||||
import type { Host } from "../../types";
|
||||
import { Input } from "../ui/input";
|
||||
|
||||
export interface RdpResolutionDraftProps {
|
||||
resolutionDraft?: RdpResolutionDraft;
|
||||
onResolutionDraftChange?: (dimension: "width" | "height", value: string) => void;
|
||||
}
|
||||
|
||||
interface RdpResolutionFieldsProps extends RdpResolutionDraftProps {
|
||||
form: Host;
|
||||
setForm: React.Dispatch<React.SetStateAction<Host>>;
|
||||
t: (key: string) => string;
|
||||
}
|
||||
|
||||
export const RdpResolutionFields: React.FC<RdpResolutionFieldsProps> = ({
|
||||
form, setForm, t, resolutionDraft, onResolutionDraftChange,
|
||||
}) => {
|
||||
const [localDraft, setLocalDraft] = useState<RdpResolutionDraft>({});
|
||||
const id = useId();
|
||||
const draft = resolutionDraft ?? localDraft;
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
{(["width", "height"] as const).map((dimension) => {
|
||||
const value = draft[dimension] ?? String(form.rdpConfig?.[dimension]
|
||||
?? (dimension === "width" ? DEFAULT_RDP_WIDTH : DEFAULT_RDP_HEIGHT));
|
||||
const invalid = parseRdpDimensionDraft(value) === undefined;
|
||||
const inputId = `${id}-${dimension}`;
|
||||
return (
|
||||
<div key={dimension} className="space-y-1">
|
||||
<div className="flex items-center justify-between gap-2 bg-transparent px-1 h-10">
|
||||
<label htmlFor={inputId} className="text-sm font-medium text-foreground shrink-0">
|
||||
{t(`hostDetails.rdp.${dimension}`)}
|
||||
</label>
|
||||
<Input
|
||||
id={inputId}
|
||||
type="text"
|
||||
inputMode="numeric"
|
||||
value={value}
|
||||
aria-invalid={invalid}
|
||||
aria-describedby={invalid ? `${inputId}-hint` : undefined}
|
||||
onChange={(e) => {
|
||||
const next = e.target.value;
|
||||
if (onResolutionDraftChange) onResolutionDraftChange(dimension, next);
|
||||
else setLocalDraft((prev) => ({ ...prev, [dimension]: next }));
|
||||
const parsed = parseRdpDimensionDraft(next);
|
||||
if (parsed !== undefined) {
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
rdpConfig: { ...prev.rdpConfig, [dimension]: parsed },
|
||||
}));
|
||||
}
|
||||
}}
|
||||
className="h-8 w-20 text-sm text-center font-mono"
|
||||
/>
|
||||
</div>
|
||||
{invalid && (
|
||||
<p id={`${inputId}-hint`} className="px-1 text-xs text-destructive">
|
||||
{t("hostDetails.rdp.dimensionHint")}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -38,10 +38,11 @@ import { Input } from "../ui/input";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../ui/select";
|
||||
import { Switch } from "../ui/switch";
|
||||
import { HostDetailsSection, HostDetailsSettingRow } from "./HostDetailsSection";
|
||||
import { RdpResolutionFields, type RdpResolutionDraftProps } from "./RdpResolutionFields";
|
||||
|
||||
type Translate = (key: string, params?: Record<string, unknown>) => string;
|
||||
|
||||
interface RemoteDesktopOptionsSectionProps {
|
||||
interface RemoteDesktopOptionsSectionProps extends RdpResolutionDraftProps {
|
||||
form: Host;
|
||||
setForm: React.Dispatch<React.SetStateAction<Host>>;
|
||||
t: Translate;
|
||||
@@ -51,6 +52,8 @@ export const RemoteDesktopOptionsSection: React.FC<RemoteDesktopOptionsSectionPr
|
||||
form,
|
||||
setForm,
|
||||
t,
|
||||
resolutionDraft,
|
||||
onResolutionDraftChange,
|
||||
}) => {
|
||||
const [advancedOpen, setAdvancedOpen] = useState(() =>
|
||||
Boolean(
|
||||
@@ -99,36 +102,13 @@ export const RemoteDesktopOptionsSection: React.FC<RemoteDesktopOptionsSectionPr
|
||||
</HostDetailsSettingRow>
|
||||
|
||||
{rdp.resolutionMode === "fixed" && (
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
<div className="flex items-center justify-between gap-2 bg-transparent px-1 h-10">
|
||||
<span className="text-sm font-medium text-foreground shrink-0">{t("hostDetails.rdp.width")}</span>
|
||||
<Input
|
||||
type="number"
|
||||
min={200}
|
||||
max={8192}
|
||||
value={rdp.width}
|
||||
onChange={(e) => {
|
||||
const n = Number.parseInt(e.target.value, 10);
|
||||
if (Number.isFinite(n)) updateRdp("width", n);
|
||||
}}
|
||||
className="h-8 w-20 text-sm text-center font-mono"
|
||||
/>
|
||||
</div>
|
||||
<div className="flex items-center justify-between gap-2 bg-transparent px-1 h-10">
|
||||
<span className="text-sm font-medium text-foreground shrink-0">{t("hostDetails.rdp.height")}</span>
|
||||
<Input
|
||||
type="number"
|
||||
min={200}
|
||||
max={8192}
|
||||
value={rdp.height}
|
||||
onChange={(e) => {
|
||||
const n = Number.parseInt(e.target.value, 10);
|
||||
if (Number.isFinite(n)) updateRdp("height", n);
|
||||
}}
|
||||
className="h-8 w-20 text-sm text-center font-mono"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<RdpResolutionFields
|
||||
form={form}
|
||||
setForm={setForm}
|
||||
t={t}
|
||||
resolutionDraft={resolutionDraft}
|
||||
onResolutionDraftChange={onResolutionDraftChange}
|
||||
/>
|
||||
)}
|
||||
|
||||
<HostDetailsSettingRow
|
||||
|
||||
@@ -12,10 +12,14 @@ import { useI18n } from '../../application/i18n/I18nProvider';
|
||||
import {
|
||||
computeMonitorVirtualBounds,
|
||||
mapViewportToVirtualDesktopCoords,
|
||||
resolveEffectiveRdpSecurityMode,
|
||||
resolveNextRdpAutoFallback,
|
||||
splitWindowsUserDomain,
|
||||
type MonitorLayoutSpec,
|
||||
type NormalizedRdpConfig,
|
||||
type RdpAutoFallbackStage,
|
||||
type RdpDisplayControlCaps,
|
||||
type RdpNegotiatedSecurityInfo,
|
||||
} from '../../domain/remoteDesktop';
|
||||
import {
|
||||
permilleToFramebufferCoord,
|
||||
@@ -96,7 +100,7 @@ export interface RdpCanvasViewProps {
|
||||
password: string;
|
||||
domain: string;
|
||||
rdpConfig: NormalizedRdpConfig;
|
||||
fallbackDisableCredSsp: boolean;
|
||||
autoFallbackStage: RdpAutoFallbackStage;
|
||||
isVisible: boolean;
|
||||
displayMode: RemoteDesktopDisplayMode;
|
||||
highDpi?: boolean;
|
||||
@@ -113,12 +117,17 @@ export interface RdpCanvasViewProps {
|
||||
onDisplayControlCaps?: (caps: RdpDisplayControlCaps) => void;
|
||||
onFpsChange?: (fps: number) => void;
|
||||
onRequestReleaseGrab: () => void;
|
||||
onConnected: (info: { width: number; height: number; encrypted?: boolean }) => void;
|
||||
onConnected: (info: {
|
||||
width: number;
|
||||
height: number;
|
||||
encrypted?: boolean;
|
||||
securityInfo?: RdpNegotiatedSecurityInfo;
|
||||
}) => void;
|
||||
onDesktopResize: (size: { width: number; height: number }) => void;
|
||||
onRemoteClipboardFilesChange?: (files: RemoteDesktopClipboardFileOffer[]) => void;
|
||||
onClipboardFileTransferStatus?: (status: string | null) => void;
|
||||
onClipboardTransferChange?: (transfer: RemoteDesktopClipboardTransferState | null) => void;
|
||||
onNegotiationFallbackNeeded?: () => void;
|
||||
onNegotiationFallbackNeeded?: (nextStage: Exclude<RdpAutoFallbackStage, 'none'>) => void;
|
||||
onError: (error: { message: string; isAuthError?: boolean; kind?: number }) => void;
|
||||
onDisconnected: (reason?: string) => void;
|
||||
}
|
||||
@@ -143,7 +152,7 @@ export const RdpCanvasView = React.memo(forwardRef<RemoteDesktopCanvasHandle, Rd
|
||||
password,
|
||||
domain,
|
||||
rdpConfig,
|
||||
fallbackDisableCredSsp,
|
||||
autoFallbackStage,
|
||||
isVisible,
|
||||
displayMode,
|
||||
highDpi = true,
|
||||
@@ -967,9 +976,10 @@ export const RdpCanvasView = React.memo(forwardRef<RemoteDesktopCanvasHandle, Rd
|
||||
const { username: cleanUser, domain: cleanDomain } = splitWindowsUserDomain(username, domain);
|
||||
const authToken = extractAuthTokenFromWsUrl(wsUrl);
|
||||
const securityMode = rdpConfig.securityMode ?? 'auto';
|
||||
const enableCredSsp =
|
||||
securityMode === 'nla' || (securityMode === 'auto' && !fallbackDisableCredSsp);
|
||||
const enableStandardRdp = securityMode === 'rdp';
|
||||
const effectiveSecurityMode = resolveEffectiveRdpSecurityMode(securityMode, autoFallbackStage);
|
||||
const enableCredSsp = effectiveSecurityMode === 'nla' || effectiveSecurityMode === 'auto';
|
||||
const enableStandardRdp = effectiveSecurityMode === 'rdp';
|
||||
let negotiatedSecurityInfo: RdpNegotiatedSecurityInfo | null = null;
|
||||
|
||||
const rdpdrSessionId = propsRef.current.sessionId;
|
||||
const bridgeForRdpdr = getRemoteDesktopBridge();
|
||||
@@ -1046,6 +1056,11 @@ export const RdpCanvasView = React.memo(forwardRef<RemoteDesktopCanvasHandle, Rd
|
||||
.extension(new mod.Extension('color_depth', rdpConfig.colorDepth || 32))
|
||||
.extension(new mod.Extension('enable_credssp', enableCredSsp))
|
||||
.extension(new mod.Extension('enable_standard_rdp_security', enableStandardRdp))
|
||||
.extension(
|
||||
new mod.Extension('security_info_callback', (info: RdpNegotiatedSecurityInfo) => {
|
||||
negotiatedSecurityInfo = info;
|
||||
}),
|
||||
)
|
||||
.extension(new mod.Extension('client_name', 'Netcatty'));
|
||||
|
||||
// RDPDR sandboxed local drive redirection (always attach callback so live hotplug works)
|
||||
@@ -1491,14 +1506,16 @@ export const RdpCanvasView = React.memo(forwardRef<RemoteDesktopCanvasHandle, Rd
|
||||
: String(err);
|
||||
|
||||
// CRITICAL: In `auto` mode, if negotiation fails BEFORE credentials are sent,
|
||||
// retry ONCE without CredSSP (pure TLS). NEVER auto-retry on WrongPassword /
|
||||
// step through NLA -> TLS -> Standard RDP. NEVER auto-retry on WrongPassword /
|
||||
// LogonFailure / AccessDenied to prevent Windows NLA account lockout!
|
||||
if (
|
||||
securityMode === 'auto'
|
||||
&& !fallbackDisableCredSsp
|
||||
&& kind === mod.IronErrorKind.NegotiationFailure
|
||||
) {
|
||||
callbacksRef.current.onNegotiationFallbackNeeded?.();
|
||||
const nextFallbackStage = resolveNextRdpAutoFallback({
|
||||
configuredMode: securityMode,
|
||||
currentStage: autoFallbackStage,
|
||||
isNegotiationFailure: kind === mod.IronErrorKind.NegotiationFailure,
|
||||
errorMessage: msg,
|
||||
});
|
||||
if (nextFallbackStage) {
|
||||
callbacksRef.current.onNegotiationFallbackNeeded?.(nextFallbackStage);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1512,6 +1529,8 @@ export const RdpCanvasView = React.memo(forwardRef<RemoteDesktopCanvasHandle, Rd
|
||||
kind,
|
||||
});
|
||||
return;
|
||||
} finally {
|
||||
try { builder.free(); } catch { /* ignore */ }
|
||||
}
|
||||
|
||||
if (disposed) {
|
||||
@@ -1527,7 +1546,12 @@ export const RdpCanvasView = React.memo(forwardRef<RemoteDesktopCanvasHandle, Rd
|
||||
try { size.free(); } catch { /* ignore */ }
|
||||
setRemoteSize({ width: w, height: h });
|
||||
setSessionConnectedSeq((seq) => seq + 1);
|
||||
callbacksRef.current.onConnected({ width: w, height: h, encrypted: !enableStandardRdp });
|
||||
callbacksRef.current.onConnected({
|
||||
width: w,
|
||||
height: h,
|
||||
encrypted: !enableStandardRdp,
|
||||
securityInfo: negotiatedSecurityInfo ?? undefined,
|
||||
});
|
||||
|
||||
try {
|
||||
const termInfo = await session.run();
|
||||
@@ -1595,7 +1619,7 @@ export const RdpCanvasView = React.memo(forwardRef<RemoteDesktopCanvasHandle, Rd
|
||||
emitClipboardTransfer(null);
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [wsUrl, fallbackDisableCredSsp]);
|
||||
}, [wsUrl, autoFallbackStage]);
|
||||
|
||||
// Debounced dynamic resize via IronRDP Display Control channel
|
||||
useEffect(() => {
|
||||
|
||||
@@ -6,9 +6,13 @@ import type { Host, Identity, KnownHost, SSHKey, TerminalSession } from '../../t
|
||||
import type { RdpMultiMonitorMode } from '../../domain/models/connection';
|
||||
import {
|
||||
computeMonitorLayoutEntries,
|
||||
formatStandardRdpSecurityBadge,
|
||||
resolveEffectiveRdpSecurityMode,
|
||||
resolveRemoteDesktopConnectionSpec,
|
||||
type MonitorLayoutSpec,
|
||||
type RdpAutoFallbackStage,
|
||||
type RdpDisplayControlCaps,
|
||||
type RdpNegotiatedSecurityInfo,
|
||||
type RemoteDesktopProtocol,
|
||||
} from '../../domain/remoteDesktop';
|
||||
import { stopAgentTurn, type AgentStopBridge } from '../../infrastructure/ai/harness/agentStop';
|
||||
@@ -230,7 +234,7 @@ export const RemoteDesktopPane: React.FC<RemoteDesktopPaneProps> = React.memo(({
|
||||
const [disconnectError, setDisconnectError] = useState<string | null>(null);
|
||||
const [wsUrl, setWsUrl] = useState<string | null>(null);
|
||||
const [connectAttempt, setConnectAttempt] = useState(0);
|
||||
const [fallbackDisableCredSsp, setFallbackDisableCredSsp] = useState(false);
|
||||
const [autoFallbackStage, setAutoFallbackStage] = useState<RdpAutoFallbackStage>('none');
|
||||
|
||||
// Display, audio, input, and toolbar controls
|
||||
const [displayMode, setDisplayMode] = useState<RemoteDesktopDisplayMode>(() => {
|
||||
@@ -260,6 +264,7 @@ export const RemoteDesktopPane: React.FC<RemoteDesktopPaneProps> = React.memo(({
|
||||
const [isFullscreen, setIsFullscreen] = useState(false);
|
||||
const [resolution, setResolution] = useState<{ width: number; height: number } | null>(null);
|
||||
const [encrypted, setEncrypted] = useState<boolean>(false);
|
||||
const [rdpSecurityInfo, setRdpSecurityInfo] = useState<RdpNegotiatedSecurityInfo | null>(null);
|
||||
const [desktopTitle, setDesktopTitle] = useState<string | null>(null);
|
||||
// Resolution presets, multi-monitor, RDPDR local shared folders, and live telemetry
|
||||
const [fixedResolution, setFixedResolution] = useState<{ width: number; height: number } | null>(null);
|
||||
@@ -868,6 +873,7 @@ export const RemoteDesktopPane: React.FC<RemoteDesktopPaneProps> = React.memo(({
|
||||
setWsUrl(null);
|
||||
setDisconnectError(null);
|
||||
setPendingCert(null);
|
||||
setRdpSecurityInfo(null);
|
||||
setRemoteClipboardFiles([]);
|
||||
setClipboardFileTransferStatus(null);
|
||||
setClipboardTransfer(null);
|
||||
@@ -896,7 +902,7 @@ export const RemoteDesktopPane: React.FC<RemoteDesktopPaneProps> = React.memo(({
|
||||
knownHosts,
|
||||
quality,
|
||||
viewOnly,
|
||||
securityMode: fallbackDisableCredSsp ? 'tls' : spec.rdpConfig?.securityMode,
|
||||
securityMode: resolveEffectiveRdpSecurityMode(spec.rdpConfig?.securityMode, autoFallbackStage),
|
||||
ignoreCertErrors: spec.rdpConfig?.ignoreCertErrors,
|
||||
});
|
||||
|
||||
@@ -938,7 +944,7 @@ export const RemoteDesktopPane: React.FC<RemoteDesktopPaneProps> = React.memo(({
|
||||
// Intentionally reconnect only when connectAttempt, connectionIntent, needsAuthPrompt, or fallback change.
|
||||
// Quality changes apply live over the active VNC WebSocket without reconnecting.
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [connectAttempt, connectionIntent, needsAuthPrompt, fallbackDisableCredSsp]);
|
||||
}, [connectAttempt, connectionIntent, needsAuthPrompt, autoFallbackStage]);
|
||||
|
||||
const handleCertDecision = useCallback(
|
||||
(decision: RemoteDesktopCertDecisionValue) => {
|
||||
@@ -974,7 +980,7 @@ export const RemoteDesktopPane: React.FC<RemoteDesktopPaneProps> = React.memo(({
|
||||
setAuthErrorMessage(null);
|
||||
setNeedsAuthPrompt(false);
|
||||
setConnectionIntent('active');
|
||||
setFallbackDisableCredSsp(false);
|
||||
setAutoFallbackStage('none');
|
||||
setConnectAttempt((n) => n + 1);
|
||||
},
|
||||
[],
|
||||
@@ -989,7 +995,7 @@ export const RemoteDesktopPane: React.FC<RemoteDesktopPaneProps> = React.memo(({
|
||||
|
||||
const handleReconnect = useCallback(() => {
|
||||
setDisconnectError(null);
|
||||
setFallbackDisableCredSsp(false);
|
||||
setAutoFallbackStage('none');
|
||||
setConnectionIntent('active');
|
||||
setConnectAttempt((n) => n + 1);
|
||||
}, []);
|
||||
@@ -1118,9 +1124,16 @@ export const RemoteDesktopPane: React.FC<RemoteDesktopPaneProps> = React.memo(({
|
||||
[releaseKeyboardGrab, sessionId, updateStatus],
|
||||
);
|
||||
|
||||
const handleNegotiationFallback = useCallback(() => {
|
||||
setFallbackDisableCredSsp(true);
|
||||
setStageMessage('CredSSP unavailable, retrying with TLS security...');
|
||||
const handleNegotiationFallback = useCallback((nextStage: Exclude<RdpAutoFallbackStage, 'none'>) => {
|
||||
// Clear wsUrl synchronously so RdpCanvasView unmounts immediately and never
|
||||
// starts a stale WASM connect() against the closing WebSocket on this render.
|
||||
setWsUrl(null);
|
||||
setAutoFallbackStage(nextStage);
|
||||
setStageMessage(
|
||||
nextStage === 'rdp'
|
||||
? 'TLS unavailable, retrying with Standard RDP security...'
|
||||
: 'CredSSP unavailable, retrying with TLS security...',
|
||||
);
|
||||
setConnectAttempt((n) => n + 1);
|
||||
}, []);
|
||||
|
||||
@@ -1436,13 +1449,36 @@ export const RemoteDesktopPane: React.FC<RemoteDesktopPaneProps> = React.memo(({
|
||||
);
|
||||
|
||||
const handleRdpConnected = useCallback(
|
||||
(info: { width: number; height: number; encrypted?: boolean }) => {
|
||||
(info: {
|
||||
width: number;
|
||||
height: number;
|
||||
encrypted?: boolean;
|
||||
securityInfo?: RdpNegotiatedSecurityInfo;
|
||||
}) => {
|
||||
setResolution({ width: info.width, height: info.height });
|
||||
setEncrypted(Boolean(info.encrypted));
|
||||
setRdpSecurityInfo(info.securityInfo ?? null);
|
||||
if (autoFallbackStage === 'rdp') {
|
||||
const badge = formatStandardRdpSecurityBadge(info.securityInfo);
|
||||
toast.info(
|
||||
badge
|
||||
? tr(
|
||||
t,
|
||||
'remoteDesktop.rdp.fallbackStandardRdpWithCipher',
|
||||
'Connected using Standard RDP Security ({{cipher}}).',
|
||||
{ cipher: badge },
|
||||
)
|
||||
: tr(
|
||||
t,
|
||||
'remoteDesktop.rdp.fallbackStandardRdp',
|
||||
'Connected using Standard RDP Security.',
|
||||
),
|
||||
);
|
||||
}
|
||||
setStageMessage('Desktop connected');
|
||||
updateStatus('connected');
|
||||
},
|
||||
[updateStatus],
|
||||
[autoFallbackStage, t, updateStatus],
|
||||
);
|
||||
|
||||
const handleRemoteClipboardFilesChange = useCallback(
|
||||
@@ -1496,6 +1532,7 @@ export const RemoteDesktopPane: React.FC<RemoteDesktopPaneProps> = React.memo(({
|
||||
statusDetail={stageMessage}
|
||||
tunneled={tunneled}
|
||||
encrypted={encrypted}
|
||||
legacySecurityBadge={isRdp ? formatStandardRdpSecurityBadge(rdpSecurityInfo) : null}
|
||||
resolution={resolution}
|
||||
isFullscreen={isFullscreen}
|
||||
keyboardGrabActive={keyboardGrabActive}
|
||||
@@ -1644,7 +1681,7 @@ export const RemoteDesktopPane: React.FC<RemoteDesktopPaneProps> = React.memo(({
|
||||
password={credentials.password}
|
||||
domain={credentials.domain}
|
||||
rdpConfig={spec.rdpConfig}
|
||||
fallbackDisableCredSsp={fallbackDisableCredSsp}
|
||||
autoFallbackStage={autoFallbackStage}
|
||||
isVisible={isVisible}
|
||||
displayMode={displayMode}
|
||||
highDpi={highDpi}
|
||||
|
||||
@@ -48,6 +48,21 @@ test('RemoteDesktopToolbar does not expose SFTP button on graphical remote deskt
|
||||
assert.doesNotMatch(withSftpProp, /data-testid="remote-desktop-sftp-btn"/);
|
||||
});
|
||||
|
||||
test('RemoteDesktopToolbar fullscreen wrapper passes clicks through except at the hover strip and visible pill', () => {
|
||||
const html = renderToolbar({ isFullscreen: true });
|
||||
const layers = html.match(/^<div class="([^"]+)"><div class="([^"]+)"><\/div><div class="([^"]+)">/);
|
||||
assert.ok(layers, 'fullscreen wrapper should contain the trigger strip and toolbar bar');
|
||||
const [, wrapperClass, triggerClass, barClass] = layers;
|
||||
|
||||
assert.match(wrapperClass, /\bpointer-events-none\b/);
|
||||
assert.doesNotMatch(wrapperClass, /\bpointer-events-auto\b/);
|
||||
assert.match(wrapperClass, /\bleft-0 right-0\b/);
|
||||
assert.match(triggerClass, /\bpointer-events-auto\b/);
|
||||
assert.match(triggerClass, /\bh-3\b/);
|
||||
assert.match(barClass, /-translate-y-full opacity-0 pointer-events-none/);
|
||||
assert.doesNotMatch(barClass, /\bpointer-events-auto\b/);
|
||||
});
|
||||
|
||||
test('RemoteDesktopToolbar renders live clipboard transfer progress pills for all phases', () => {
|
||||
const staged = renderToolbar({
|
||||
clipboardTransfer: {
|
||||
@@ -190,3 +205,22 @@ test('RemoteDesktopToolbar disables Keyboard Grab while connecting', () => {
|
||||
});
|
||||
assert.match(connectingHtml, /<button[^>]*disabled=""[^>]*aria-label="Keys: Local"/);
|
||||
});
|
||||
|
||||
test('RemoteDesktopToolbar renders Standard RDP security badge only when not using TLS', () => {
|
||||
const standardRdpHtml = renderToolbar({
|
||||
protocol: 'rdp',
|
||||
encrypted: false,
|
||||
legacySecurityBadge: 'RC4-128',
|
||||
});
|
||||
assert.match(standardRdpHtml, /RC4-128/);
|
||||
assert.match(standardRdpHtml, /Standard RDP Security \(RC4-128\)/);
|
||||
assert.doesNotMatch(standardRdpHtml, /Encrypted TLS connection/);
|
||||
|
||||
const tlsHtml = renderToolbar({
|
||||
protocol: 'rdp',
|
||||
encrypted: true,
|
||||
legacySecurityBadge: 'RC4-128',
|
||||
});
|
||||
assert.match(tlsHtml, /Encrypted TLS connection/);
|
||||
assert.doesNotMatch(tlsHtml, /Standard RDP Security/);
|
||||
});
|
||||
@@ -100,6 +100,7 @@ export interface RemoteDesktopToolbarProps {
|
||||
statusDetail?: string;
|
||||
tunneled?: boolean;
|
||||
encrypted?: boolean;
|
||||
legacySecurityBadge?: string | null;
|
||||
resolution?: { width: number; height: number } | null;
|
||||
fps?: number;
|
||||
isFullscreen: boolean;
|
||||
@@ -449,6 +450,7 @@ const RemoteDesktopNetworkTelemetryPill = React.memo(({
|
||||
fpsProp,
|
||||
resolutionLabel,
|
||||
encrypted,
|
||||
legacySecurityBadge,
|
||||
tunneled,
|
||||
narrowMode,
|
||||
}: {
|
||||
@@ -458,6 +460,7 @@ const RemoteDesktopNetworkTelemetryPill = React.memo(({
|
||||
fpsProp?: number;
|
||||
resolutionLabel: string;
|
||||
encrypted?: boolean;
|
||||
legacySecurityBadge?: string | null;
|
||||
tunneled?: boolean;
|
||||
narrowMode: boolean;
|
||||
}) => {
|
||||
@@ -601,6 +604,12 @@ const RemoteDesktopNetworkTelemetryPill = React.memo(({
|
||||
<span>{tr(t, 'remoteDesktop.network.tlsEncrypted', 'TLS')}</span>
|
||||
</span>
|
||||
)}
|
||||
{!encrypted && legacySecurityBadge && (
|
||||
<span className="inline-flex items-center gap-0.5 text-amber-600 dark:text-amber-400">
|
||||
<ShieldAlert size={10} />
|
||||
<span>{legacySecurityBadge}</span>
|
||||
</span>
|
||||
)}
|
||||
{tunneled && (
|
||||
<span className="inline-flex items-center gap-0.5 text-emerald-600 dark:text-emerald-400">
|
||||
<SshTunnelIcon size={10} />
|
||||
@@ -623,6 +632,7 @@ export const RemoteDesktopToolbar: React.FC<RemoteDesktopToolbarProps> = React.m
|
||||
statusDetail,
|
||||
tunneled,
|
||||
encrypted,
|
||||
legacySecurityBadge,
|
||||
resolution,
|
||||
fps,
|
||||
isFullscreen,
|
||||
@@ -700,6 +710,7 @@ export const RemoteDesktopToolbar: React.FC<RemoteDesktopToolbarProps> = React.m
|
||||
const [customHeightInput, setCustomHeightInput] = useState(() => String(fixedResolution?.height || resolution?.height || 1080));
|
||||
const barRef = useRef<HTMLDivElement | null>(null);
|
||||
const localFileInputRef = useRef<HTMLInputElement | null>(null);
|
||||
const hoverHideTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
||||
const isRdp = protocol === 'rdp';
|
||||
|
||||
const canPickResolution = Boolean(onSelectResolutionPreset && (isRdp || supportsDynamicResize));
|
||||
@@ -716,6 +727,8 @@ export const RemoteDesktopToolbar: React.FC<RemoteDesktopToolbarProps> = React.m
|
||||
onSelectResolutionPreset(clampedW, clampedH);
|
||||
};
|
||||
|
||||
useEffect(() => () => clearTimeout(hoverHideTimerRef.current), [isFullscreen]);
|
||||
|
||||
useEffect(() => {
|
||||
const el = barRef.current;
|
||||
if (!el || isFullscreen || typeof ResizeObserver === 'undefined') return undefined;
|
||||
@@ -792,6 +805,20 @@ export const RemoteDesktopToolbar: React.FC<RemoteDesktopToolbarProps> = React.m
|
||||
aria-label={tr(t, 'remoteDesktop.toolbar.encrypted', 'Encrypted TLS connection')}
|
||||
/>
|
||||
)}
|
||||
{!narrowMode && !encrypted && legacySecurityBadge && (
|
||||
<span
|
||||
className="inline-flex items-center gap-0.5 rounded bg-amber-500/12 px-1.5 py-0.5 text-[10px] font-medium text-amber-600 dark:text-amber-400 shrink-0"
|
||||
title={tr(
|
||||
t,
|
||||
'remoteDesktop.toolbar.standardRdpSecurity',
|
||||
'Standard RDP Security ({{cipher}})',
|
||||
{ cipher: legacySecurityBadge },
|
||||
)}
|
||||
>
|
||||
<ShieldAlert size={10} />
|
||||
<span>{legacySecurityBadge}</span>
|
||||
</span>
|
||||
)}
|
||||
{viewOnly && (
|
||||
<span className="inline-flex items-center gap-1 rounded bg-amber-500/12 px-1.5 py-0.5 text-[10px] font-medium text-amber-600 dark:text-amber-400 shrink-0">
|
||||
<Eye size={10} />
|
||||
@@ -1329,6 +1356,7 @@ export const RemoteDesktopToolbar: React.FC<RemoteDesktopToolbarProps> = React.m
|
||||
fpsProp={fps}
|
||||
resolutionLabel={resolutionLabel}
|
||||
encrypted={encrypted}
|
||||
legacySecurityBadge={legacySecurityBadge}
|
||||
tunneled={tunneled}
|
||||
narrowMode={narrowMode}
|
||||
/>
|
||||
@@ -2298,17 +2326,23 @@ export const RemoteDesktopToolbar: React.FC<RemoteDesktopToolbarProps> = React.m
|
||||
|
||||
return (
|
||||
<div
|
||||
className="pointer-events-auto absolute left-0 right-0 top-0 z-30 flex justify-center pt-1.5"
|
||||
onMouseEnter={() => setHoverReveal(true)}
|
||||
onMouseLeave={() => setHoverReveal(false)}
|
||||
className="pointer-events-none absolute left-0 right-0 top-0 z-30 flex justify-center pt-1.5"
|
||||
onMouseEnter={() => {
|
||||
clearTimeout(hoverHideTimerRef.current);
|
||||
setHoverReveal(true);
|
||||
}}
|
||||
onMouseLeave={() => {
|
||||
// Allow travel from the trigger strip onto the animating pill.
|
||||
hoverHideTimerRef.current = setTimeout(() => setHoverReveal(false), 150);
|
||||
}}
|
||||
>
|
||||
{/* Top-edge hover trigger strip */}
|
||||
<div className="absolute inset-x-0 top-0 h-3" />
|
||||
<div className="pointer-events-auto absolute inset-x-0 top-0 h-3" />
|
||||
<div
|
||||
className={cn(
|
||||
'transition-all duration-150',
|
||||
pinnedFullscreen || hoverReveal
|
||||
? 'translate-y-0 opacity-100'
|
||||
? 'translate-y-0 opacity-100 pointer-events-auto'
|
||||
: '-translate-y-full opacity-0 pointer-events-none',
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -38,15 +38,19 @@ test('per-pane close button keeps shrink-0 so a narrow pane cannot squeeze it aw
|
||||
);
|
||||
});
|
||||
|
||||
test('magnified side panels use a continuous 1px inset outline in the side panel accent', () => {
|
||||
test('magnified side panels use an inner rounded 1px border in the side panel accent', () => {
|
||||
const source = readFileSync(new URL('./TerminalLayerSidePanelSection.tsx', import.meta.url), 'utf8');
|
||||
const chromeStart = source.indexOf('className="absolute inset-3');
|
||||
const chromeSource = source.slice(chromeStart, source.indexOf('\n >', chromeStart));
|
||||
const strokeStart = source.indexOf('data-section="pane-magnification-stroke"', chromeStart);
|
||||
const strokeSource = source.slice(strokeStart, source.indexOf('/>', strokeStart));
|
||||
|
||||
assert.match(chromeSource, /overflow-hidden rounded-md bg-background shadow-2xl/);
|
||||
assert.match(chromeSource, /outline: `1px solid \$\{sidePanelTheme\.accent\}`/);
|
||||
assert.match(chromeSource, /outlineOffset: -1/);
|
||||
assert.doesNotMatch(chromeSource, /\bborder(?:Color|Width|Style)?\b/);
|
||||
assert.doesNotMatch(chromeSource, /\b(?:outline|outlineOffset|border|borderColor|borderWidth|borderStyle)\b/);
|
||||
assert.match(strokeSource, /className="pointer-events-none absolute inset-0 z-50"/);
|
||||
assert.match(strokeSource, /boxSizing: 'border-box'/);
|
||||
assert.match(strokeSource, /border: `1px solid \$\{sidePanelTheme\.accent\}`/);
|
||||
assert.match(strokeSource, /borderRadius: 'inherit'/);
|
||||
});
|
||||
|
||||
test('AI side panel shell can be force-hidden for layout isolation', () => {
|
||||
|
||||
@@ -1585,8 +1585,6 @@ function TerminalLayerSidePanelInner({ ctx, pluginSidebar }: { ctx: SidePanelCon
|
||||
<div
|
||||
className="absolute inset-3 flex flex-col overflow-hidden rounded-md bg-background shadow-2xl animate-in fade-in zoom-in-95 duration-150"
|
||||
style={{
|
||||
outline: `1px solid ${sidePanelTheme.accent}`,
|
||||
outlineOffset: -1,
|
||||
backgroundColor: sidePanelTheme.termBg,
|
||||
color: sidePanelTheme.termFg,
|
||||
}}
|
||||
@@ -1612,6 +1610,16 @@ function TerminalLayerSidePanelInner({ ctx, pluginSidebar }: { ctx: SidePanelCon
|
||||
className="relative flex-1 min-h-0 overflow-hidden [contain:strict]"
|
||||
data-section="pane-magnification-content"
|
||||
/>
|
||||
<div
|
||||
aria-hidden="true"
|
||||
data-section="pane-magnification-stroke"
|
||||
className="pointer-events-none absolute inset-0 z-50"
|
||||
style={{
|
||||
boxSizing: 'border-box',
|
||||
border: `1px solid ${sidePanelTheme.accent}`,
|
||||
borderRadius: 'inherit',
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{showMagnificationHint && (
|
||||
<div
|
||||
|
||||
@@ -1824,13 +1824,7 @@ const TerminalPane: React.FC<TerminalPaneProps> = memo(({
|
||||
isVisible && "z-10",
|
||||
magnifiedSurfaceBounds && "overflow-hidden rounded-md shadow-2xl",
|
||||
)}
|
||||
style={{
|
||||
...style,
|
||||
outline: magnifiedSurfaceBounds
|
||||
? `1px solid ${sessionAppearanceTheme.colors.cursor}`
|
||||
: undefined,
|
||||
outlineOffset: magnifiedSurfaceBounds ? -1 : undefined,
|
||||
}}
|
||||
style={style}
|
||||
tabIndex={-1}
|
||||
onClick={handlePaneClick}
|
||||
onFocusCapture={handlePaneClick}
|
||||
@@ -1994,6 +1988,18 @@ const TerminalPane: React.FC<TerminalPaneProps> = memo(({
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
{magnifiedSurfaceBounds && (
|
||||
<div
|
||||
aria-hidden="true"
|
||||
data-section="pane-magnification-stroke"
|
||||
className="pointer-events-none absolute inset-0 z-50"
|
||||
style={{
|
||||
boxSizing: 'border-box',
|
||||
border: `1px solid ${sessionAppearanceTheme.colors.cursor}`,
|
||||
borderRadius: 'inherit',
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}, terminalPanePropsAreEqual);
|
||||
|
||||
@@ -9,39 +9,46 @@ import { renderToStaticMarkup } from "react-dom/server";
|
||||
|
||||
import { TerminalLayerWorkspaceSection } from "./TerminalLayerWorkspaceSection.tsx";
|
||||
|
||||
test("terminal pane chrome follows retained surface bounds through restore with a continuous 1px inset outline", () => {
|
||||
test("terminal pane chrome uses an inner rounded 1px border while retaining overflow clipping", () => {
|
||||
const source = readFileSync(new URL("./TerminalLayerSupport.tsx", import.meta.url), "utf8");
|
||||
const paneSource = source.slice(source.indexOf('data-section="terminal-split-pane"'), source.indexOf("<Terminal\n"));
|
||||
const paneSource = source.slice(source.indexOf('data-section="terminal-split-pane"'), source.indexOf('TerminalPane.displayName'));
|
||||
const hostSource = paneSource.slice(0, paneSource.indexOf("<LazyLoadBoundary"));
|
||||
const strokeSource = paneSource.slice(paneSource.indexOf("{magnifiedSurfaceBounds && ("));
|
||||
|
||||
assert.match(paneSource, /^\s*magnifiedSurfaceBounds && "overflow-hidden rounded-md shadow-2xl",$/m);
|
||||
assert.match(paneSource, /outline: magnifiedSurfaceBounds\s+\? `1px solid \$\{sessionAppearanceTheme\.colors\.cursor\}`\s+: undefined/);
|
||||
assert.match(paneSource, /outlineOffset: magnifiedSurfaceBounds \? -1 : undefined/);
|
||||
assert.doesNotMatch(paneSource, /\bborder(?:Color|Width|Style)?\b/);
|
||||
assert.match(hostSource, /^\s*magnifiedSurfaceBounds && "overflow-hidden rounded-md shadow-2xl",$/m);
|
||||
assert.match(hostSource, /style=\{style\}/);
|
||||
assert.doesNotMatch(hostSource, /\b(?:outline|outlineOffset|border|borderColor|borderWidth|borderStyle)\b/);
|
||||
assert.match(strokeSource, /aria-hidden="true"/);
|
||||
assert.match(strokeSource, /data-section="pane-magnification-stroke"/);
|
||||
assert.match(strokeSource, /className="pointer-events-none absolute inset-0 z-50"/);
|
||||
assert.match(strokeSource, /boxSizing: 'border-box'/);
|
||||
assert.match(strokeSource, /border: `1px solid \$\{sessionAppearanceTheme\.colors\.cursor\}`/);
|
||||
assert.match(strokeSource, /borderRadius: 'inherit'/);
|
||||
});
|
||||
|
||||
test("restoring terminal chrome keeps its 1px inset outline until surface bounds clear at any DPR", () => {
|
||||
test("restoring terminal chrome retains its inner 1px border until surface bounds clear at any DPR", () => {
|
||||
const source = readFileSync(new URL("./TerminalLayerSupport.tsx", import.meta.url), "utf8");
|
||||
const paneSource = source.slice(source.indexOf('data-section="terminal-split-pane"'), source.indexOf("<Terminal\n"));
|
||||
const styleSource = paneSource.match(/style=\{\{([\s\S]*?)\}\}/);
|
||||
const strokeSource = source.slice(source.indexOf("{magnifiedSurfaceBounds && ("), source.indexOf('TerminalPane.displayName'));
|
||||
const condition = strokeSource.match(/^\{(\w+) && \(/);
|
||||
const styleSource = strokeSource.match(/style=\{\{([\s\S]*?)\}\}/);
|
||||
assert.ok(condition);
|
||||
assert.ok(styleSource);
|
||||
const resolveStyle = new Function(
|
||||
"style", "isMagnified", "magnifiedSurfaceBounds", "sessionAppearanceTheme",
|
||||
"magnifiedDevicePixelRatio",
|
||||
`return ({${styleSource[1]}});`,
|
||||
const resolveStroke = new Function(
|
||||
"isMagnified", "magnifiedSurfaceBounds", "sessionAppearanceTheme", "magnifiedDevicePixelRatio",
|
||||
`return ${condition[1]} ? ({${styleSource[1]}}) : null;`,
|
||||
);
|
||||
const bounds = { left: 0, top: 80, width: 1200, height: 800 };
|
||||
const theme = { colors: { cursor: "#0088ff" } };
|
||||
|
||||
for (const dpr of [1, 1.25, 1.5, 2, 3]) {
|
||||
const magnified = resolveStyle({}, true, bounds, theme, dpr);
|
||||
const restoring = resolveStyle({}, false, bounds, theme, dpr);
|
||||
const magnified = resolveStroke(true, bounds, theme, dpr);
|
||||
const restoring = resolveStroke(false, bounds, theme, dpr);
|
||||
assert.deepEqual(restoring, magnified);
|
||||
assert.equal(restoring.outline, `1px solid ${theme.colors.cursor}`);
|
||||
assert.equal(restoring.outlineOffset, -1);
|
||||
assert.equal(restoring.border, `1px solid ${theme.colors.cursor}`);
|
||||
assert.equal(restoring.boxSizing, 'border-box');
|
||||
assert.equal(restoring.borderRadius, 'inherit');
|
||||
for (const isMagnified of [false, true]) {
|
||||
const cleared = resolveStyle({}, isMagnified, null, theme, dpr);
|
||||
assert.equal(cleared.outline, undefined);
|
||||
assert.equal(cleared.outlineOffset, undefined);
|
||||
assert.equal(resolveStroke(isMagnified, null, theme, dpr), null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
} from "../../domain/remoteDesktop";
|
||||
import type { Host } from "../../types";
|
||||
import { HostDetailsConnectionSections } from "../HostDetailsConnectionSections";
|
||||
import { CompanionRemoteDesktopSections } from "../host-details/CompanionRemoteDesktopSections";
|
||||
import { CompanionRemoteDesktopInlineFields, CompanionRemoteDesktopSections } from "../host-details/CompanionRemoteDesktopSections";
|
||||
import {
|
||||
resolvePrimaryProtocolSavePort,
|
||||
resolvePrimaryProtocolSwitchPort,
|
||||
@@ -316,3 +316,28 @@ test("buildHostForProtocolOverride keeps SSH identity for companion RDP/VNC and
|
||||
assert.equal(sshDispatch.host.protocol, "ssh");
|
||||
assert.equal(sshDispatch.host.rdpConfig?.defaultConnect, undefined);
|
||||
});
|
||||
|
||||
for (const resolutionMode of ["fixed", "dynamic", "fit"] as const) {
|
||||
test(`companion RDP shows dimensions only in fixed mode: ${resolutionMode}`, () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<TooltipProvider>
|
||||
<CompanionRemoteDesktopInlineFields
|
||||
protocol="rdp"
|
||||
form={makeHost({ rdpConfig: { enabled: true, resolutionMode, width: 1920, height: 1080 } })}
|
||||
setForm={() => {}}
|
||||
identities={[]}
|
||||
t={(key) => key}
|
||||
/>
|
||||
</TooltipProvider>,
|
||||
);
|
||||
for (const dimension of ["width", "height"]) {
|
||||
const label = new RegExp(`hostDetails\\.rdp\\.${dimension}`);
|
||||
if (resolutionMode === "fixed") assert.match(markup, label);
|
||||
else assert.doesNotMatch(markup, label);
|
||||
}
|
||||
if (resolutionMode === "fixed") {
|
||||
assert.match(markup, /inputMode="numeric"[^>]*value="1920"/);
|
||||
assert.match(markup, /inputMode="numeric"[^>]*value="1080"/);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -10,10 +10,13 @@ import {
|
||||
DEFAULT_RDP_PORT,
|
||||
DEFAULT_VNC_PORT,
|
||||
formatBandwidthBps,
|
||||
formatStandardRdpSecurityBadge,
|
||||
formatVncDisplayNumber,
|
||||
getAvailableRemoteDesktopProtocols,
|
||||
hasCompanionRdp,
|
||||
hasCompanionVnc,
|
||||
hasValidRdpFixedResolution,
|
||||
parseRdpDimensionDraft,
|
||||
isRdpProtocol,
|
||||
isRemoteDesktopProtocol,
|
||||
isVncProtocol,
|
||||
@@ -22,6 +25,8 @@ import {
|
||||
normalizeVncConfig,
|
||||
parseVncPortOrDisplay,
|
||||
RDP_RESOLUTION_PRESETS,
|
||||
resolveEffectiveRdpSecurityMode,
|
||||
resolveNextRdpAutoFallback,
|
||||
resolveRemoteDesktopConnectionSpec,
|
||||
sanitizeRdpConfig,
|
||||
sanitizeVncConfig,
|
||||
@@ -418,3 +423,139 @@ test('mapViewportToVirtualDesktopCoords maps full view and cropped single-monito
|
||||
{ x: 3839, y: 1079 },
|
||||
);
|
||||
});
|
||||
|
||||
test('fixed RDP resolution validation rejects invalid drafts before sanitization', () => {
|
||||
const config = { resolutionMode: 'fixed' as const, width: 1920, height: 1080 };
|
||||
for (const value of ['', ' ', '19', '192', '199', '8193', '3840.5', 'abc', 'Infinity']) {
|
||||
assert.equal(parseRdpDimensionDraft(value), undefined, value);
|
||||
assert.equal(hasValidRdpFixedResolution(config, { width: value }), false, value);
|
||||
assert.equal(hasValidRdpFixedResolution(config, { height: value }), false, value);
|
||||
}
|
||||
for (const value of ['200', '3840', '8192']) {
|
||||
assert.equal(parseRdpDimensionDraft(value), Number(value));
|
||||
assert.equal(hasValidRdpFixedResolution(config, { width: value, height: value }), true);
|
||||
}
|
||||
for (const dimension of [192, 8193, 3840.5, NaN]) {
|
||||
assert.equal(hasValidRdpFixedResolution({ ...config, width: dimension }), false);
|
||||
assert.equal(hasValidRdpFixedResolution({ ...config, height: dimension }), false);
|
||||
}
|
||||
assert.equal(hasValidRdpFixedResolution(config), true);
|
||||
assert.equal(hasValidRdpFixedResolution({ resolutionMode: 'fixed' }), true);
|
||||
for (const resolutionMode of ['dynamic', 'fit'] as const) {
|
||||
assert.equal(hasValidRdpFixedResolution({ ...config, resolutionMode }, { width: '' }), true);
|
||||
}
|
||||
});
|
||||
|
||||
test('RDP auto-fallback steps NLA -> TLS -> Standard RDP safely without downgrading explicit modes', () => {
|
||||
assert.equal(resolveEffectiveRdpSecurityMode('auto', 'none'), 'auto');
|
||||
assert.equal(resolveEffectiveRdpSecurityMode('auto', 'tls'), 'tls');
|
||||
assert.equal(resolveEffectiveRdpSecurityMode('auto', 'rdp'), 'rdp');
|
||||
assert.equal(resolveEffectiveRdpSecurityMode('nla', 'rdp'), 'nla');
|
||||
assert.equal(resolveEffectiveRdpSecurityMode('tls', 'rdp'), 'tls');
|
||||
|
||||
// Generic negotiation failure steps none -> tls -> rdp -> null
|
||||
assert.equal(
|
||||
resolveNextRdpAutoFallback({
|
||||
configuredMode: 'auto',
|
||||
currentStage: 'none',
|
||||
isNegotiationFailure: true,
|
||||
errorMessage: 'server requires TLS without CredSSP',
|
||||
}),
|
||||
'tls',
|
||||
);
|
||||
assert.equal(
|
||||
resolveNextRdpAutoFallback({
|
||||
configuredMode: 'auto',
|
||||
currentStage: 'tls',
|
||||
isNegotiationFailure: true,
|
||||
errorMessage: 'negotiation failure',
|
||||
}),
|
||||
'rdp',
|
||||
);
|
||||
assert.equal(
|
||||
resolveNextRdpAutoFallback({
|
||||
configuredMode: 'auto',
|
||||
currentStage: 'rdp',
|
||||
isNegotiationFailure: true,
|
||||
errorMessage: 'negotiation failure',
|
||||
}),
|
||||
null,
|
||||
);
|
||||
|
||||
// Server explicitly advertising Standard-RDP-only jumps straight to 'rdp'
|
||||
assert.equal(
|
||||
resolveNextRdpAutoFallback({
|
||||
configuredMode: 'auto',
|
||||
currentStage: 'none',
|
||||
isNegotiationFailure: true,
|
||||
errorMessage: '[negotiation failure] server only supports Standard RDP Security',
|
||||
}),
|
||||
'rdp',
|
||||
);
|
||||
assert.equal(
|
||||
resolveNextRdpAutoFallback({
|
||||
configuredMode: 'auto',
|
||||
currentStage: 'none',
|
||||
isNegotiationFailure: true,
|
||||
errorMessage: 'SSL_NOT_ALLOWED_BY_SERVER',
|
||||
}),
|
||||
'rdp',
|
||||
);
|
||||
|
||||
// Explicit modes and non-negotiation errors must never fallback
|
||||
assert.equal(
|
||||
resolveNextRdpAutoFallback({
|
||||
configuredMode: 'nla',
|
||||
currentStage: 'none',
|
||||
isNegotiationFailure: true,
|
||||
errorMessage: 'server only supports Standard RDP Security',
|
||||
}),
|
||||
null,
|
||||
);
|
||||
assert.equal(
|
||||
resolveNextRdpAutoFallback({
|
||||
configuredMode: 'tls',
|
||||
currentStage: 'none',
|
||||
isNegotiationFailure: true,
|
||||
errorMessage: 'server only supports Standard RDP Security',
|
||||
}),
|
||||
null,
|
||||
);
|
||||
assert.equal(
|
||||
resolveNextRdpAutoFallback({
|
||||
configuredMode: 'auto',
|
||||
currentStage: 'none',
|
||||
isNegotiationFailure: false,
|
||||
errorMessage: 'wrong password',
|
||||
}),
|
||||
null,
|
||||
);
|
||||
});
|
||||
|
||||
test('formatStandardRdpSecurityBadge formats RC4/FIPS/Unencrypted labels and hides TLS', () => {
|
||||
assert.equal(formatStandardRdpSecurityBadge(null), null);
|
||||
assert.equal(
|
||||
formatStandardRdpSecurityBadge({ standardRdp: false, encrypted: true, method: 'tls', level: 'enhanced' }),
|
||||
null,
|
||||
);
|
||||
assert.equal(
|
||||
formatStandardRdpSecurityBadge({ standardRdp: true, encrypted: true, method: 'rc4-128', level: 'client-compatible' }),
|
||||
'RC4-128',
|
||||
);
|
||||
assert.equal(
|
||||
formatStandardRdpSecurityBadge({ standardRdp: true, encrypted: true, method: 'rc4-56', level: 'client-compatible' }),
|
||||
'RC4-56',
|
||||
);
|
||||
assert.equal(
|
||||
formatStandardRdpSecurityBadge({ standardRdp: true, encrypted: true, method: 'rc4-40', level: 'low' }),
|
||||
'RC4-40',
|
||||
);
|
||||
assert.equal(
|
||||
formatStandardRdpSecurityBadge({ standardRdp: true, encrypted: true, method: 'fips', level: 'fips' }),
|
||||
'FIPS',
|
||||
);
|
||||
assert.equal(
|
||||
formatStandardRdpSecurityBadge({ standardRdp: true, encrypted: false, method: 'none', level: 'none' }),
|
||||
'Unencrypted',
|
||||
);
|
||||
});
|
||||
@@ -24,6 +24,25 @@ export const DEFAULT_RDP_COLOR_DEPTH: RdpColorDepth = 32;
|
||||
export const DEFAULT_RDP_RESOLUTION_MODE: RdpResolutionMode = 'dynamic';
|
||||
export const DEFAULT_RDP_SECURITY_MODE: RdpSecurityMode = 'auto';
|
||||
|
||||
// Editor drafts stay separate from the sanitized config until they are valid.
|
||||
export type RdpResolutionDraft = Partial<Record<'width' | 'height', string>>;
|
||||
|
||||
export const parseRdpDimensionDraft = (value: string): number | undefined => {
|
||||
if (!value.trim()) return undefined;
|
||||
const dimension = Number(value);
|
||||
return Number.isInteger(dimension) && dimension >= 200 && dimension <= 8192
|
||||
? dimension
|
||||
: undefined;
|
||||
};
|
||||
|
||||
export const hasValidRdpFixedResolution = (
|
||||
config: RdpConfig | undefined,
|
||||
draft: RdpResolutionDraft = {},
|
||||
): boolean => config?.resolutionMode !== 'fixed' || (
|
||||
parseRdpDimensionDraft(draft.width ?? String(config.width ?? DEFAULT_RDP_WIDTH)) !== undefined
|
||||
&& parseRdpDimensionDraft(draft.height ?? String(config.height ?? DEFAULT_RDP_HEIGHT)) !== undefined
|
||||
);
|
||||
|
||||
export const DEFAULT_VNC_SCALING_MODE: VncScalingMode = 'fit';
|
||||
export const DEFAULT_VNC_QUALITY = 6;
|
||||
export const DEFAULT_VNC_COMPRESSION_LEVEL = 2;
|
||||
@@ -1156,3 +1175,84 @@ export function mapViewportToVirtualDesktopCoords(
|
||||
const y = Math.max(0, Math.min(Math.round(virtualSize.height) - 1, Math.round(rawY)));
|
||||
return { x, y };
|
||||
}
|
||||
|
||||
export type RdpAutoFallbackStage = 'none' | 'tls' | 'rdp';
|
||||
|
||||
export interface RdpNegotiatedSecurityInfo {
|
||||
standardRdp: boolean;
|
||||
encrypted: boolean;
|
||||
method: 'tls' | 'rc4-128' | 'rc4-56' | 'rc4-40' | 'fips' | 'none';
|
||||
level: 'enhanced' | 'low' | 'client-compatible' | 'high' | 'fips' | 'none';
|
||||
}
|
||||
|
||||
const STANDARD_RDP_ONLY_ERROR_RE =
|
||||
/server only supports standard rdp security|ssl_not_allowed_by_server|standard rdp security is not supported/i;
|
||||
|
||||
/**
|
||||
* Resolve the effective RDP security mode for a connection attempt given the
|
||||
* user's configured mode and any active `auto`-mode negotiation fallback stage.
|
||||
*/
|
||||
export function resolveEffectiveRdpSecurityMode(
|
||||
configuredMode: RdpSecurityMode | undefined,
|
||||
autoFallbackStage: RdpAutoFallbackStage,
|
||||
): RdpSecurityMode {
|
||||
const mode = configuredMode ?? DEFAULT_RDP_SECURITY_MODE;
|
||||
if (mode !== 'auto') return mode;
|
||||
if (autoFallbackStage === 'tls') return 'tls';
|
||||
if (autoFallbackStage === 'rdp') return 'rdp';
|
||||
return 'auto';
|
||||
}
|
||||
|
||||
/**
|
||||
* Decide the next `auto`-mode negotiation fallback stage after a pre-auth
|
||||
* `NegotiationFailure`. Explicit security modes (`nla`, `tls`, `rdp`) never
|
||||
* auto-downgrade, and non-negotiation errors (e.g. wrong password) never retry.
|
||||
*/
|
||||
export function resolveNextRdpAutoFallback(options: {
|
||||
configuredMode: RdpSecurityMode | undefined;
|
||||
currentStage: RdpAutoFallbackStage;
|
||||
isNegotiationFailure: boolean;
|
||||
errorMessage?: string;
|
||||
}): Exclude<RdpAutoFallbackStage, 'none'> | null {
|
||||
const mode = options.configuredMode ?? DEFAULT_RDP_SECURITY_MODE;
|
||||
if (mode !== 'auto' || !options.isNegotiationFailure) {
|
||||
return null;
|
||||
}
|
||||
if (options.currentStage === 'rdp') {
|
||||
return null;
|
||||
}
|
||||
if (options.errorMessage && STANDARD_RDP_ONLY_ERROR_RE.test(options.errorMessage)) {
|
||||
return 'rdp';
|
||||
}
|
||||
if (options.currentStage === 'none') {
|
||||
return 'tls';
|
||||
}
|
||||
if (options.currentStage === 'tls') {
|
||||
return 'rdp';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a compact badge label for Standard RDP Security (RC4 / FIPS / None).
|
||||
* Returns `null` for Enhanced RDP Security (TLS / NLA).
|
||||
*/
|
||||
export function formatStandardRdpSecurityBadge(
|
||||
info: RdpNegotiatedSecurityInfo | null | undefined,
|
||||
): string | null {
|
||||
if (!info?.standardRdp) return null;
|
||||
switch (info.method) {
|
||||
case 'rc4-128':
|
||||
return 'RC4-128';
|
||||
case 'rc4-56':
|
||||
return 'RC4-56';
|
||||
case 'rc4-40':
|
||||
return 'RC4-40';
|
||||
case 'fips':
|
||||
return 'FIPS';
|
||||
case 'none':
|
||||
return 'Unencrypted';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -124,9 +124,8 @@ function setAutoLaunchEnabled(enabled, {
|
||||
try {
|
||||
app.setLoginItemSettings({
|
||||
openAtLogin: wantEnabled,
|
||||
// openAsHidden only applies on macOS App Store builds; Windows relies
|
||||
// on the --hidden arg below, which main.cjs checks on cold start.
|
||||
openAsHidden: wantEnabled,
|
||||
// Windows relies on the --hidden arg below, which main.cjs checks on cold start.
|
||||
// macOS 13+ detects login launches via wasOpenedAtLogin (openAsHidden was removed in Electron 44).
|
||||
path: execPath,
|
||||
args: wantEnabled ? [HIDDEN_LAUNCH_ARG] : [],
|
||||
});
|
||||
|
||||
@@ -204,7 +204,6 @@ test("setAutoLaunchEnabled(true) registers the hidden launch arg", () => {
|
||||
|
||||
assert.deepEqual(capturedSettings, {
|
||||
openAtLogin: true,
|
||||
openAsHidden: true,
|
||||
path: EXEC_PATH,
|
||||
args: [HIDDEN_LAUNCH_ARG],
|
||||
});
|
||||
|
||||
@@ -90,6 +90,67 @@ function parseClipboardTextFilePaths(text, options = {}) {
|
||||
return collectExistingFiles(candidates, options);
|
||||
}
|
||||
|
||||
async function readClipboardFilesAsync(clipboard, options) {
|
||||
try {
|
||||
const items = await clipboard.read();
|
||||
if (!Array.isArray(items) || items.length === 0) return [];
|
||||
|
||||
for (const item of items) {
|
||||
const types = Array.isArray(item?.types) ? item.types : [];
|
||||
if (typeof item?.getType !== "function") continue;
|
||||
|
||||
// Electron 44+ maps native file references (CF_HDROP on Windows,
|
||||
// NSFilenamesPboardType on macOS, text/uri-list on Linux) to text/uri-list.
|
||||
for (const mime of URI_LIST_FORMATS) {
|
||||
if (!types.includes(mime)) continue;
|
||||
const blob = await item.getType(mime);
|
||||
const text = typeof blob?.text === "function" ? await blob.text() : "";
|
||||
const files = parseClipboardTextFilePaths(text, options);
|
||||
if (files.length > 0) return files;
|
||||
}
|
||||
|
||||
for (const rawFormat of HDROP_FORMATS) {
|
||||
const osMime = `electron application/osclipboard;format="${rawFormat}"`;
|
||||
if (!types.includes(osMime)) continue;
|
||||
const blob = await item.getType(osMime);
|
||||
if (typeof blob?.arrayBuffer !== "function") continue;
|
||||
const files = collectExistingFiles(
|
||||
decodeWindowsHDrop(Buffer.from(await blob.arrayBuffer())),
|
||||
options,
|
||||
);
|
||||
if (files.length > 0) return files;
|
||||
}
|
||||
|
||||
const fileNameWMime = 'electron application/osclipboard;format="FileNameW"';
|
||||
if (types.includes(fileNameWMime)) {
|
||||
const blob = await item.getType(fileNameWMime);
|
||||
if (typeof blob?.arrayBuffer === "function") {
|
||||
const files = collectExistingFiles(
|
||||
decodeWindowsFileNameW(Buffer.from(await blob.arrayBuffer())),
|
||||
options,
|
||||
);
|
||||
if (files.length > 0) return files;
|
||||
}
|
||||
}
|
||||
|
||||
const fileNameMime = 'electron application/osclipboard;format="FileName"';
|
||||
if (types.includes(fileNameMime)) {
|
||||
const blob = await item.getType(fileNameMime);
|
||||
if (typeof blob?.arrayBuffer === "function") {
|
||||
const files = collectExistingFiles(
|
||||
decodeWindowsFileName(Buffer.from(await blob.arrayBuffer())),
|
||||
options,
|
||||
);
|
||||
if (files.length > 0) return files;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
function readClipboardFiles({
|
||||
clipboard,
|
||||
fsImpl = fs,
|
||||
@@ -98,6 +159,12 @@ function readClipboardFiles({
|
||||
if (!clipboard) return [];
|
||||
|
||||
const options = { fsImpl, pathImpl };
|
||||
// Electron 44+ removed availableFormats/readBuffer and replaced clipboard.read
|
||||
// with the async W3C ClipboardItem[] API.
|
||||
if (typeof clipboard.availableFormats !== "function" && typeof clipboard.read === "function") {
|
||||
return readClipboardFilesAsync(clipboard, options);
|
||||
}
|
||||
|
||||
try {
|
||||
const formats = typeof clipboard.availableFormats === "function"
|
||||
? clipboard.availableFormats()
|
||||
@@ -174,18 +241,61 @@ async function readClipboardImage({
|
||||
clipboard,
|
||||
fsImpl = fs,
|
||||
tempDirBridge,
|
||||
nativeImageImpl = null,
|
||||
now = () => new Date(),
|
||||
} = {}) {
|
||||
if (!clipboard || typeof clipboard.readImage !== "function" || !tempDirBridge?.getTempFilePath) {
|
||||
if (!clipboard || !tempDirBridge?.getTempFilePath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
const image = clipboard.readImage();
|
||||
if (!image || (typeof image.isEmpty === "function" && image.isEmpty())) return null;
|
||||
if (typeof image.toPNG !== "function") return null;
|
||||
let content = null;
|
||||
if (typeof clipboard.readImage === "function") {
|
||||
const image = clipboard.readImage();
|
||||
if (!image || (typeof image.isEmpty === "function" && image.isEmpty())) return null;
|
||||
if (typeof image.toPNG !== "function") return null;
|
||||
content = image.toPNG();
|
||||
} else if (typeof clipboard.read === "function") {
|
||||
const items = await clipboard.read();
|
||||
if (!Array.isArray(items) || items.length === 0) return null;
|
||||
let matchedItem = null;
|
||||
let matchedType = null;
|
||||
for (const item of items) {
|
||||
const types = Array.isArray(item?.types) ? item.types : [];
|
||||
if (types.includes("image/png")) {
|
||||
matchedItem = item;
|
||||
matchedType = "image/png";
|
||||
break;
|
||||
}
|
||||
const fallbackType = types.find((type) => typeof type === "string" && type.startsWith("image/"));
|
||||
if (fallbackType && !matchedItem) {
|
||||
matchedItem = item;
|
||||
matchedType = fallbackType;
|
||||
}
|
||||
}
|
||||
if (!matchedItem || !matchedType || typeof matchedItem.getType !== "function") return null;
|
||||
const blob = await matchedItem.getType(matchedType);
|
||||
if (typeof blob?.arrayBuffer !== "function") return null;
|
||||
const rawBuffer = Buffer.from(await blob.arrayBuffer());
|
||||
if (rawBuffer.length === 0) return null;
|
||||
if (matchedType === "image/png") {
|
||||
content = rawBuffer;
|
||||
} else {
|
||||
const ni = nativeImageImpl || (() => {
|
||||
try { return require("electron").nativeImage; } catch { return null; }
|
||||
})();
|
||||
if (ni && typeof ni.createFromBuffer === "function") {
|
||||
const img = ni.createFromBuffer(rawBuffer);
|
||||
if (!img || (typeof img.isEmpty === "function" && img.isEmpty())) return null;
|
||||
content = img.toPNG();
|
||||
} else {
|
||||
content = rawBuffer;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
const content = image.toPNG();
|
||||
if (!Buffer.isBuffer(content) || content.length === 0) return null;
|
||||
|
||||
const name = createClipboardImageFileName(now());
|
||||
@@ -202,6 +312,27 @@ async function readClipboardImage({
|
||||
}
|
||||
}
|
||||
|
||||
async function hasClipboardImageAsync(clipboard) {
|
||||
try {
|
||||
if (typeof clipboard.read === "function") {
|
||||
const items = await clipboard.read();
|
||||
if (Array.isArray(items)) {
|
||||
return items.some(
|
||||
(item) => Array.isArray(item?.types)
|
||||
&& item.types.some((type) => typeof type === "string" && type.startsWith("image/")),
|
||||
);
|
||||
}
|
||||
}
|
||||
if (typeof clipboard.has === "function") {
|
||||
if (await clipboard.has("image/png")) return true;
|
||||
if (await clipboard.has("image/jpeg")) return true;
|
||||
}
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Peek whether the OS clipboard currently holds an image without writing a
|
||||
* temp file. Used by local terminal paste to decide whether to forward Ctrl+V
|
||||
@@ -209,7 +340,13 @@ async function readClipboardImage({
|
||||
* turns the chord into a clipboard paste event.
|
||||
*/
|
||||
function hasClipboardImage({ clipboard } = {}) {
|
||||
if (!clipboard || typeof clipboard.readImage !== "function") return false;
|
||||
if (!clipboard) return false;
|
||||
if (typeof clipboard.readImage !== "function") {
|
||||
if (typeof clipboard.read === "function" || typeof clipboard.has === "function") {
|
||||
return hasClipboardImageAsync(clipboard);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
if (typeof clipboard.availableFormats === "function") {
|
||||
try {
|
||||
|
||||
@@ -305,3 +305,64 @@ test("hasClipboardImage is false when clipboard API is unavailable", () => {
|
||||
assert.equal(hasClipboardImage({ clipboard: null }), false);
|
||||
assert.equal(hasClipboardImage({ clipboard: {} }), false);
|
||||
});
|
||||
|
||||
test("readClipboardFiles supports Electron 44+ async W3C clipboard.read() text/uri-list", async () => {
|
||||
const fsImpl = createFs({
|
||||
"/Users/me/report.pdf": "file",
|
||||
"/Users/me/docs": "directory",
|
||||
});
|
||||
const clipboard = {
|
||||
read: async () => [
|
||||
{
|
||||
types: ["text/uri-list"],
|
||||
getType: async (type) => {
|
||||
assert.equal(type, "text/uri-list");
|
||||
return new Blob(["file:///Users/me/report.pdf\r\nfile:///Users/me/docs\r\n"]);
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const files = await readClipboardFiles({ clipboard, fsImpl, pathImpl: require("node:path") });
|
||||
assert.deepEqual(files, [
|
||||
{ path: "/Users/me/report.pdf", name: "report.pdf", isDirectory: false, size: 42 },
|
||||
{ path: "/Users/me/docs", name: "docs", isDirectory: true, size: 0 },
|
||||
]);
|
||||
});
|
||||
|
||||
test("readClipboardImage and hasClipboardImage support Electron 44+ async W3C clipboard.read()", async () => {
|
||||
const pngBytes = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
|
||||
const written = [];
|
||||
const clipboard = {
|
||||
read: async () => [
|
||||
{
|
||||
types: ["text/plain", "image/png"],
|
||||
getType: async (type) => {
|
||||
assert.equal(type, "image/png");
|
||||
return new Blob([pngBytes], { type: "image/png" });
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
assert.equal(await hasClipboardImage({ clipboard }), true);
|
||||
const saved = await readClipboardImage({
|
||||
clipboard,
|
||||
fsImpl: {
|
||||
promises: {
|
||||
writeFile: async (filePath, buf) => {
|
||||
written.push({ filePath, buf });
|
||||
},
|
||||
},
|
||||
},
|
||||
tempDirBridge: {
|
||||
getTempFilePath: (name) => `/tmp/${name}`,
|
||||
},
|
||||
now: () => new Date(2026, 10, 27, 12, 0, 0, 5),
|
||||
});
|
||||
assert.equal(saved.mediaType, "image/png");
|
||||
assert.equal(saved.size, pngBytes.length);
|
||||
assert.equal(written.length, 1);
|
||||
assert.deepEqual(written[0].buf, pngBytes);
|
||||
});
|
||||
|
||||
@@ -104,10 +104,11 @@ function loadSftpBridgeWithAuthRetryMocks(t, options = {}) {
|
||||
: ["password", "keyboard-interactive"];
|
||||
const first = offerNext(firstMethods, false);
|
||||
if (attemptIndex === 1 && options.dynamicAuth) {
|
||||
assert.equal(first?.type, "publickey");
|
||||
const password = offerNext(["password", "keyboard-interactive"], false);
|
||||
assert.equal(password?.type, "password");
|
||||
offerNext(["publickey"], false);
|
||||
assert.equal(first?.type, "password");
|
||||
const publickey = offerNext(["publickey"], false);
|
||||
assert.equal(publickey?.type, "publickey");
|
||||
const exhausted = offerNext(["publickey"], false);
|
||||
assert.equal(exhausted, false);
|
||||
const err = new Error("All configured authentication methods failed");
|
||||
err.level = "client-authentication";
|
||||
this.client.emit("error", err);
|
||||
@@ -443,7 +444,7 @@ test("openSftp retries keyboard-interactive after dynamic auth password rejectio
|
||||
MockSftpClient.instances[0].authMethodsOffered.map((method) => (
|
||||
method?.type === "publickey" ? "publickey" : method?.type || method
|
||||
)),
|
||||
["none", "publickey", "password", false],
|
||||
["none", "password", "publickey", false],
|
||||
);
|
||||
assert.deepEqual(
|
||||
MockSftpClient.instances[1].authMethodsOffered.map((method) => (
|
||||
|
||||
@@ -1658,9 +1658,11 @@ function buildAuthHandler(options) {
|
||||
asObjects: true,
|
||||
});
|
||||
} else if (isAutomatic) {
|
||||
// Automatic normally mirrors the familiar OpenSSH-style order. With MFA
|
||||
// enabled and no saved password, prompt before probing discovered keys so
|
||||
// repeated key attempts cannot exhaust a server's authentication limit.
|
||||
// Automatic normally mirrors the familiar OpenSSH-style order, except a
|
||||
// saved password is tried before discovered default ~/.ssh keys so key
|
||||
// probing cannot exhaust MaxAuthTries first (#4478). With MFA enabled and
|
||||
// no saved password, prompt before probing discovered keys for the same
|
||||
// reason.
|
||||
if (requiresMfa && !hasExplicitPassword) {
|
||||
authMethods.push({ type: "keyboard-interactive", id: "keyboard-interactive" });
|
||||
}
|
||||
@@ -1675,6 +1677,12 @@ function buildAuthHandler(options) {
|
||||
id: "publickey-user"
|
||||
});
|
||||
}
|
||||
appendPasswordAuthMethods(authMethods, {
|
||||
hasPassword: !!password,
|
||||
skipPasswordMethod,
|
||||
preferKeyboardInteractive: requiresMfa && hasExplicitPassword,
|
||||
asObjects: true,
|
||||
});
|
||||
for (const keyInfo of fallbackKeys) {
|
||||
authMethods.push({
|
||||
type: "publickey",
|
||||
@@ -1682,12 +1690,6 @@ function buildAuthHandler(options) {
|
||||
id: `publickey-default-${keyInfo.keyName}`
|
||||
});
|
||||
}
|
||||
appendPasswordAuthMethods(authMethods, {
|
||||
hasPassword: !!password,
|
||||
skipPasswordMethod,
|
||||
preferKeyboardInteractive: requiresMfa && hasExplicitPassword,
|
||||
asObjects: true,
|
||||
});
|
||||
} else if (isKeyOnly) {
|
||||
// Key-only: user key first, then password (if any), then agent/default keys as fallback
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ test("buildAuthHandler password-only still fires onAuthAttempt for jump/SFTP pro
|
||||
);
|
||||
});
|
||||
|
||||
test("buildAuthHandler automatic mode tries agent and default keys before password", () => {
|
||||
test("buildAuthHandler automatic mode tries agent before password and password before default keys (#4478)", () => {
|
||||
const auth = buildAuthHandler({
|
||||
authMethod: "auto",
|
||||
password: "saved-secret",
|
||||
@@ -118,13 +118,98 @@ test("buildAuthHandler automatic mode tries agent and default keys before passwo
|
||||
assert.ok(keyIndex >= 0, `expected publickey; got ${labels.join(",")}`);
|
||||
assert.ok(passwordIndex >= 0, `expected password; got ${labels.join(",")}`);
|
||||
assert.ok(agentIndex < passwordIndex, `agent should precede password; got ${labels.join(",")}`);
|
||||
assert.ok(keyIndex < passwordIndex, `default key should precede password; got ${labels.join(",")}`);
|
||||
assert.ok(passwordIndex < keyIndex, `password should precede default keys; got ${labels.join(",")}`);
|
||||
assert.ok(
|
||||
labels.every((label, index) => label !== "publickey" || index < passwordIndex),
|
||||
`all default keys should precede password; got ${labels.join(",")}`,
|
||||
labels.every((label, index) => label !== "publickey" || index > passwordIndex),
|
||||
`password should precede all default keys; got ${labels.join(",")}`,
|
||||
);
|
||||
});
|
||||
|
||||
test("buildAuthHandler automatic mode with saved password and no agent tries password before all default keys (#4478)", () => {
|
||||
const manyDefaultKeys = [
|
||||
...DEFAULT_KEYS,
|
||||
{ keyName: "id_ecdsa", keyPath: "/tmp/id_ecdsa", privateKey: "-----BEGIN EC PRIVATE KEY-----\nec\n-----END EC PRIVATE KEY-----\n" },
|
||||
{ keyName: "id_work_1", keyPath: "/tmp/id_work_1", privateKey: "-----BEGIN OPENSSH PRIVATE KEY-----\nw1\n-----END OPENSSH PRIVATE KEY-----\n" },
|
||||
{ keyName: "id_work_2", keyPath: "/tmp/id_work_2", privateKey: "-----BEGIN OPENSSH PRIVATE KEY-----\nw2\n-----END OPENSSH PRIVATE KEY-----\n" },
|
||||
{ keyName: "id_work_3", keyPath: "/tmp/id_work_3", privateKey: "-----BEGIN OPENSSH PRIVATE KEY-----\nw3\n-----END OPENSSH PRIVATE KEY-----\n" },
|
||||
];
|
||||
const attempts = [];
|
||||
const auth = buildAuthHandler({
|
||||
authMethod: "auto",
|
||||
password: "saved-secret",
|
||||
username: "root",
|
||||
defaultKeys: manyDefaultKeys,
|
||||
unlockedEncryptedKeys: [{
|
||||
keyName: "id_encrypted",
|
||||
privateKey: "-----BEGIN OPENSSH PRIVATE KEY-----\nenc\n-----END OPENSSH PRIVATE KEY-----\n",
|
||||
passphrase: "key-pass",
|
||||
}],
|
||||
allowAgentFallback: false,
|
||||
onAuthAttempt: (label) => attempts.push(label),
|
||||
});
|
||||
|
||||
const labels = collectAuthMethods(auth.authHandler, 24);
|
||||
const passwordIndex = labels.indexOf("password");
|
||||
assert.equal(labels.includes("agent"), false, labels.join(","));
|
||||
assert.ok(passwordIndex >= 0, `expected password; got ${labels.join(",")}`);
|
||||
assert.equal(
|
||||
labels.filter((label) => label === "publickey").length,
|
||||
manyDefaultKeys.length + 1,
|
||||
`expected all default and unlocked keys after password; got ${labels.join(",")}`,
|
||||
);
|
||||
assert.ok(
|
||||
labels.every((label, index) => label !== "publickey" || index > passwordIndex),
|
||||
`password should appear before every default/unlocked publickey; got ${labels.join(",")}`,
|
||||
);
|
||||
const passwordAttemptIndex = attempts.indexOf("password");
|
||||
const firstDefaultKeyAttemptIndex = attempts.findIndex((label) => label.startsWith("key id_"));
|
||||
assert.ok(passwordAttemptIndex >= 0 && firstDefaultKeyAttemptIndex > passwordAttemptIndex, attempts.join(" | "));
|
||||
});
|
||||
|
||||
test("buildAuthHandler automatic mode keeps user key before password and MFA KI before password and default keys", () => {
|
||||
const attempts = [];
|
||||
const auth = buildAuthHandler({
|
||||
authMethod: "auto",
|
||||
privateKey: "-----BEGIN OPENSSH PRIVATE KEY-----\nuser\n-----END OPENSSH PRIVATE KEY-----\n",
|
||||
password: "saved-secret",
|
||||
requiresMfa: true,
|
||||
username: "root",
|
||||
defaultKeys: DEFAULT_KEYS,
|
||||
sshAgentSocketOverride: "/tmp/ssh-agent.sock",
|
||||
onAuthAttempt: (label) => attempts.push(label),
|
||||
});
|
||||
|
||||
const labels = collectAuthMethods(auth.authHandler);
|
||||
assert.deepEqual(labels, [
|
||||
"none",
|
||||
"agent",
|
||||
"publickey",
|
||||
"keyboard-interactive",
|
||||
"password",
|
||||
"publickey",
|
||||
"publickey",
|
||||
]);
|
||||
assert.ok(
|
||||
attempts.indexOf("configured key") < attempts.indexOf("keyboard-interactive")
|
||||
&& attempts.indexOf("keyboard-interactive") < attempts.indexOf("password")
|
||||
&& attempts.indexOf("password") < attempts.indexOf("key id_ed25519"),
|
||||
attempts.join(" | "),
|
||||
);
|
||||
});
|
||||
|
||||
test("buildAuthHandler automatic mode without a saved password keeps default keys first", () => {
|
||||
const auth = buildAuthHandler({
|
||||
authMethod: "auto",
|
||||
username: "root",
|
||||
defaultKeys: DEFAULT_KEYS,
|
||||
allowAgentFallback: false,
|
||||
});
|
||||
|
||||
const labels = collectAuthMethods(auth.authHandler);
|
||||
assert.equal(labels.includes("password"), false, labels.join(","));
|
||||
assert.deepEqual(labels, ["none", "publickey", "publickey", "keyboard-interactive"]);
|
||||
});
|
||||
|
||||
test("buildAuthHandler automatic mode skips an unavailable validated agent", () => {
|
||||
const auth = buildAuthHandler({
|
||||
authMethod: "auto",
|
||||
|
||||
@@ -115,6 +115,10 @@ async function withFakeDefaultKey(run) {
|
||||
const home = fs.mkdtempSync(path.join(os.tmpdir(), "netcatty-auto-auth-"));
|
||||
const sshDir = path.join(home, ".ssh");
|
||||
fs.mkdirSync(sshDir);
|
||||
fs.writeFileSync(
|
||||
path.join(sshDir, "id_ed25519"),
|
||||
"-----BEGIN OPENSSH PRIVATE KEY-----\nfake-ed25519-auto-auth\n-----END OPENSSH PRIVATE KEY-----\n",
|
||||
);
|
||||
fs.writeFileSync(
|
||||
path.join(sshDir, "id_rsa"),
|
||||
"-----BEGIN RSA PRIVATE KEY-----\nMIIBfake-auto-auth\n-----END RSA PRIVATE KEY-----\n",
|
||||
@@ -133,7 +137,7 @@ async function withFakeDefaultKey(run) {
|
||||
}
|
||||
}
|
||||
|
||||
test("SSH start automatic mode tries local keys before its saved password", async (t) => {
|
||||
test("SSH start automatic mode tries its saved password before default local keys (#4478)", async (t) => {
|
||||
await withFakeDefaultKey(async () => {
|
||||
const { bridge, MockSSHClient } = loadBridgeWithMockedSsh2(t);
|
||||
const start = registerStartHandler(bridge, new Map());
|
||||
@@ -155,11 +159,43 @@ test("SSH start automatic mode tries local keys before its saved password", asyn
|
||||
);
|
||||
|
||||
const labels = collectAuthMethods(MockSSHClient.instances[0].connectOpts.authHandler);
|
||||
assert.ok(labels.includes("publickey"), `expected publickey; got ${labels.join(",")}`);
|
||||
assert.ok(labels.indexOf("publickey") < labels.indexOf("password"), labels.join(","));
|
||||
assert.ok(labels.indexOf("publickey") < labels.indexOf("keyboard-interactive"), labels.join(","));
|
||||
const passwordIndex = labels.indexOf("password");
|
||||
const firstKeyIndex = labels.indexOf("publickey");
|
||||
assert.ok(passwordIndex >= 0, `expected password; got ${labels.join(",")}`);
|
||||
assert.ok(firstKeyIndex >= 0, `expected publickey; got ${labels.join(",")}`);
|
||||
assert.ok(
|
||||
labels.every((label, index) => label !== "publickey" || index > passwordIndex),
|
||||
`password should precede all default keys; got ${labels.join(",")}`,
|
||||
);
|
||||
assert.ok(firstKeyIndex < labels.indexOf("keyboard-interactive"), labels.join(","));
|
||||
// Default hosts keep password before keyboard-interactive.
|
||||
assert.ok(labels.indexOf("password") < labels.indexOf("keyboard-interactive"), labels.join(","));
|
||||
assert.ok(passwordIndex < labels.indexOf("keyboard-interactive"), labels.join(","));
|
||||
});
|
||||
});
|
||||
|
||||
test("SSH start automatic mode without a saved password still tries default local keys first", async (t) => {
|
||||
await withFakeDefaultKey(async () => {
|
||||
const { bridge, MockSSHClient } = loadBridgeWithMockedSsh2(t);
|
||||
const start = registerStartHandler(bridge, new Map());
|
||||
|
||||
await assert.rejects(
|
||||
() => start(
|
||||
{ sender: makeSender() },
|
||||
{
|
||||
sessionId: "ssh-auto-auth-no-password",
|
||||
hostname: "192.0.2.9",
|
||||
username: "alice",
|
||||
port: 22,
|
||||
authMethod: "auto",
|
||||
knownHosts: [],
|
||||
},
|
||||
),
|
||||
/Connection timeout/,
|
||||
);
|
||||
|
||||
const labels = collectAuthMethods(MockSSHClient.instances[0].connectOpts.authHandler);
|
||||
assert.equal(labels.includes("password"), false, labels.join(","));
|
||||
assert.deepEqual(labels, ["none", "publickey", "publickey", "keyboard-interactive"]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1842,9 +1842,9 @@ function createStartSessionApi(ctx) {
|
||||
});
|
||||
}
|
||||
|
||||
// Automatic mode intentionally mirrors OpenSSH-style discovery even
|
||||
// when a saved password exists: agent and default keys are tried first,
|
||||
// then the password. Password-only mode never enters this path.
|
||||
// Automatic mode probes ssh-agent before a saved password, while
|
||||
// discovered default ~/.ssh keys stay after any saved password so key
|
||||
// probing cannot exhaust MaxAuthTries first (#4478).
|
||||
if (isAutomaticAuth && !connectOpts.agent && options.useSshAgent !== false) {
|
||||
const automaticAgentSocket = await getAvailableAgentSocket();
|
||||
if (automaticAgentSocket) {
|
||||
@@ -1953,6 +1953,12 @@ function createStartSessionApi(ctx) {
|
||||
if (connectOpts.privateKey && !usedDefaultKeyAsPrimary) {
|
||||
authMethods.push({ type: "publickey", key: connectOpts.privateKey, passphrase: connectOpts.passphrase, id: "publickey-user" });
|
||||
}
|
||||
if (options.requiresMfa && connectOpts.password && !options._skipPasswordMethod) {
|
||||
authMethods.push({ type: "keyboard-interactive", id: "keyboard-interactive" });
|
||||
}
|
||||
if (connectOpts.password && !options._skipPasswordMethod) {
|
||||
authMethods.push({ type: "password", id: "password" });
|
||||
}
|
||||
for (const keyInfo of allDefaultKeys) {
|
||||
authMethods.push({
|
||||
type: "publickey",
|
||||
@@ -1961,12 +1967,6 @@ function createStartSessionApi(ctx) {
|
||||
id: `publickey-default-${keyInfo.keyName}`
|
||||
});
|
||||
}
|
||||
if (options.requiresMfa && connectOpts.password && !options._skipPasswordMethod) {
|
||||
authMethods.push({ type: "keyboard-interactive", id: "keyboard-interactive" });
|
||||
}
|
||||
if (connectOpts.password && !options._skipPasswordMethod) {
|
||||
authMethods.push({ type: "password", id: "password" });
|
||||
}
|
||||
} else {
|
||||
// First try user-configured key if available (explicit user choice)
|
||||
if (connectOpts.privateKey && !usedDefaultKeyAsPrimary) {
|
||||
|
||||
@@ -402,7 +402,7 @@ function createBridgeRegistrar(context) {
|
||||
const owner = electronModule.BrowserWindow.fromWebContents(event.sender);
|
||||
const result = await electronModule.dialog.showOpenDialog(owner || undefined, {
|
||||
title: "Select file to import",
|
||||
properties: ["openFile", "showHiddenFiles"],
|
||||
properties: process.platform === "linux" ? ["openFile"] : ["openFile", "showHiddenFiles"],
|
||||
filters: [{ name: "All Files", extensions: ["*"] }],
|
||||
});
|
||||
return result.canceled ? null : result.filePaths[0] ?? null;
|
||||
@@ -1180,7 +1180,8 @@ function createBridgeRegistrar(context) {
|
||||
// Clipboard helpers for renderer fallback paths (e.g. Monaco paste in Electron)
|
||||
ipcMain.handle("netcatty:clipboard:readText", async () => {
|
||||
try {
|
||||
return clipboard?.readText?.() || "";
|
||||
const text = await clipboard?.readText?.();
|
||||
return typeof text === "string" ? text : "";
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
@@ -1189,7 +1190,7 @@ function createBridgeRegistrar(context) {
|
||||
ipcMain.handle("netcatty:clipboard:writeText", async (_event, text) => {
|
||||
try {
|
||||
if (typeof clipboard?.writeText !== "function") return false;
|
||||
clipboard.writeText(typeof text === "string" ? text : "");
|
||||
await clipboard.writeText(typeof text === "string" ? text : "");
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
@@ -1197,15 +1198,15 @@ function createBridgeRegistrar(context) {
|
||||
});
|
||||
|
||||
ipcMain.handle("netcatty:clipboard:readFiles", async () => {
|
||||
return readClipboardFiles({ clipboard, fsImpl: fs, pathImpl: path });
|
||||
return await readClipboardFiles({ clipboard, fsImpl: fs, pathImpl: path });
|
||||
});
|
||||
|
||||
ipcMain.handle("netcatty:clipboard:readImage", async () => {
|
||||
return readClipboardImage({ clipboard, fsImpl: fs, tempDirBridge });
|
||||
return await readClipboardImage({ clipboard, fsImpl: fs, tempDirBridge });
|
||||
});
|
||||
|
||||
ipcMain.handle("netcatty:clipboard:hasImage", async () => {
|
||||
return hasClipboardImage({ clipboard });
|
||||
return await hasClipboardImage({ clipboard });
|
||||
});
|
||||
|
||||
// Select an application from system file picker
|
||||
@@ -1288,7 +1289,7 @@ function createBridgeRegistrar(context) {
|
||||
title: title || "Select File",
|
||||
defaultPath: defaultPath || os.homedir(),
|
||||
filters: filters || [{ name: "All Files", extensions: ["*"] }],
|
||||
properties: ["openFile", "showHiddenFiles"],
|
||||
properties: process.platform === "linux" ? ["openFile"] : ["openFile", "showHiddenFiles"],
|
||||
});
|
||||
|
||||
if (result.canceled || !result.filePaths.length) {
|
||||
|
||||
@@ -6,6 +6,7 @@ const net = require("node:net");
|
||||
const fs = require("node:fs");
|
||||
const os = require("node:os");
|
||||
const path = require("node:path");
|
||||
const { spawn } = require("node:child_process");
|
||||
const { Client } = require("@modelcontextprotocol/sdk/client/index.js");
|
||||
const { StdioClientTransport } = require("@modelcontextprotocol/sdk/client/stdio.js");
|
||||
|
||||
@@ -84,6 +85,7 @@ function startBridge({ token, authDelayMs = 0, onGetContext = null }) {
|
||||
}
|
||||
if (msg.method === "netcatty/getContext" && onGetContext) {
|
||||
const action = onGetContext(msg, socket);
|
||||
if (action === "hold") return;
|
||||
if (action === "hold-and-close") {
|
||||
socket.destroy();
|
||||
return;
|
||||
@@ -96,7 +98,8 @@ function startBridge({ token, authDelayMs = 0, onGetContext = null }) {
|
||||
});
|
||||
};
|
||||
if (msg.method === "auth/verify" && authDelayMs > 0) {
|
||||
setTimeout(respond, authDelayMs);
|
||||
const timer = setTimeout(respond, authDelayMs);
|
||||
timer.unref?.();
|
||||
} else {
|
||||
respond();
|
||||
}
|
||||
@@ -115,6 +118,9 @@ function startBridge({ token, authDelayMs = 0, onGetContext = null }) {
|
||||
get connections() {
|
||||
return connections;
|
||||
},
|
||||
get activeSockets() {
|
||||
return sockets.size;
|
||||
},
|
||||
destroySockets() {
|
||||
for (const socket of sockets) socket.destroy();
|
||||
},
|
||||
@@ -432,3 +438,229 @@ test("managed stdio calls that race bridge shutdown stay not-connected", {
|
||||
assert.match(errorText(stillAlive), /Not connected to Netcatty/);
|
||||
assert.equal(second.connections, 0);
|
||||
});
|
||||
|
||||
async function waitForExit(proc, timeoutMs = 5000) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (proc.exitCode !== null || proc.signalCode !== null) {
|
||||
resolve({ code: proc.exitCode, signal: proc.signalCode });
|
||||
return;
|
||||
}
|
||||
const timer = setTimeout(() => {
|
||||
proc.off("exit", onExit);
|
||||
reject(new Error(`process ${proc.pid} did not exit within ${timeoutMs}ms`));
|
||||
}, timeoutMs);
|
||||
const onExit = (code, signal) => {
|
||||
clearTimeout(timer);
|
||||
resolve({ code, signal });
|
||||
};
|
||||
proc.once("exit", onExit);
|
||||
});
|
||||
}
|
||||
|
||||
async function waitForCondition(predicate, timeoutMs = 5000) {
|
||||
const deadline = Date.now() + timeoutMs;
|
||||
while (Date.now() < deadline) {
|
||||
if (predicate()) return;
|
||||
await new Promise((resolve) => setTimeout(resolve, 15));
|
||||
}
|
||||
throw new Error(`condition not met within ${timeoutMs}ms`);
|
||||
}
|
||||
|
||||
test("external stdio MCP server exits cleanly on stdin EOF while bridge stays open", async (t) => {
|
||||
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "netcatty-mcp-eof-"));
|
||||
const discoveryPath = path.join(tmp, "discovery.json");
|
||||
const bridge = startBridge({ token: "eof-token" });
|
||||
const port = await bridge.ready;
|
||||
writeDiscovery(discoveryPath, { port, token: "eof-token" });
|
||||
|
||||
const child = spawn(process.execPath, [EXTERNAL_SERVER], {
|
||||
env: childEnv({ NETCATTY_EXTERNAL_MCP_DISCOVERY_FILE: discoveryPath }),
|
||||
stdio: ["pipe", "pipe", "pipe"],
|
||||
});
|
||||
const stderr = [];
|
||||
child.stderr.on("data", (chunk) => stderr.push(String(chunk)));
|
||||
t.after(async () => {
|
||||
if (child.exitCode === null && child.signalCode === null) {
|
||||
try { child.kill("SIGKILL"); } catch { /* ignore */ }
|
||||
}
|
||||
await bridge.close().catch(() => {});
|
||||
fs.rmSync(tmp, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
// Wait for TCP auth to finish so the ref'd TCP socket is live before closing stdin.
|
||||
await waitForCondition(
|
||||
() => bridge.activeSockets === 1 && bridge.calls.some((call) => call.method === "auth/verify"),
|
||||
);
|
||||
|
||||
// Close stdin without sending SIGTERM/SIGKILL -- mirrors MCP client disconnect
|
||||
// and Windows .cmd wrapper teardown where killing cmd.exe does not kill Netcatty.exe.
|
||||
child.stdin.end();
|
||||
|
||||
const { code, signal } = await waitForExit(child, 5000);
|
||||
assert.equal(signal, null, `expected clean exit without signal, stderr:\n${stderr.join("")}`);
|
||||
assert.equal(code, 0, `expected exit code 0, stderr:\n${stderr.join("")}`);
|
||||
await waitForCondition(() => bridge.activeSockets === 0);
|
||||
});
|
||||
|
||||
test("managed stdio MCP server exits cleanly on stdin EOF while bridge stays open", async (t) => {
|
||||
const bridge = startBridge({ token: "managed-eof-token" });
|
||||
const port = await bridge.ready;
|
||||
|
||||
const child = spawn(process.execPath, [MANAGED_SERVER], {
|
||||
env: childEnv({
|
||||
NETCATTY_MCP_PORT: String(port),
|
||||
NETCATTY_MCP_TOKEN: "managed-eof-token",
|
||||
}),
|
||||
stdio: ["pipe", "pipe", "pipe"],
|
||||
});
|
||||
const stderr = [];
|
||||
child.stderr.on("data", (chunk) => stderr.push(String(chunk)));
|
||||
t.after(async () => {
|
||||
if (child.exitCode === null && child.signalCode === null) {
|
||||
try { child.kill("SIGKILL"); } catch { /* ignore */ }
|
||||
}
|
||||
await bridge.close().catch(() => {});
|
||||
});
|
||||
|
||||
await waitForCondition(
|
||||
() => bridge.activeSockets === 1 && bridge.calls.some((call) => call.method === "auth/verify"),
|
||||
);
|
||||
|
||||
child.stdin.end();
|
||||
|
||||
const { code, signal } = await waitForExit(child, 5000);
|
||||
assert.equal(signal, null, `expected clean exit without signal, stderr:\n${stderr.join("")}`);
|
||||
assert.equal(code, 0, `expected exit code 0, stderr:\n${stderr.join("")}`);
|
||||
await waitForCondition(() => bridge.activeSockets === 0);
|
||||
});
|
||||
|
||||
test("external stdio MCP server exits cleanly on stdin EOF even when startup auth stalls", async (t) => {
|
||||
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "netcatty-mcp-eof-startup-"));
|
||||
const discoveryPath = path.join(tmp, "discovery.json");
|
||||
// Hold auth/verify far longer than the exit budget so passing proves stdin
|
||||
// EOF was observed before server.connect(transport) rather than after auth.
|
||||
const bridge = startBridge({ token: "startup-eof-token", authDelayMs: 6000 });
|
||||
const port = await bridge.ready;
|
||||
writeDiscovery(discoveryPath, { port, token: "startup-eof-token" });
|
||||
|
||||
const child = spawn(process.execPath, [EXTERNAL_SERVER], {
|
||||
env: childEnv({ NETCATTY_EXTERNAL_MCP_DISCOVERY_FILE: discoveryPath }),
|
||||
stdio: ["pipe", "pipe", "pipe"],
|
||||
});
|
||||
const stderr = [];
|
||||
child.stderr.on("data", (chunk) => stderr.push(String(chunk)));
|
||||
t.after(async () => {
|
||||
if (child.exitCode === null && child.signalCode === null) {
|
||||
try { child.kill("SIGKILL"); } catch { /* ignore */ }
|
||||
}
|
||||
await bridge.close().catch(() => {});
|
||||
fs.rmSync(tmp, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
const started = Date.now();
|
||||
child.stdin.end();
|
||||
|
||||
const { code, signal } = await waitForExit(child, 3500);
|
||||
assert.ok(Date.now() - started < 4500, "child should exit before stalled startup auth completes");
|
||||
assert.equal(signal, null, `expected clean exit without signal, stderr:\n${stderr.join("")}`);
|
||||
assert.equal(code, 0, `expected exit code 0, stderr:\n${stderr.join("")}`);
|
||||
assert.doesNotMatch(stderr.join(""), /Authenticated with TCP bridge/);
|
||||
await waitForCondition(() => bridge.activeSockets === 0);
|
||||
});
|
||||
|
||||
test("stdio MCP server exits cleanly with exit 0 when debug logging races closed stderr", async (t) => {
|
||||
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "netcatty-mcp-eof-stderr-"));
|
||||
const discoveryPath = path.join(tmp, "discovery.json");
|
||||
const bridge = startBridge({ token: "stderr-eof-token" });
|
||||
const port = await bridge.ready;
|
||||
writeDiscovery(discoveryPath, { port, token: "stderr-eof-token" });
|
||||
|
||||
const child = spawn(process.execPath, [EXTERNAL_SERVER], {
|
||||
env: childEnv({
|
||||
NETCATTY_EXTERNAL_MCP_DISCOVERY_FILE: discoveryPath,
|
||||
NETCATTY_MCP_DEBUG: "1",
|
||||
}),
|
||||
stdio: ["pipe", "pipe", "pipe"],
|
||||
});
|
||||
t.after(async () => {
|
||||
if (child.exitCode === null && child.signalCode === null) {
|
||||
try { child.kill("SIGKILL"); } catch { /* ignore */ }
|
||||
}
|
||||
await bridge.close().catch(() => {});
|
||||
fs.rmSync(tmp, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
await waitForCondition(
|
||||
() => bridge.activeSockets === 1 && bridge.calls.some((call) => call.method === "auth/verify"),
|
||||
);
|
||||
|
||||
// Destroy stderr and stdout read ends to simulate abrupt client crash with
|
||||
// debug logging enabled, then close stdin.
|
||||
child.stderr.destroy();
|
||||
child.stdout.destroy();
|
||||
child.stdin.end();
|
||||
|
||||
const { code, signal } = await waitForExit(child, 5000);
|
||||
assert.equal(signal, null);
|
||||
assert.equal(code, 0);
|
||||
await waitForCondition(() => bridge.activeSockets === 0);
|
||||
});
|
||||
|
||||
test("stdio MCP server exits cleanly on stdin EOF while an RPC call is in flight", async (t) => {
|
||||
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "netcatty-mcp-eof-inflight-"));
|
||||
const discoveryPath = path.join(tmp, "discovery.json");
|
||||
const bridge = startBridge({
|
||||
token: "inflight-eof-token",
|
||||
onGetContext: () => "hold",
|
||||
});
|
||||
const port = await bridge.ready;
|
||||
writeDiscovery(discoveryPath, { port, token: "inflight-eof-token" });
|
||||
|
||||
const child = spawn(process.execPath, [EXTERNAL_SERVER], {
|
||||
env: childEnv({ NETCATTY_EXTERNAL_MCP_DISCOVERY_FILE: discoveryPath }),
|
||||
stdio: ["pipe", "pipe", "pipe"],
|
||||
});
|
||||
const stderr = [];
|
||||
child.stderr.on("data", (chunk) => stderr.push(String(chunk)));
|
||||
t.after(async () => {
|
||||
if (child.exitCode === null && child.signalCode === null) {
|
||||
try { child.kill("SIGKILL"); } catch { /* ignore */ }
|
||||
}
|
||||
await bridge.close().catch(() => {});
|
||||
fs.rmSync(tmp, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
await waitForCondition(
|
||||
() => bridge.activeSockets === 1 && bridge.calls.some((call) => call.method === "auth/verify"),
|
||||
);
|
||||
|
||||
// Initialize MCP session and issue a tool call whose bridge RPC stays pending.
|
||||
child.stdin.write(`${JSON.stringify({
|
||||
jsonrpc: "2.0",
|
||||
id: 1,
|
||||
method: "initialize",
|
||||
params: {
|
||||
protocolVersion: "2024-11-05",
|
||||
capabilities: {},
|
||||
clientInfo: { name: "eof-inflight-test", version: "1" },
|
||||
},
|
||||
})}\n`);
|
||||
child.stdin.write(`${JSON.stringify({
|
||||
jsonrpc: "2.0",
|
||||
method: "notifications/initialized",
|
||||
})}\n`);
|
||||
child.stdin.write(`${JSON.stringify({
|
||||
jsonrpc: "2.0",
|
||||
id: 2,
|
||||
method: "tools/call",
|
||||
params: { name: "get_environment", arguments: {} },
|
||||
})}\n`);
|
||||
|
||||
await waitForCondition(() => bridge.calls.some((call) => call.method === "netcatty/getContext"));
|
||||
child.stdin.end();
|
||||
|
||||
const { code, signal } = await waitForExit(child, 5000);
|
||||
assert.equal(signal, null, `expected clean exit without signal, stderr:\n${stderr.join("")}`);
|
||||
assert.equal(code, 0, `expected exit code 0, stderr:\n${stderr.join("")}`);
|
||||
await waitForCondition(() => bridge.activeSockets === 0);
|
||||
});
|
||||
@@ -0,0 +1,256 @@
|
||||
"use strict";
|
||||
|
||||
const DEFAULT_FORCE_EXIT_MS = 500;
|
||||
const DEFAULT_PARENT_POLL_INTERVAL_MS = 5000;
|
||||
const STREAM_DISCONNECT_ERROR_CODES = new Set([
|
||||
"EPIPE",
|
||||
"ECONNRESET",
|
||||
"EOF",
|
||||
"ERR_STREAM_DESTROYED",
|
||||
"ERR_STREAM_WRITE_AFTER_END",
|
||||
]);
|
||||
const POSIX_SHUTDOWN_SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
||||
const WIN32_SHUTDOWN_SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP", "SIGBREAK"];
|
||||
|
||||
/**
|
||||
* Manages graceful shutdown for stdio-based MCP server processes so they exit
|
||||
* promptly when the MCP client disconnects (stdin EOF/close, stdout broken
|
||||
* pipe/close, transport close, termination signal, or dead parent on Windows)
|
||||
* instead of staying alive indefinitely behind an open TCP bridge socket.
|
||||
*/
|
||||
function createMcpStdioLifecycle({
|
||||
stdin = process.stdin,
|
||||
stdout = process.stdout,
|
||||
proc = process,
|
||||
onShutdown = () => {},
|
||||
onLog = () => {},
|
||||
exit = (code) => proc.exit(code),
|
||||
forceExitMs = DEFAULT_FORCE_EXIT_MS,
|
||||
watchParentPid = proc.platform === "win32",
|
||||
parentPollIntervalMs = DEFAULT_PARENT_POLL_INTERVAL_MS,
|
||||
} = {}) {
|
||||
const initialPpid = Number(proc?.ppid);
|
||||
let attached = false;
|
||||
let shuttingDown = false;
|
||||
let shutdownPromise = null;
|
||||
let forceExitTimer = null;
|
||||
let parentPollTimer = null;
|
||||
const signalHandlers = [];
|
||||
const transportBindings = [];
|
||||
|
||||
function safeLog(message, meta) {
|
||||
try {
|
||||
onLog(message, meta);
|
||||
} catch {
|
||||
// Logging failures during teardown must never block shutdown.
|
||||
}
|
||||
}
|
||||
|
||||
function isParentGone() {
|
||||
if (!Number.isInteger(initialPpid) || initialPpid <= 1) return false;
|
||||
try {
|
||||
proc.kill(initialPpid, 0);
|
||||
return false;
|
||||
} catch (err) {
|
||||
return err?.code === "ESRCH";
|
||||
}
|
||||
}
|
||||
|
||||
function clearTimers() {
|
||||
if (parentPollTimer) {
|
||||
clearInterval(parentPollTimer);
|
||||
parentPollTimer = null;
|
||||
}
|
||||
if (forceExitTimer) {
|
||||
clearTimeout(forceExitTimer);
|
||||
forceExitTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
const onStdinEnd = () => {
|
||||
void shutdown("stdin_end");
|
||||
};
|
||||
const onStdinClose = () => {
|
||||
void shutdown("stdin_close");
|
||||
};
|
||||
const onStdinError = (err) => {
|
||||
const code = err?.code;
|
||||
const exitCode = STREAM_DISCONNECT_ERROR_CODES.has(code) ? 0 : 1;
|
||||
void shutdown(`stdin_error:${code || "unknown"}`, { exitCode });
|
||||
};
|
||||
const onStdoutClose = () => {
|
||||
void shutdown("stdout_close");
|
||||
};
|
||||
const onStdoutError = (err) => {
|
||||
const code = err?.code;
|
||||
const exitCode = STREAM_DISCONNECT_ERROR_CODES.has(code) ? 0 : 1;
|
||||
void shutdown(`stdout_error:${code || "unknown"}`, { exitCode });
|
||||
};
|
||||
|
||||
function unbindTransports() {
|
||||
for (const binding of transportBindings.splice(0)) {
|
||||
binding.active = false;
|
||||
if (binding.transport.onclose === binding.wrapper) {
|
||||
binding.transport.onclose = binding.previousOnClose;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function stopShutdownTriggers({ keepStreamErrorHandlers = false } = {}) {
|
||||
if (parentPollTimer) {
|
||||
clearInterval(parentPollTimer);
|
||||
parentPollTimer = null;
|
||||
}
|
||||
unbindTransports();
|
||||
if (!attached) return;
|
||||
stdin?.off?.("end", onStdinEnd);
|
||||
stdin?.off?.("close", onStdinClose);
|
||||
stdout?.off?.("close", onStdoutClose);
|
||||
for (const { signal, handler } of signalHandlers.splice(0)) {
|
||||
proc?.off?.(signal, handler);
|
||||
}
|
||||
if (!keepStreamErrorHandlers) {
|
||||
stdin?.off?.("error", onStdinError);
|
||||
stdout?.off?.("error", onStdoutError);
|
||||
attached = false;
|
||||
}
|
||||
}
|
||||
|
||||
function detach() {
|
||||
stopShutdownTriggers({ keepStreamErrorHandlers: false });
|
||||
}
|
||||
|
||||
function shutdown(reason = "shutdown", { exitCode = 0 } = {}) {
|
||||
if (shuttingDown) return shutdownPromise;
|
||||
shuttingDown = true;
|
||||
safeLog("Shutting down MCP server", { reason, exitCode });
|
||||
// Keep stdin/stdout error listeners attached while async onShutdown runs so
|
||||
// late EPIPE/ECONNRESET events on closing pipes cannot crash with exit 1.
|
||||
stopShutdownTriggers({ keepStreamErrorHandlers: true });
|
||||
|
||||
let exited = false;
|
||||
const finishExit = () => {
|
||||
if (exited) return;
|
||||
exited = true;
|
||||
clearTimers();
|
||||
exit(exitCode);
|
||||
};
|
||||
|
||||
forceExitTimer = setTimeout(finishExit, forceExitMs);
|
||||
if (exitCode === 0) {
|
||||
forceExitTimer.unref?.();
|
||||
}
|
||||
|
||||
shutdownPromise = Promise.resolve()
|
||||
.then(() => onShutdown(reason))
|
||||
.catch((err) => {
|
||||
safeLog("Error during MCP server shutdown", {
|
||||
reason,
|
||||
message: err?.message || String(err),
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
finishExit();
|
||||
});
|
||||
|
||||
return shutdownPromise;
|
||||
}
|
||||
|
||||
function attach() {
|
||||
if (attached || shuttingDown) return;
|
||||
attached = true;
|
||||
|
||||
stdin?.on?.("end", onStdinEnd);
|
||||
stdin?.on?.("close", onStdinClose);
|
||||
stdin?.on?.("error", onStdinError);
|
||||
stdout?.on?.("close", onStdoutClose);
|
||||
stdout?.on?.("error", onStdoutError);
|
||||
|
||||
const signals = proc?.platform === "win32"
|
||||
? WIN32_SHUTDOWN_SIGNALS
|
||||
: POSIX_SHUTDOWN_SIGNALS;
|
||||
for (const signal of signals) {
|
||||
const handler = () => {
|
||||
void shutdown(`signal:${signal}`);
|
||||
};
|
||||
try {
|
||||
proc?.on?.(signal, handler);
|
||||
signalHandlers.push({ signal, handler });
|
||||
} catch {
|
||||
// Ignore unsupported signals on constrained platforms.
|
||||
}
|
||||
}
|
||||
|
||||
if (stdin?.readableEnded || stdin?.destroyed) {
|
||||
void shutdown("stdin_already_closed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (stdout?.writableEnded || stdout?.destroyed) {
|
||||
void shutdown("stdout_already_closed");
|
||||
return;
|
||||
}
|
||||
|
||||
// Start observing the underlying stdin pipe without switching to flowing
|
||||
// mode or consuming buffered bytes, so immediate/startup EOF fires before
|
||||
// StdioServerTransport attaches its data listener.
|
||||
if (stdin?.readableFlowing === null && typeof stdin.read === "function") {
|
||||
try {
|
||||
stdin.read(0);
|
||||
} catch {
|
||||
// Ignore non-standard stdin implementations.
|
||||
}
|
||||
if (shuttingDown) return;
|
||||
}
|
||||
|
||||
if (watchParentPid && Number.isInteger(initialPpid) && initialPpid > 1) {
|
||||
if (isParentGone()) {
|
||||
void shutdown("parent_exited");
|
||||
return;
|
||||
}
|
||||
parentPollTimer = setInterval(() => {
|
||||
if (isParentGone()) {
|
||||
void shutdown("parent_exited");
|
||||
}
|
||||
}, parentPollIntervalMs);
|
||||
parentPollTimer.unref?.();
|
||||
}
|
||||
}
|
||||
|
||||
function bindTransport(transport) {
|
||||
if (!transport) return;
|
||||
const previousOnClose = transport.onclose;
|
||||
const binding = {
|
||||
transport,
|
||||
previousOnClose,
|
||||
wrapper: null,
|
||||
active: true,
|
||||
};
|
||||
const wrapper = () => {
|
||||
try {
|
||||
previousOnClose?.();
|
||||
} finally {
|
||||
if (binding.active) {
|
||||
void shutdown("transport_close");
|
||||
}
|
||||
}
|
||||
};
|
||||
binding.wrapper = wrapper;
|
||||
transport.onclose = wrapper;
|
||||
transportBindings.push(binding);
|
||||
}
|
||||
|
||||
return {
|
||||
attach,
|
||||
detach,
|
||||
bindTransport,
|
||||
shutdown,
|
||||
isShuttingDown: () => shuttingDown,
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createMcpStdioLifecycle,
|
||||
DEFAULT_FORCE_EXIT_MS,
|
||||
DEFAULT_PARENT_POLL_INTERVAL_MS,
|
||||
};
|
||||
@@ -0,0 +1,448 @@
|
||||
"use strict";
|
||||
|
||||
const { test } = require("node:test");
|
||||
const assert = require("node:assert/strict");
|
||||
const { EventEmitter } = require("node:events");
|
||||
const { createMcpStdioLifecycle } = require("./mcpStdioLifecycle.cjs");
|
||||
|
||||
function createFakeProcess(overrides = {}) {
|
||||
const proc = new EventEmitter();
|
||||
proc.platform = "linux";
|
||||
proc.ppid = 4242;
|
||||
proc.kill = () => true;
|
||||
proc.exit = () => {};
|
||||
return Object.assign(proc, overrides);
|
||||
}
|
||||
|
||||
function createExitWaiter(timeoutMs = 2000) {
|
||||
const exits = [];
|
||||
let resolveExit;
|
||||
const exited = new Promise((resolve, reject) => {
|
||||
// Keep this timer referenced until exit() clears it so isolated unit tests
|
||||
// with fake streams and unref'd lifecycle timers stay alive until shutdown.
|
||||
const timer = setTimeout(() => {
|
||||
reject(new Error(`exit was not called within ${timeoutMs}ms`));
|
||||
}, timeoutMs);
|
||||
resolveExit = (code) => {
|
||||
clearTimeout(timer);
|
||||
resolve(code);
|
||||
};
|
||||
});
|
||||
return {
|
||||
exits,
|
||||
exited,
|
||||
exit: (code) => {
|
||||
exits.push(code);
|
||||
resolveExit(code);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
test("exits cleanly on stdin end and ignores duplicate triggers", async () => {
|
||||
const stdin = new EventEmitter();
|
||||
const stdout = new EventEmitter();
|
||||
const proc = createFakeProcess();
|
||||
const reasons = [];
|
||||
const { exits, exit } = createExitWaiter();
|
||||
|
||||
const lifecycle = createMcpStdioLifecycle({
|
||||
stdin,
|
||||
stdout,
|
||||
proc,
|
||||
watchParentPid: false,
|
||||
onShutdown: async (reason) => {
|
||||
reasons.push(reason);
|
||||
},
|
||||
exit,
|
||||
});
|
||||
|
||||
lifecycle.attach();
|
||||
stdin.emit("end");
|
||||
stdin.emit("close");
|
||||
proc.emit("SIGTERM");
|
||||
|
||||
await lifecycle.shutdown("manual");
|
||||
assert.deepEqual(reasons, ["stdin_end"]);
|
||||
assert.deepEqual(exits, [0]);
|
||||
assert.equal(lifecycle.isShuttingDown(), true);
|
||||
});
|
||||
|
||||
test("exits immediately on attach when stdin or stdout is already closed", async () => {
|
||||
{
|
||||
const stdin = Object.assign(new EventEmitter(), { readableEnded: true });
|
||||
const stdout = new EventEmitter();
|
||||
const proc = createFakeProcess();
|
||||
const reasons = [];
|
||||
const { exits, exited, exit } = createExitWaiter();
|
||||
|
||||
const lifecycle = createMcpStdioLifecycle({
|
||||
stdin,
|
||||
stdout,
|
||||
proc,
|
||||
watchParentPid: false,
|
||||
onShutdown: (reason) => reasons.push(reason),
|
||||
exit,
|
||||
});
|
||||
|
||||
lifecycle.attach();
|
||||
assert.equal(await exited, 0);
|
||||
assert.deepEqual(reasons, ["stdin_already_closed"]);
|
||||
assert.deepEqual(exits, [0]);
|
||||
}
|
||||
|
||||
{
|
||||
const stdin = new EventEmitter();
|
||||
const stdout = Object.assign(new EventEmitter(), { writableEnded: true });
|
||||
const proc = createFakeProcess();
|
||||
const reasons = [];
|
||||
const { exits, exited, exit } = createExitWaiter();
|
||||
|
||||
const lifecycle = createMcpStdioLifecycle({
|
||||
stdin,
|
||||
stdout,
|
||||
proc,
|
||||
watchParentPid: false,
|
||||
onShutdown: (reason) => reasons.push(reason),
|
||||
exit,
|
||||
});
|
||||
|
||||
lifecycle.attach();
|
||||
assert.equal(await exited, 0);
|
||||
assert.deepEqual(reasons, ["stdout_already_closed"]);
|
||||
assert.deepEqual(exits, [0]);
|
||||
}
|
||||
});
|
||||
|
||||
test("primes paused stdin via read(0) without consuming buffered data", () => {
|
||||
const readCalls = [];
|
||||
const stdin = Object.assign(new EventEmitter(), {
|
||||
readableFlowing: null,
|
||||
read: (size) => {
|
||||
readCalls.push(size);
|
||||
return null;
|
||||
},
|
||||
});
|
||||
const stdout = new EventEmitter();
|
||||
const proc = createFakeProcess();
|
||||
|
||||
const lifecycle = createMcpStdioLifecycle({
|
||||
stdin,
|
||||
stdout,
|
||||
proc,
|
||||
watchParentPid: false,
|
||||
});
|
||||
|
||||
lifecycle.attach();
|
||||
assert.deepEqual(readCalls, [0]);
|
||||
assert.equal(stdin.listenerCount("data"), 0);
|
||||
lifecycle.detach();
|
||||
});
|
||||
|
||||
test("handles stdout EPIPE as clean exit and unexpected stdout error as exit 1", async () => {
|
||||
{
|
||||
const stdin = new EventEmitter();
|
||||
const stdout = new EventEmitter();
|
||||
const proc = createFakeProcess();
|
||||
const { exits, exited, exit } = createExitWaiter();
|
||||
const lifecycle = createMcpStdioLifecycle({
|
||||
stdin,
|
||||
stdout,
|
||||
proc,
|
||||
watchParentPid: false,
|
||||
exit,
|
||||
});
|
||||
lifecycle.attach();
|
||||
stdout.emit("error", Object.assign(new Error("broken pipe"), { code: "EPIPE" }));
|
||||
assert.equal(await exited, 0);
|
||||
assert.deepEqual(exits, [0]);
|
||||
}
|
||||
|
||||
{
|
||||
const stdin = new EventEmitter();
|
||||
const stdout = new EventEmitter();
|
||||
const proc = createFakeProcess();
|
||||
const { exits, exited, exit } = createExitWaiter();
|
||||
const lifecycle = createMcpStdioLifecycle({
|
||||
stdin,
|
||||
stdout,
|
||||
proc,
|
||||
watchParentPid: false,
|
||||
exit,
|
||||
});
|
||||
lifecycle.attach();
|
||||
stdout.emit("error", Object.assign(new Error("io failure"), { code: "EIO" }));
|
||||
assert.equal(await exited, 1);
|
||||
assert.deepEqual(exits, [1]);
|
||||
}
|
||||
});
|
||||
|
||||
test("handles stdin ECONNRESET cleanly and unexpected stdin error with exit 1", async () => {
|
||||
{
|
||||
const stdin = new EventEmitter();
|
||||
const stdout = new EventEmitter();
|
||||
const proc = createFakeProcess();
|
||||
const { exits, exited, exit } = createExitWaiter();
|
||||
const lifecycle = createMcpStdioLifecycle({
|
||||
stdin,
|
||||
stdout,
|
||||
proc,
|
||||
watchParentPid: false,
|
||||
exit,
|
||||
});
|
||||
lifecycle.attach();
|
||||
stdin.emit("error", Object.assign(new Error("reset"), { code: "ECONNRESET" }));
|
||||
assert.equal(await exited, 0);
|
||||
assert.deepEqual(exits, [0]);
|
||||
}
|
||||
|
||||
{
|
||||
const stdin = new EventEmitter();
|
||||
const stdout = new EventEmitter();
|
||||
const proc = createFakeProcess();
|
||||
const { exits, exited, exit } = createExitWaiter();
|
||||
const lifecycle = createMcpStdioLifecycle({
|
||||
stdin,
|
||||
stdout,
|
||||
proc,
|
||||
watchParentPid: false,
|
||||
exit,
|
||||
});
|
||||
lifecycle.attach();
|
||||
stdin.emit("error", Object.assign(new Error("io error"), { code: "EIO" }));
|
||||
assert.equal(await exited, 1);
|
||||
assert.deepEqual(exits, [1]);
|
||||
}
|
||||
});
|
||||
|
||||
test("keeps stdin and stdout error handlers alive during async onShutdown", async () => {
|
||||
const stdin = new EventEmitter();
|
||||
const stdout = new EventEmitter();
|
||||
const proc = createFakeProcess();
|
||||
const { exits, exited, exit } = createExitWaiter();
|
||||
let finishShutdown;
|
||||
let resolveStarted;
|
||||
const shutdownStarted = new Promise((resolve) => {
|
||||
resolveStarted = resolve;
|
||||
});
|
||||
|
||||
const lifecycle = createMcpStdioLifecycle({
|
||||
stdin,
|
||||
stdout,
|
||||
proc,
|
||||
watchParentPid: false,
|
||||
onShutdown: () => new Promise((resolve) => {
|
||||
finishShutdown = resolve;
|
||||
resolveStarted();
|
||||
}),
|
||||
exit,
|
||||
});
|
||||
|
||||
lifecycle.attach();
|
||||
stdin.emit("end");
|
||||
await shutdownStarted;
|
||||
|
||||
// Emit stream errors asynchronously while onShutdown is still pending.
|
||||
assert.doesNotThrow(() => {
|
||||
stdout.emit("error", Object.assign(new Error("broken pipe"), { code: "EPIPE" }));
|
||||
stdin.emit("error", Object.assign(new Error("reset"), { code: "ECONNRESET" }));
|
||||
});
|
||||
|
||||
finishShutdown();
|
||||
assert.equal(await exited, 0);
|
||||
assert.deepEqual(exits, [0]);
|
||||
});
|
||||
|
||||
test("swallows onLog and onShutdown errors and still exits cleanly", async () => {
|
||||
const stdin = new EventEmitter();
|
||||
const stdout = new EventEmitter();
|
||||
const proc = createFakeProcess();
|
||||
const { exits, exited, exit } = createExitWaiter();
|
||||
|
||||
const lifecycle = createMcpStdioLifecycle({
|
||||
stdin,
|
||||
stdout,
|
||||
proc,
|
||||
watchParentPid: false,
|
||||
onLog: () => {
|
||||
throw new Error("stderr EPIPE");
|
||||
},
|
||||
onShutdown: async () => {
|
||||
throw new Error("close failed");
|
||||
},
|
||||
exit,
|
||||
});
|
||||
|
||||
lifecycle.attach();
|
||||
stdin.emit("end");
|
||||
assert.equal(await exited, 0);
|
||||
assert.deepEqual(exits, [0]);
|
||||
});
|
||||
|
||||
test("bindTransport preserves existing onclose handler and triggers shutdown", async () => {
|
||||
const stdin = new EventEmitter();
|
||||
const stdout = new EventEmitter();
|
||||
const proc = createFakeProcess();
|
||||
const order = [];
|
||||
const { exits, exited, exit } = createExitWaiter();
|
||||
|
||||
const lifecycle = createMcpStdioLifecycle({
|
||||
stdin,
|
||||
stdout,
|
||||
proc,
|
||||
watchParentPid: false,
|
||||
onShutdown: (reason) => order.push(`shutdown:${reason}`),
|
||||
exit,
|
||||
});
|
||||
|
||||
const transport = {
|
||||
onclose: () => order.push("prev_onclose"),
|
||||
};
|
||||
lifecycle.bindTransport(transport);
|
||||
lifecycle.attach();
|
||||
|
||||
transport.onclose();
|
||||
assert.equal(await exited, 0);
|
||||
assert.deepEqual(order, ["prev_onclose", "shutdown:transport_close"]);
|
||||
assert.deepEqual(exits, [0]);
|
||||
});
|
||||
|
||||
test("forces exit if onShutdown hangs past forceExitMs", async () => {
|
||||
const stdin = new EventEmitter();
|
||||
const stdout = new EventEmitter();
|
||||
const proc = createFakeProcess();
|
||||
const { exits, exited, exit } = createExitWaiter();
|
||||
|
||||
const lifecycle = createMcpStdioLifecycle({
|
||||
stdin,
|
||||
stdout,
|
||||
proc,
|
||||
watchParentPid: false,
|
||||
forceExitMs: 25,
|
||||
onShutdown: () => new Promise(() => {}),
|
||||
exit,
|
||||
});
|
||||
|
||||
lifecycle.attach();
|
||||
proc.emit("SIGINT");
|
||||
assert.equal(await exited, 0);
|
||||
assert.deepEqual(exits, [0]);
|
||||
});
|
||||
|
||||
test("parent PID watchdog exits immediately when parent is already gone on attach", async () => {
|
||||
const stdin = new EventEmitter();
|
||||
const stdout = new EventEmitter();
|
||||
const proc = createFakeProcess({
|
||||
platform: "win32",
|
||||
ppid: 9999,
|
||||
kill: () => {
|
||||
throw Object.assign(new Error("no such process"), { code: "ESRCH" });
|
||||
},
|
||||
});
|
||||
const reasons = [];
|
||||
const { exits, exited, exit } = createExitWaiter();
|
||||
|
||||
const lifecycle = createMcpStdioLifecycle({
|
||||
stdin,
|
||||
stdout,
|
||||
proc,
|
||||
watchParentPid: true,
|
||||
onShutdown: (reason) => reasons.push(reason),
|
||||
exit,
|
||||
});
|
||||
|
||||
lifecycle.attach();
|
||||
assert.equal(await exited, 0);
|
||||
assert.deepEqual(reasons, ["parent_exited"]);
|
||||
assert.deepEqual(exits, [0]);
|
||||
});
|
||||
|
||||
test("parent PID watchdog exits on ESRCH but treats EPERM as alive", async () => {
|
||||
const stdin = new EventEmitter();
|
||||
const stdout = new EventEmitter();
|
||||
let state = "eperm";
|
||||
let killChecks = 0;
|
||||
let resolveEpermChecks;
|
||||
const epermObserved = new Promise((resolve) => {
|
||||
resolveEpermChecks = resolve;
|
||||
});
|
||||
const proc = createFakeProcess({
|
||||
platform: "win32",
|
||||
ppid: 9999,
|
||||
kill: () => {
|
||||
killChecks += 1;
|
||||
if (state === "eperm") {
|
||||
if (killChecks >= 3) resolveEpermChecks();
|
||||
throw Object.assign(new Error("not permitted"), { code: "EPERM" });
|
||||
}
|
||||
if (state === "esrch") {
|
||||
throw Object.assign(new Error("no such process"), { code: "ESRCH" });
|
||||
}
|
||||
return true;
|
||||
},
|
||||
});
|
||||
const reasons = [];
|
||||
const { exits, exited, exit } = createExitWaiter();
|
||||
|
||||
const lifecycle = createMcpStdioLifecycle({
|
||||
stdin,
|
||||
stdout,
|
||||
proc,
|
||||
watchParentPid: true,
|
||||
parentPollIntervalMs: 10,
|
||||
onShutdown: (reason) => reasons.push(reason),
|
||||
exit,
|
||||
});
|
||||
|
||||
lifecycle.attach();
|
||||
await epermObserved;
|
||||
assert.deepEqual(reasons, []);
|
||||
assert.deepEqual(exits, []);
|
||||
|
||||
state = "esrch";
|
||||
assert.equal(await exited, 0);
|
||||
assert.deepEqual(reasons, ["parent_exited"]);
|
||||
assert.deepEqual(exits, [0]);
|
||||
});
|
||||
|
||||
test("detach removes listeners and unbinds transport wrappers", () => {
|
||||
const stdin = new EventEmitter();
|
||||
const stdout = new EventEmitter();
|
||||
const proc = createFakeProcess({ platform: "win32" });
|
||||
const exits = [];
|
||||
let prevCloseCalls = 0;
|
||||
const prevOnClose = () => {
|
||||
prevCloseCalls += 1;
|
||||
};
|
||||
const transport = { onclose: prevOnClose };
|
||||
|
||||
const lifecycle = createMcpStdioLifecycle({
|
||||
stdin,
|
||||
stdout,
|
||||
proc,
|
||||
watchParentPid: false,
|
||||
exit: (code) => exits.push(code),
|
||||
});
|
||||
|
||||
lifecycle.bindTransport(transport);
|
||||
lifecycle.attach();
|
||||
assert.equal(stdin.listenerCount("end"), 1);
|
||||
assert.equal(stdin.listenerCount("close"), 1);
|
||||
assert.equal(stdin.listenerCount("error"), 1);
|
||||
assert.equal(stdout.listenerCount("close"), 1);
|
||||
assert.equal(stdout.listenerCount("error"), 1);
|
||||
assert.equal(proc.listenerCount("SIGBREAK"), 1);
|
||||
|
||||
lifecycle.detach();
|
||||
assert.equal(stdin.listenerCount("end"), 0);
|
||||
assert.equal(stdin.listenerCount("close"), 0);
|
||||
assert.equal(stdin.listenerCount("error"), 0);
|
||||
assert.equal(stdout.listenerCount("close"), 0);
|
||||
assert.equal(stdout.listenerCount("error"), 0);
|
||||
assert.equal(proc.listenerCount("SIGBREAK"), 0);
|
||||
assert.equal(transport.onclose, prevOnClose);
|
||||
|
||||
stdin.emit("end");
|
||||
transport.onclose();
|
||||
assert.equal(prevCloseCalls, 1);
|
||||
assert.deepEqual(exits, []);
|
||||
});
|
||||
@@ -15,6 +15,7 @@ const { getCatalogToolDescription } = require("./catalogToolMetadata.cjs");
|
||||
const { NETCATTY_MCP_SERVER_INSTRUCTIONS } = require("./netcattyMcpInstructions.cjs");
|
||||
const { registerProgressiveMcpTools } = require("./progressiveMcpTools.cjs");
|
||||
const { normalizeMcpJsonRpcMessage } = require("./normalizeMcpCallArguments.cjs");
|
||||
const { createMcpStdioLifecycle } = require("./mcpStdioLifecycle.cjs");
|
||||
|
||||
function catalogDescription(toolName, fallback) {
|
||||
return getCatalogToolDescription(toolName) || fallback;
|
||||
@@ -24,6 +25,9 @@ const { createPrivacyBoundary } = require("./externalMcpPrivacyBoundary.cjs");
|
||||
|
||||
const DEBUG_MCP = process.env.NETCATTY_MCP_DEBUG === "1";
|
||||
|
||||
// Avoid uncaught EPIPE crashes when the client closes stderr during teardown.
|
||||
process.stderr.on("error", () => {});
|
||||
|
||||
function debugLog(...args) {
|
||||
if (!DEBUG_MCP) return;
|
||||
process.stderr.write(`[netcatty-mcp:debug] ${args.map(arg => {
|
||||
@@ -123,10 +127,18 @@ function guardWriteOperation(command, { skipBlocklist = false } = {}) {
|
||||
}
|
||||
|
||||
let tcpSocket = null;
|
||||
let connectingSocket = null;
|
||||
let pendingRequests = new Map(); // id -> { resolve, reject, sock }
|
||||
let nextRpcId = 1;
|
||||
let tcpBuffer = "";
|
||||
|
||||
function rejectAllPending(message) {
|
||||
for (const [id, pending] of pendingRequests) {
|
||||
pendingRequests.delete(id);
|
||||
pending.reject(new Error(message));
|
||||
}
|
||||
}
|
||||
|
||||
// `destroyed` stays false after the peer FIN has already moved readyState to
|
||||
// "closed". Writing in that window hits writeAfterFIN and rejects the call
|
||||
// with "TCP connection lost" instead of reconnecting.
|
||||
@@ -154,11 +166,33 @@ function rejectPendingOnSocket(sock, externalMessage) {
|
||||
|
||||
function connectTcp() {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (lifecycle.isShuttingDown()) {
|
||||
reject(new Error("MCP server is shutting down"));
|
||||
return;
|
||||
}
|
||||
let settled = false;
|
||||
const finishResolve = () => {
|
||||
if (settled) return;
|
||||
settled = true;
|
||||
resolve();
|
||||
};
|
||||
const finishReject = (err) => {
|
||||
if (settled) return;
|
||||
settled = true;
|
||||
reject(err);
|
||||
};
|
||||
const sock = net.createConnection({ host: "127.0.0.1", port: NETCATTY_MCP_PORT }, () => {
|
||||
if (connectingSocket === sock) connectingSocket = null;
|
||||
if (lifecycle.isShuttingDown()) {
|
||||
sock.destroy();
|
||||
finishReject(new Error("MCP server is shutting down"));
|
||||
return;
|
||||
}
|
||||
tcpSocket = sock;
|
||||
debugLog("Connected to TCP bridge", { port: NETCATTY_MCP_PORT });
|
||||
resolve();
|
||||
finishResolve();
|
||||
});
|
||||
connectingSocket = sock;
|
||||
sock.setEncoding("utf-8");
|
||||
const MAX_BUFFER_SIZE = 10 * 1024 * 1024; // 10 MB
|
||||
sock.on("data", (chunk) => {
|
||||
@@ -196,15 +230,18 @@ function connectTcp() {
|
||||
}
|
||||
});
|
||||
sock.on("error", (err) => {
|
||||
if (connectingSocket === sock) connectingSocket = null;
|
||||
debugLog("TCP socket error", { message: err?.message || String(err) });
|
||||
reject(err);
|
||||
finishReject(err);
|
||||
// External in-flight calls stay rejected and are not replayed.
|
||||
// Managed children do not reread discovery, so a call that races the
|
||||
// dead socket fails as not-connected rather than "TCP connection lost".
|
||||
rejectPendingOnSocket(sock, "TCP connection lost");
|
||||
});
|
||||
sock.on("close", () => {
|
||||
if (connectingSocket === sock) connectingSocket = null;
|
||||
debugLog("TCP socket closed");
|
||||
finishReject(new Error("TCP connection closed"));
|
||||
rejectPendingOnSocket(sock, "TCP connection closed");
|
||||
if (tcpSocket === sock) tcpSocket = null;
|
||||
});
|
||||
@@ -251,9 +288,14 @@ function refreshExternalEndpoint() {
|
||||
}
|
||||
|
||||
function dropActiveSocket() {
|
||||
const pendingSock = connectingSocket;
|
||||
connectingSocket = null;
|
||||
const sock = tcpSocket;
|
||||
tcpSocket = null;
|
||||
tcpBuffer = "";
|
||||
if (pendingSock && pendingSock !== sock && !pendingSock.destroyed) {
|
||||
pendingSock.destroy();
|
||||
}
|
||||
if (sock && !sock.destroyed) sock.destroy();
|
||||
}
|
||||
|
||||
@@ -358,9 +400,21 @@ if (process.env.NETCATTY_MCP_DELEGATED_TOOLS !== undefined) {
|
||||
registerMcpTools(server, toolDependencies, listMcpTools().filter((tool) => allowed.has(tool.mcpTool)));
|
||||
} else registerProgressiveMcpTools(server, toolDependencies);
|
||||
|
||||
const lifecycle = createMcpStdioLifecycle({
|
||||
onLog: debugLog,
|
||||
onShutdown: async () => {
|
||||
dropActiveSocket();
|
||||
rejectAllPending("MCP server shutting down");
|
||||
await server.close().catch(() => {});
|
||||
},
|
||||
});
|
||||
|
||||
// ── Start ──
|
||||
|
||||
async function main() {
|
||||
lifecycle.attach();
|
||||
if (lifecycle.isShuttingDown()) return;
|
||||
|
||||
debugLog("Starting MCP server", {
|
||||
port: NETCATTY_MCP_PORT,
|
||||
hasToken: Boolean(NETCATTY_MCP_TOKEN),
|
||||
@@ -382,15 +436,19 @@ async function main() {
|
||||
process.stderr.write("[netcatty-mcp] Authenticated with TCP bridge\n");
|
||||
}
|
||||
|
||||
if (lifecycle.isShuttingDown()) return;
|
||||
|
||||
const transport = new StdioServerTransport();
|
||||
// Protocol.connect keeps this callback and runs it before request dispatch.
|
||||
transport.onmessage = (message) => {
|
||||
normalizeMcpJsonRpcMessage(message);
|
||||
};
|
||||
lifecycle.bindTransport(transport);
|
||||
await server.connect(transport);
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
if (lifecycle.isShuttingDown()) return;
|
||||
process.stderr.write(`[netcatty-mcp] Fatal: ${err.message}\n`);
|
||||
process.exit(1);
|
||||
});
|
||||
@@ -631,8 +631,8 @@ class PluginHostInteractionService {
|
||||
await context.assertActive(); this.#assertWindow(sender);
|
||||
const entry = { context, params };
|
||||
this.#audit(entry, "completed");
|
||||
if (params.kind === "clipboard.write") { this.clipboard.writeText(params.text); return { cancelled: false, value: true }; }
|
||||
const text = assertTextBytes(this.clipboard.readText(), LIMITS.clipboardBytes);
|
||||
if (params.kind === "clipboard.write") { await this.clipboard.writeText(params.text); return { cancelled: false, value: true }; }
|
||||
const text = assertTextBytes(await this.clipboard.readText(), LIMITS.clipboardBytes);
|
||||
this.quotaManager.chargeBytes(context.runtimeId, "clipboard", Buffer.byteLength(text));
|
||||
await context.assertActive();
|
||||
return { cancelled: false, value: text };
|
||||
@@ -653,14 +653,36 @@ class PluginHostInteractionService {
|
||||
if (terminalTarget) entry.terminalWatch = this.terminalSelection.watch();
|
||||
context.signal?.addEventListener("abort", entry.onAbort, { once: true });
|
||||
if (context.signal?.aborted) { entry.onAbort(); return; }
|
||||
try {
|
||||
if (params.kind === "clipboard.read") {
|
||||
entry.previewText = assertTextBytes(this.clipboard.readText(), LIMITS.clipboardBytes);
|
||||
this.quotaManager.chargeBytes(context.runtimeId, "clipboard", Buffer.byteLength(entry.previewText));
|
||||
entry.phase = "preview";
|
||||
const finishPresent = (rawClipboardText) => {
|
||||
if (this.pending.get(entry.id) !== entry) return;
|
||||
try {
|
||||
if (params.kind === "clipboard.read") {
|
||||
entry.previewText = assertTextBytes(rawClipboardText, LIMITS.clipboardBytes);
|
||||
this.quotaManager.chargeBytes(context.runtimeId, "clipboard", Buffer.byteLength(entry.previewText));
|
||||
entry.phase = "preview";
|
||||
}
|
||||
this.#present(entry);
|
||||
} catch { this.#finish(entry, null, fail("unavailable", "Host interaction window is unavailable")); }
|
||||
};
|
||||
if (params.kind === "clipboard.read") {
|
||||
let readResult;
|
||||
try { readResult = this.clipboard.readText(); }
|
||||
catch { this.#finish(entry, null, fail("unavailable", "Host interaction window is unavailable")); return; }
|
||||
if (readResult && typeof readResult.then === "function") {
|
||||
readResult.then(
|
||||
(text) => {
|
||||
if (this.pending.get(entry.id) !== entry) return;
|
||||
if (context.signal?.aborted) { entry.onAbort(); return; }
|
||||
finishPresent(text);
|
||||
},
|
||||
() => { this.#finish(entry, null, fail("unavailable", "Host interaction window is unavailable")); },
|
||||
);
|
||||
return;
|
||||
}
|
||||
this.#present(entry);
|
||||
} catch { this.#finish(entry, null, fail("unavailable", "Host interaction window is unavailable")); }
|
||||
finishPresent(readResult);
|
||||
return;
|
||||
}
|
||||
finishPresent(null);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -730,7 +752,7 @@ class PluginHostInteractionService {
|
||||
if (response.action !== "preview") throw fail("invalidArgument", "Clipboard sharing requires a preview action");
|
||||
this.#audit(entry, "preview-confirmed");
|
||||
let rawText;
|
||||
try { rawText = this.clipboard.readText(); }
|
||||
try { rawText = await this.clipboard.readText(); }
|
||||
catch { throw fail("unavailable", "Host clipboard text is unavailable"); }
|
||||
const text = assertTextBytes(rawText, LIMITS.clipboardBytes);
|
||||
this.quotaManager.chargeBytes(entry.context.runtimeId, "clipboard", Buffer.byteLength(text));
|
||||
@@ -758,7 +780,7 @@ class PluginHostInteractionService {
|
||||
value = Object.freeze({ text: entry.previewText, ...this.terminalSelection.issue(entry.terminalTarget, entry.context) });
|
||||
}
|
||||
if (entry.params.kind === "clipboard.write") {
|
||||
try { this.clipboard.writeText(entry.params.text); }
|
||||
try { await this.clipboard.writeText(entry.params.text); }
|
||||
catch { throw fail("unavailable", "Host clipboard write failed"); }
|
||||
}
|
||||
return this.#finish(entry, { cancelled: false, value });
|
||||
|
||||
@@ -28,7 +28,7 @@ async function stageRendererFileToTemp(file, localPath, fsImpl, signal = null) {
|
||||
if (signal?.aborted) throw cancellationError();
|
||||
if (done) break;
|
||||
if (!value) continue;
|
||||
const chunk = Buffer.from(value.buffer, value.byteOffset, value.byteLength);
|
||||
const chunk = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
||||
let chunkOffset = 0;
|
||||
while (chunkOffset < chunk.length) {
|
||||
if (signal?.aborted) throw cancellationError();
|
||||
|
||||
Generated
+7
-7
@@ -95,7 +95,7 @@
|
||||
"clsx": "2.1.1",
|
||||
"concurrently": "^9.2.1",
|
||||
"cross-env": "^10.1.0",
|
||||
"electron": "^42.11.12",
|
||||
"electron": "^45.5.0",
|
||||
"electron-builder": "^26.15.2",
|
||||
"esbuild": "0.27.2",
|
||||
"eslint": "^9.39.1",
|
||||
@@ -11803,9 +11803,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/electron": {
|
||||
"version": "42.11.12",
|
||||
"resolved": "https://registry.npmjs.org/electron/-/electron-42.11.12.tgz",
|
||||
"integrity": "sha512-fHlCHh1uqfvWykQUq8eoSoB5q1gej7z/KKd3m7rqEEhHhihm7qz/EvBIkDat7vQoIq3kGTJcrskLbJ6UFkYGyg==",
|
||||
"version": "45.5.0",
|
||||
"resolved": "https://registry.npmjs.org/electron/-/electron-45.5.0.tgz",
|
||||
"integrity": "sha512-rBQ0Czu1Qrtrs6Fygq7Qtfcgkhpt79SylMkaFb1AhtXItdxh0Wq3ERQoPfBYECYf+FxptAiXKCZ7p+H/39CWIA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -16770,9 +16770,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/node-abi": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-4.31.0.tgz",
|
||||
"integrity": "sha512-Erq5w/t3syw3s4sDsUaX4QttIdBPsGKTT1DTRsCkTonGggczhlDKm/wDX3o+HPJpQ41EjXCbcmXf0tgr5YZJXw==",
|
||||
"version": "4.43.0",
|
||||
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-4.43.0.tgz",
|
||||
"integrity": "sha512-sey5XPoGJ2VBCcwtHhvwSbMMkYvXyvZkn+FjHsoFij3bcWjJRN4+3Zt7GsZOkgZ8J0maJFCWsYtralZDJVQncg==",
|
||||
"devOptional": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
||||
+2
-2
@@ -164,7 +164,7 @@
|
||||
"clsx": "2.1.1",
|
||||
"concurrently": "^9.2.1",
|
||||
"cross-env": "^10.1.0",
|
||||
"electron": "^42.11.12",
|
||||
"electron": "^45.5.0",
|
||||
"electron-builder": "^26.15.2",
|
||||
"esbuild": "0.27.2",
|
||||
"eslint": "^9.39.1",
|
||||
@@ -210,7 +210,7 @@
|
||||
"overrides": {
|
||||
"cpu-features": "npm:empty-npm-package@1.0.0",
|
||||
"axios": "1.13.5",
|
||||
"node-abi": "4.31.0",
|
||||
"node-abi": "4.43.0",
|
||||
"@electron/asar": "4.2.0"
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ Self-contained WebAssembly build of [Devolutions/IronRDP](https://github.com/Dev
|
||||
1. `0001-session-responsiveness.patch` — 16ms dirty-rectangle coalescing (`PaintTicker`) and cooperative event-loop yielding every 16 frames so rapid screen updates do not starve DOM keyboard/mouse input.
|
||||
2. `0002-load-balance-info-and-shell.patch` — Exposes `load_balance_info`, `alternate_shell`, and `work_dir` extensions on `SessionBuilder` for JumpServer Razor and RDS Connection Broker routing.
|
||||
3. `0003-rdpdr-drives-and-multimonitor.patch` — Adds `WasmDriveBackend` for MS-RDPEFS drive redirection (`rdpdr_drives`, `rdpdr_request_callback`, `rdpdr_response`, `rdpdr_add_drive`, `rdpdr_remove_drive`, composing cleanly with audio and printer redirection) and MS-RDPEDISP multi-monitor layout extensions (`set_monitor_layout`, `display_control_caps_callback`).
|
||||
4. `0004-standard-rdp-security.patch` — Fixes `ConferenceCreateRequest` GCC `connectPDU` PER length encoding, raises `ServerSecurityData` certificate size limits, and adds Standard RDP Security (MS-RDPBCGR 5.3) with 40/56/128-bit RC4 (standard & salted MAC, 4096-packet key update) and FIPS (3DES-EDE3-CBC + HMAC-SHA1) across Slow-Path, Fast-Path, and Deactivation-Reactivation, plus `security_info_callback`.
|
||||
|
||||
## Rebuilding
|
||||
|
||||
|
||||
@@ -1493,32 +1493,32 @@ function __wbg_get_imports() {
|
||||
return ret;
|
||||
},
|
||||
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 3861, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 3876, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
||||
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__hc8af3a46fbf9a387);
|
||||
return ret;
|
||||
},
|
||||
__wbindgen_generic_0000000000000002: function(arg0, arg1) {
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("CloseEvent")], shim_idx: 1108, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("CloseEvent")], shim_idx: 1111, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
||||
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h69dcddf96fe0df48);
|
||||
return ret;
|
||||
},
|
||||
__wbindgen_generic_0000000000000003: function(arg0, arg1) {
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 1108, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 1111, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
||||
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h69dcddf96fe0df48_69);
|
||||
return ret;
|
||||
},
|
||||
__wbindgen_generic_0000000000000004: function(arg0, arg1) {
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 1108, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 1111, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
||||
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h69dcddf96fe0df48_70);
|
||||
return ret;
|
||||
},
|
||||
__wbindgen_generic_0000000000000005: function(arg0, arg1) {
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 1100, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 1103, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
||||
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__hda0c6eb1ba57bb78);
|
||||
return ret;
|
||||
},
|
||||
__wbindgen_generic_0000000000000006: function(arg0, arg1) {
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 1109, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 1112, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
||||
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__hed1c9475885aec45);
|
||||
return ret;
|
||||
},
|
||||
|
||||
Binary file not shown.
@@ -31,7 +31,8 @@
|
||||
"patches": [
|
||||
"0001-session-responsiveness.patch",
|
||||
"0002-load-balance-info-and-shell.patch",
|
||||
"0003-rdpdr-drives-and-multimonitor.patch"
|
||||
"0003-rdpdr-drives-and-multimonitor.patch",
|
||||
"0004-standard-rdp-security.patch"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,7 @@ prepare_source() {
|
||||
echo "Checking out clean ${IRONRDP_COMMIT}..."
|
||||
git -C "${SRC_DIR}" checkout --force --detach "${IRONRDP_COMMIT}"
|
||||
git -C "${SRC_DIR}" reset --hard "${IRONRDP_COMMIT}" >/dev/null
|
||||
git -C "${SRC_DIR}" clean -fd crates/ironrdp-web >/dev/null
|
||||
git -C "${SRC_DIR}" clean -fd crates/ironrdp-web crates/ironrdp-pdu crates/ironrdp-connector crates/ironrdp-testsuite-core >/dev/null
|
||||
|
||||
echo "Applying patches from ${PATCH_DIR}..."
|
||||
shopt -s nullglob
|
||||
@@ -113,9 +113,11 @@ run_host_tests() {
|
||||
return
|
||||
fi
|
||||
|
||||
echo "Running ironrdp-web host unit tests (drive::tests, session::tests)..."
|
||||
echo "Running IronRDP host unit tests (ironrdp-pdu, ironrdp-connector, ironrdp-web)..."
|
||||
(
|
||||
cd "${SRC_DIR}"
|
||||
cargo test -p ironrdp-pdu --lib --locked -- crypto:: gcc::
|
||||
cargo test -p ironrdp-connector --lib --locked
|
||||
# Run host-compatible unit tests (RDPDR drive PDU marshalling, multi-monitor
|
||||
# layout validation, load_balance_info, audio/printer/drive channel
|
||||
# attachment, RDCleanPath, file-transfer marshalling). Clipboard JS bridge
|
||||
@@ -211,7 +213,8 @@ package_output() {
|
||||
"patches": [
|
||||
"0001-session-responsiveness.patch",
|
||||
"0002-load-balance-info-and-shell.patch",
|
||||
"0003-rdpdr-drives-and-multimonitor.patch"
|
||||
"0003-rdpdr-drives-and-multimonitor.patch",
|
||||
"0004-standard-rdp-security.patch"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -228,6 +231,7 @@ Self-contained WebAssembly build of [Devolutions/IronRDP](https://github.com/Dev
|
||||
1. \`0001-session-responsiveness.patch\` — 16ms dirty-rectangle coalescing (\`PaintTicker\`) and cooperative event-loop yielding every 16 frames so rapid screen updates do not starve DOM keyboard/mouse input.
|
||||
2. \`0002-load-balance-info-and-shell.patch\` — Exposes \`load_balance_info\`, \`alternate_shell\`, and \`work_dir\` extensions on \`SessionBuilder\` for JumpServer Razor and RDS Connection Broker routing.
|
||||
3. \`0003-rdpdr-drives-and-multimonitor.patch\` — Adds \`WasmDriveBackend\` for MS-RDPEFS drive redirection (\`rdpdr_drives\`, \`rdpdr_request_callback\`, \`rdpdr_response\`, \`rdpdr_add_drive\`, \`rdpdr_remove_drive\`, composing cleanly with audio and printer redirection) and MS-RDPEDISP multi-monitor layout extensions (\`set_monitor_layout\`, \`display_control_caps_callback\`).
|
||||
4. \`0004-standard-rdp-security.patch\` — Fixes \`ConferenceCreateRequest\` GCC \`connectPDU\` PER length encoding, raises \`ServerSecurityData\` certificate size limits, and adds Standard RDP Security (MS-RDPBCGR 5.3) with 40/56/128-bit RC4 (standard & salted MAC, 4096-packet key update) and FIPS (3DES-EDE3-CBC + HMAC-SHA1) across Slow-Path, Fast-Path, and Deactivation-Reactivation, plus \`security_info_callback\`.
|
||||
|
||||
## Rebuilding
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user