Fix: Remote Desktop — 60fps, Screen-Wechsel live, Consent-Dialog sichtbar (v2.3.0)
- CaptureModeRunner: Thread.Sleep(150) → 16ms (~60fps) + Skip-if-unchanged via Pixel-Hash - RtcService: rdp_switch_screen Handler — Screen wechseln ohne Consent-Dialog - RtcService: Fallback bei Consent-Fehler → rdp_denied statt silent capture - RdpConsentWindow: WindowStyle=ToolWindow + ShowInTaskbar=True (jetzt in Taskleiste sichtbar) - RemoteDesktopPanel: Screen-Dropdown auch während aktiver Verbindung nutzbar - Version: 2.2.0 → 2.3.0 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,7 @@ namespace ITNexusAgent;
|
||||
|
||||
public class AgentWorker
|
||||
{
|
||||
private const string Version = "2.2.0";
|
||||
private const string Version = "2.3.0";
|
||||
private const string DataDir = @"C:\ProgramData\IT Nexus Agent";
|
||||
private const string ConfigPath = @"C:\ProgramData\IT Nexus Agent\config.json";
|
||||
private const string StatusPath = @"C:\ProgramData\IT Nexus Agent\status.json";
|
||||
|
||||
@@ -24,7 +24,6 @@ public static class CaptureModeRunner
|
||||
var encParams = new EncoderParameters(1);
|
||||
encParams.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 60L);
|
||||
|
||||
// Capture-Region bestimmen: 0 = alle Screens, 1-N = spezifischer Screen
|
||||
var allScreens = System.Windows.Forms.Screen.AllScreens;
|
||||
Rectangle captureRect;
|
||||
if (screenIdx <= 0 || screenIdx > allScreens.Length)
|
||||
@@ -40,14 +39,27 @@ public static class CaptureModeRunner
|
||||
captureRect = allScreens[screenIdx - 1].Bounds;
|
||||
}
|
||||
|
||||
uint lastHash = 0;
|
||||
var sw = System.Diagnostics.Stopwatch.StartNew();
|
||||
|
||||
while (tcp.Connected)
|
||||
{
|
||||
sw.Restart();
|
||||
try
|
||||
{
|
||||
using var bmp = new Bitmap(captureRect.Width, captureRect.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
||||
using (var g = Graphics.FromImage(bmp))
|
||||
g.CopyFromScreen(captureRect.X, captureRect.Y, 0, 0, new Size(captureRect.Width, captureRect.Height));
|
||||
|
||||
var hash = SampleHash(bmp);
|
||||
if (hash == lastHash)
|
||||
{
|
||||
var elapsed = (int)sw.ElapsedMilliseconds;
|
||||
if (elapsed < 16) Thread.Sleep(16 - elapsed);
|
||||
continue;
|
||||
}
|
||||
lastHash = hash;
|
||||
|
||||
byte[] jpeg;
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
@@ -55,16 +67,32 @@ public static class CaptureModeRunner
|
||||
jpeg = ms.ToArray();
|
||||
}
|
||||
|
||||
// 4-Byte Länge (LE) + JPEG-Daten
|
||||
stream.Write(BitConverter.GetBytes(jpeg.Length));
|
||||
stream.Write(jpeg);
|
||||
stream.Flush();
|
||||
}
|
||||
catch { break; }
|
||||
|
||||
Thread.Sleep(150); // ~6-7 fps
|
||||
var frameMs = (int)sw.ElapsedMilliseconds;
|
||||
if (frameMs < 16) Thread.Sleep(16 - frameMs); // cap at ~60 fps
|
||||
}
|
||||
}
|
||||
catch { /* Verbindung fehlgeschlagen → Exit */ }
|
||||
}
|
||||
|
||||
private static uint SampleHash(Bitmap bmp)
|
||||
{
|
||||
// Sample 64 evenly-distributed pixels — fast change detection, O(1)
|
||||
uint h = 2166136261u;
|
||||
int w = bmp.Width, ht = bmp.Height;
|
||||
int stepX = Math.Max(1, w / 8);
|
||||
int stepY = Math.Max(1, ht / 8);
|
||||
for (int y = 0; y < ht; y += stepY)
|
||||
for (int x = 0; x < w; x += stepX)
|
||||
{
|
||||
var c = bmp.GetPixel(x, y);
|
||||
h = (h ^ (uint)c.ToArgb()) * 16777619u;
|
||||
}
|
||||
return h;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<AssemblyName>IT-Nexus-Agent</AssemblyName>
|
||||
<RootNamespace>ITNexusAgent</RootNamespace>
|
||||
<Version>2.0.0</Version>
|
||||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||||
<Version>2.3.0</Version>
|
||||
<AssemblyVersion>2.3.0.0</AssemblyVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||
|
||||
@@ -70,6 +70,15 @@ public class RtcService
|
||||
_ = ConsentAndCaptureAsync(ws, screenIdx, captureCts.Token);
|
||||
AgentWorker.Log($"RDP: Consent angefordert (screen={screenIdx})");
|
||||
}
|
||||
else if (type == "rdp_switch_screen" && captureCts != null)
|
||||
{
|
||||
// Consent bereits erteilt — nur Screen wechseln, kein erneuter Dialog
|
||||
var newScreen = obj["screen"]?.ToObject<int>() ?? 0;
|
||||
captureCts.Cancel();
|
||||
captureCts = CancellationTokenSource.CreateLinkedTokenSource(ct);
|
||||
_ = CapturePipeLoopAsync(ws, newScreen, captureCts.Token);
|
||||
AgentWorker.Log($"RDP: Screen gewechselt zu {newScreen}");
|
||||
}
|
||||
else if (type == "rdp_stop" && captureCts != null)
|
||||
{
|
||||
captureCts.Cancel();
|
||||
@@ -93,8 +102,10 @@ public class RtcService
|
||||
if (!SpawnConsentHelper(exePath, consentPort.ToString()))
|
||||
{
|
||||
consentListener.Stop();
|
||||
AgentWorker.Log("RDP: Consent-Helper fehlgeschlagen, starte ohne Consent");
|
||||
await CapturePipeLoopAsync(ws, screenIdx, ct);
|
||||
AgentWorker.Log("RDP: Consent-Helper fehlgeschlagen, verweigere Zugriff");
|
||||
var failed = Encoding.UTF8.GetBytes("{\"type\":\"rdp_denied\",\"reason\":\"consent_spawn_failed\"}");
|
||||
if (ws.State == WebSocketState.Open)
|
||||
await ws.SendAsync(new ArraySegment<byte>(failed), WebSocketMessageType.Text, true, CancellationToken.None);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class ShellService
|
||||
+ $"/ws?type=agent&key={Uri.EscapeDataString(_agentKey)}&hostname={Uri.EscapeDataString(_hostname)}";
|
||||
|
||||
using var ws = new ClientWebSocket();
|
||||
ws.Options.SetRequestHeader("User-Agent", "IT-Nexus-Agent/2.1.2");
|
||||
ws.Options.SetRequestHeader("User-Agent", "IT-Nexus-Agent/2.3.0");
|
||||
|
||||
await ws.ConnectAsync(new Uri(wsUrl), ct);
|
||||
AgentWorker.Log("SHELL: WebSocket verbunden");
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
<Window x:Class="ITNexusAgent.UI.RdpConsentWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="IT Nexus – Bildschirmzugriff"
|
||||
Title="IT Nexus – Bildschirmzugriff angefordert"
|
||||
Width="480" Height="Auto"
|
||||
SizeToContent="Height"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
ResizeMode="NoResize"
|
||||
WindowStyle="None"
|
||||
WindowStyle="ToolWindow"
|
||||
AllowsTransparency="False"
|
||||
Background="#1A1D2E"
|
||||
Topmost="True"
|
||||
ShowInTaskbar="True"
|
||||
FontFamily="Segoe UI">
|
||||
|
||||
<Window.Resources>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#define MyAppName "IT Nexus Agent"
|
||||
#define MyAppVersion "2.2.0"
|
||||
#define MyAppVersion "2.3.0"
|
||||
#define MyAppPublisher "Cereda Systems GmbH"
|
||||
#define MyAppURL "https://it-nexus.cereda-systems.de"
|
||||
#define MyAppExeName "IT-Nexus-Agent.exe"
|
||||
|
||||
@@ -61,7 +61,9 @@ export default function RemoteDesktopPanel({ agentId, agentHostname, autoConnect
|
||||
img.src = 'data:image/jpeg;base64,' + msg.data;
|
||||
} else if (msg.type === 'rdp_denied') {
|
||||
setStatus('error');
|
||||
setError('Zugriff wurde vom Benutzer abgelehnt');
|
||||
setError(msg.reason === 'consent_spawn_failed'
|
||||
? 'Consent-Dialog konnte nicht geöffnet werden (schtasks-Fehler)'
|
||||
: 'Zugriff wurde vom Benutzer abgelehnt');
|
||||
ws.close();
|
||||
} else if (msg.type === 'rdp_disconnected') {
|
||||
setStatus('idle');
|
||||
@@ -119,8 +121,14 @@ export default function RemoteDesktopPanel({ agentId, agentHostname, autoConnect
|
||||
{/* Screen-Selektor */}
|
||||
<select
|
||||
value={screenIdx}
|
||||
onChange={e => setScreenIdx(Number(e.target.value))}
|
||||
disabled={status === 'connected' || status === 'connecting' || status === 'waiting'}
|
||||
onChange={e => {
|
||||
const newIdx = Number(e.target.value);
|
||||
setScreenIdx(newIdx);
|
||||
if (status === 'connected' && wsRef.current?.readyState === WebSocket.OPEN) {
|
||||
wsRef.current.send(JSON.stringify({ type: 'rdp_switch_screen', screen: newIdx }));
|
||||
}
|
||||
}}
|
||||
disabled={status === 'connecting' || status === 'waiting'}
|
||||
style={{ fontSize: 12, padding: '3px 8px', borderRadius: 7, border: '1px solid var(--border-color)', background: 'var(--bg-tertiary)', color: 'var(--text-primary)', cursor: 'pointer', marginLeft: 4 }}
|
||||
>
|
||||
{SCREEN_OPTIONS.map(o => (
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useAuth } from '../context/AuthContext';
|
||||
|
||||
const ANN_TYPES = { maintenance: { icon: '🔧', label: 'Wartung', color: '#f59e0b' }, warning: { icon: '⚠️', label: 'Warnung', color: '#ef4444' }, info: { icon: 'ℹ️', label: 'Info', color: '#6366f1' } };
|
||||
|
||||
const LATEST_AGENT_VERSION = '2.2.0';
|
||||
const LATEST_AGENT_VERSION = '2.3.0';
|
||||
const SEVERITY_LABELS = { critical: 'Kritisch', important: 'Wichtig', moderate: 'Moderat', low: 'Niedrig', all: 'Alle' };
|
||||
const SEVERITY_COLORS = { critical: '#EF4444', important: '#F59E0B', moderate: '#3B82F6', low: '#6B7280', all: '#0D9488' };
|
||||
const COMMAND_LABELS = { check_updates: '🔍 Update-Scan', install_updates: '⬇️ Installation', reboot: '🔄 Neustart', upgrade_win11: '🪟 Win 11 Upgrade', update_agent: '⬆️ Agent-Update' };
|
||||
|
||||
Reference in New Issue
Block a user