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
|
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 DataDir = @"C:\ProgramData\IT Nexus Agent";
|
||||||
private const string ConfigPath = @"C:\ProgramData\IT Nexus Agent\config.json";
|
private const string ConfigPath = @"C:\ProgramData\IT Nexus Agent\config.json";
|
||||||
private const string StatusPath = @"C:\ProgramData\IT Nexus Agent\status.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);
|
var encParams = new EncoderParameters(1);
|
||||||
encParams.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 60L);
|
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;
|
var allScreens = System.Windows.Forms.Screen.AllScreens;
|
||||||
Rectangle captureRect;
|
Rectangle captureRect;
|
||||||
if (screenIdx <= 0 || screenIdx > allScreens.Length)
|
if (screenIdx <= 0 || screenIdx > allScreens.Length)
|
||||||
@@ -40,14 +39,27 @@ public static class CaptureModeRunner
|
|||||||
captureRect = allScreens[screenIdx - 1].Bounds;
|
captureRect = allScreens[screenIdx - 1].Bounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint lastHash = 0;
|
||||||
|
var sw = System.Diagnostics.Stopwatch.StartNew();
|
||||||
|
|
||||||
while (tcp.Connected)
|
while (tcp.Connected)
|
||||||
{
|
{
|
||||||
|
sw.Restart();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var bmp = new Bitmap(captureRect.Width, captureRect.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
using var bmp = new Bitmap(captureRect.Width, captureRect.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
||||||
using (var g = Graphics.FromImage(bmp))
|
using (var g = Graphics.FromImage(bmp))
|
||||||
g.CopyFromScreen(captureRect.X, captureRect.Y, 0, 0, new Size(captureRect.Width, captureRect.Height));
|
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;
|
byte[] jpeg;
|
||||||
using (var ms = new MemoryStream())
|
using (var ms = new MemoryStream())
|
||||||
{
|
{
|
||||||
@@ -55,16 +67,32 @@ public static class CaptureModeRunner
|
|||||||
jpeg = ms.ToArray();
|
jpeg = ms.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4-Byte Länge (LE) + JPEG-Daten
|
|
||||||
stream.Write(BitConverter.GetBytes(jpeg.Length));
|
stream.Write(BitConverter.GetBytes(jpeg.Length));
|
||||||
stream.Write(jpeg);
|
stream.Write(jpeg);
|
||||||
stream.Flush();
|
stream.Flush();
|
||||||
}
|
}
|
||||||
catch { break; }
|
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 */ }
|
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>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<AssemblyName>IT-Nexus-Agent</AssemblyName>
|
<AssemblyName>IT-Nexus-Agent</AssemblyName>
|
||||||
<RootNamespace>ITNexusAgent</RootNamespace>
|
<RootNamespace>ITNexusAgent</RootNamespace>
|
||||||
<Version>2.0.0</Version>
|
<Version>2.3.0</Version>
|
||||||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
<AssemblyVersion>2.3.0.0</AssemblyVersion>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||||
|
|||||||
@@ -70,6 +70,15 @@ public class RtcService
|
|||||||
_ = ConsentAndCaptureAsync(ws, screenIdx, captureCts.Token);
|
_ = ConsentAndCaptureAsync(ws, screenIdx, captureCts.Token);
|
||||||
AgentWorker.Log($"RDP: Consent angefordert (screen={screenIdx})");
|
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)
|
else if (type == "rdp_stop" && captureCts != null)
|
||||||
{
|
{
|
||||||
captureCts.Cancel();
|
captureCts.Cancel();
|
||||||
@@ -93,8 +102,10 @@ public class RtcService
|
|||||||
if (!SpawnConsentHelper(exePath, consentPort.ToString()))
|
if (!SpawnConsentHelper(exePath, consentPort.ToString()))
|
||||||
{
|
{
|
||||||
consentListener.Stop();
|
consentListener.Stop();
|
||||||
AgentWorker.Log("RDP: Consent-Helper fehlgeschlagen, starte ohne Consent");
|
AgentWorker.Log("RDP: Consent-Helper fehlgeschlagen, verweigere Zugriff");
|
||||||
await CapturePipeLoopAsync(ws, screenIdx, ct);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class ShellService
|
|||||||
+ $"/ws?type=agent&key={Uri.EscapeDataString(_agentKey)}&hostname={Uri.EscapeDataString(_hostname)}";
|
+ $"/ws?type=agent&key={Uri.EscapeDataString(_agentKey)}&hostname={Uri.EscapeDataString(_hostname)}";
|
||||||
|
|
||||||
using var ws = new ClientWebSocket();
|
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);
|
await ws.ConnectAsync(new Uri(wsUrl), ct);
|
||||||
AgentWorker.Log("SHELL: WebSocket verbunden");
|
AgentWorker.Log("SHELL: WebSocket verbunden");
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
<Window x:Class="ITNexusAgent.UI.RdpConsentWindow"
|
<Window x:Class="ITNexusAgent.UI.RdpConsentWindow"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
Title="IT Nexus – Bildschirmzugriff"
|
Title="IT Nexus – Bildschirmzugriff angefordert"
|
||||||
Width="480" Height="Auto"
|
Width="480" Height="Auto"
|
||||||
SizeToContent="Height"
|
SizeToContent="Height"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
ResizeMode="NoResize"
|
ResizeMode="NoResize"
|
||||||
WindowStyle="None"
|
WindowStyle="ToolWindow"
|
||||||
AllowsTransparency="False"
|
AllowsTransparency="False"
|
||||||
Background="#1A1D2E"
|
Background="#1A1D2E"
|
||||||
Topmost="True"
|
Topmost="True"
|
||||||
|
ShowInTaskbar="True"
|
||||||
FontFamily="Segoe UI">
|
FontFamily="Segoe UI">
|
||||||
|
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#define MyAppName "IT Nexus Agent"
|
#define MyAppName "IT Nexus Agent"
|
||||||
#define MyAppVersion "2.2.0"
|
#define MyAppVersion "2.3.0"
|
||||||
#define MyAppPublisher "Cereda Systems GmbH"
|
#define MyAppPublisher "Cereda Systems GmbH"
|
||||||
#define MyAppURL "https://it-nexus.cereda-systems.de"
|
#define MyAppURL "https://it-nexus.cereda-systems.de"
|
||||||
#define MyAppExeName "IT-Nexus-Agent.exe"
|
#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;
|
img.src = 'data:image/jpeg;base64,' + msg.data;
|
||||||
} else if (msg.type === 'rdp_denied') {
|
} else if (msg.type === 'rdp_denied') {
|
||||||
setStatus('error');
|
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();
|
ws.close();
|
||||||
} else if (msg.type === 'rdp_disconnected') {
|
} else if (msg.type === 'rdp_disconnected') {
|
||||||
setStatus('idle');
|
setStatus('idle');
|
||||||
@@ -119,8 +121,14 @@ export default function RemoteDesktopPanel({ agentId, agentHostname, autoConnect
|
|||||||
{/* Screen-Selektor */}
|
{/* Screen-Selektor */}
|
||||||
<select
|
<select
|
||||||
value={screenIdx}
|
value={screenIdx}
|
||||||
onChange={e => setScreenIdx(Number(e.target.value))}
|
onChange={e => {
|
||||||
disabled={status === 'connected' || status === 'connecting' || status === 'waiting'}
|
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 }}
|
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 => (
|
{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 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_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 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' };
|
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