Add: Dauerhaftes Bildschirm-Übertragung-Overlay während RDP-Session (v2.6.0)
- RdpActiveIndicatorWindow: TeamViewer-Style Overlay unten rechts, solange RDP-Capture läuft. Zeigt Dauer der Sitzung + pulsierenden roten Punkt - User kann per "Trennen"-Button selbst die Sitzung beenden (TCP-Signal an Service, cancelt Capture-Loop sofort — auch nach Screen-Wechsel) - Overlay läuft als separater User-Prozess via SessionSpawner, wird vom Service direkt gekillt wenn Sitzung endet (rdp_stop oder Disconnect) - Version: 2.5.0 → 2.6.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.5.0";
|
private const string Version = "2.6.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";
|
||||||
|
|||||||
@@ -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.5.0</Version>
|
<Version>2.6.0</Version>
|
||||||
<AssemblyVersion>2.5.0.0</AssemblyVersion>
|
<AssemblyVersion>2.6.0.0</AssemblyVersion>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||||
|
|||||||
20
agent-cs/IndicatorModeRunner.cs
Normal file
20
agent-cs/IndicatorModeRunner.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using ITNexusAgent.UI;
|
||||||
|
|
||||||
|
namespace ITNexusAgent;
|
||||||
|
|
||||||
|
// Läuft als User-Prozess (via SessionSpawner), zeigt dauerhaftes "Bildschirm wird übertragen"-Overlay
|
||||||
|
// solange RDP-Session aktiv ist. User kann selbst trennen (TCP-Signal an Service).
|
||||||
|
public static class IndicatorModeRunner
|
||||||
|
{
|
||||||
|
public static void Run(string portStr)
|
||||||
|
{
|
||||||
|
if (!int.TryParse(portStr, out var port) || port <= 0) return;
|
||||||
|
|
||||||
|
var app = new System.Windows.Application();
|
||||||
|
app.ShutdownMode = System.Windows.ShutdownMode.OnMainWindowClose;
|
||||||
|
|
||||||
|
var win = new RdpActiveIndicatorWindow(port);
|
||||||
|
win.Show();
|
||||||
|
app.Run();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,6 +29,10 @@ internal class Program
|
|||||||
args.Length > 2 && int.TryParse(args[2], out var si) ? si : 0);
|
args.Length > 2 && int.TryParse(args[2], out var si) ? si : 0);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
case "--rdp-indicator":
|
||||||
|
IndicatorModeRunner.Run(args.Length > 1 ? args[1] : "");
|
||||||
|
return;
|
||||||
|
|
||||||
case "--dashboard":
|
case "--dashboard":
|
||||||
RunDashboard();
|
RunDashboard();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ public class RtcService
|
|||||||
private readonly string _serverUrl;
|
private readonly string _serverUrl;
|
||||||
private readonly string _agentKey;
|
private readonly string _agentKey;
|
||||||
private readonly string _hostname;
|
private readonly string _hostname;
|
||||||
|
private int _indicatorPid = -1;
|
||||||
|
private TcpListener? _indicatorListener;
|
||||||
|
private CancellationTokenSource? _userDisconnectCts;
|
||||||
|
|
||||||
public RtcService(string serverUrl, string agentKey, string hostname)
|
public RtcService(string serverUrl, string agentKey, string hostname)
|
||||||
{
|
{
|
||||||
@@ -76,21 +79,39 @@ public class RtcService
|
|||||||
var newScreen = obj["screen"]?.ToObject<int>() ?? 0;
|
var newScreen = obj["screen"]?.ToObject<int>() ?? 0;
|
||||||
captureCts.Cancel();
|
captureCts.Cancel();
|
||||||
captureCts = CancellationTokenSource.CreateLinkedTokenSource(ct);
|
captureCts = CancellationTokenSource.CreateLinkedTokenSource(ct);
|
||||||
_ = CapturePipeLoopAsync(ws, newScreen, captureCts.Token);
|
var switchToken = _userDisconnectCts != null
|
||||||
|
? CancellationTokenSource.CreateLinkedTokenSource(captureCts.Token, _userDisconnectCts.Token).Token
|
||||||
|
: captureCts.Token;
|
||||||
|
_ = CapturePipeLoopAsync(ws, newScreen, switchToken);
|
||||||
AgentWorker.Log($"RDP: Screen gewechselt zu {newScreen}");
|
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();
|
||||||
captureCts = null;
|
captureCts = null;
|
||||||
|
StopIndicator();
|
||||||
AgentWorker.Log("RDP: Screen-Capture gestoppt");
|
AgentWorker.Log("RDP: Screen-Capture gestoppt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
captureCts?.Cancel();
|
captureCts?.Cancel();
|
||||||
|
StopIndicator();
|
||||||
AgentWorker.Log("RDP: Getrennt");
|
AgentWorker.Log("RDP: Getrennt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void StopIndicator()
|
||||||
|
{
|
||||||
|
_userDisconnectCts?.Cancel();
|
||||||
|
_userDisconnectCts = null;
|
||||||
|
try { _indicatorListener?.Stop(); } catch { }
|
||||||
|
_indicatorListener = null;
|
||||||
|
if (_indicatorPid > 0)
|
||||||
|
{
|
||||||
|
try { Process.GetProcessById(_indicatorPid).Kill(); } catch { }
|
||||||
|
_indicatorPid = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task ConsentAndCaptureAsync(ClientWebSocket ws, int screenIdx, CancellationToken ct)
|
private async Task ConsentAndCaptureAsync(ClientWebSocket ws, int screenIdx, CancellationToken ct)
|
||||||
{
|
{
|
||||||
var exePath = System.Diagnostics.Process.GetCurrentProcess().MainModule!.FileName;
|
var exePath = System.Diagnostics.Process.GetCurrentProcess().MainModule!.FileName;
|
||||||
@@ -136,7 +157,45 @@ public class RtcService
|
|||||||
}
|
}
|
||||||
|
|
||||||
AgentWorker.Log("RDP: User hat Zugriff erlaubt, starte Capture");
|
AgentWorker.Log("RDP: User hat Zugriff erlaubt, starte Capture");
|
||||||
await CapturePipeLoopAsync(ws, screenIdx, ct);
|
SpawnIndicator(exePath);
|
||||||
|
|
||||||
|
var combinedToken = _userDisconnectCts != null
|
||||||
|
? CancellationTokenSource.CreateLinkedTokenSource(ct, _userDisconnectCts.Token).Token
|
||||||
|
: ct;
|
||||||
|
await CapturePipeLoopAsync(ws, screenIdx, combinedToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zeigt dauerhaftes "Bildschirm wird übertragen"-Overlay (TeamViewer-Style) solange Capture läuft.
|
||||||
|
// User kann per Klick selbst trennen — Signal landet hier als CancellationTokenSource.Cancel().
|
||||||
|
private void SpawnIndicator(string exePath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_indicatorListener = new TcpListener(IPAddress.Loopback, 0);
|
||||||
|
_indicatorListener.Start();
|
||||||
|
var port = ((IPEndPoint)_indicatorListener.LocalEndpoint).Port;
|
||||||
|
|
||||||
|
_userDisconnectCts = new CancellationTokenSource();
|
||||||
|
var listener = _indicatorListener;
|
||||||
|
var disconnectCts = _userDisconnectCts;
|
||||||
|
_ = Task.Run(async () =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var tcp = await listener.AcceptTcpClientAsync();
|
||||||
|
tcp.GetStream().ReadByte();
|
||||||
|
disconnectCts.Cancel();
|
||||||
|
AgentWorker.Log("RDP: User hat über Overlay getrennt");
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
});
|
||||||
|
|
||||||
|
_indicatorPid = SessionSpawner.SpawnInUserSession(exePath, $"--rdp-indicator {port}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
AgentWorker.Log($"RDP: Indicator-Start fehlgeschlagen: {ex.Message}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool SpawnConsentHelper(string exePath, string portStr)
|
private static bool SpawnConsentHelper(string exePath, string portStr)
|
||||||
|
|||||||
57
agent-cs/UI/RdpActiveIndicatorWindow.xaml
Normal file
57
agent-cs/UI/RdpActiveIndicatorWindow.xaml
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<Window x:Class="ITNexusAgent.UI.RdpActiveIndicatorWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
Title="IT Nexus – Bildschirmübertragung aktiv"
|
||||||
|
Width="300" Height="64"
|
||||||
|
WindowStartupLocation="Manual"
|
||||||
|
ResizeMode="NoResize"
|
||||||
|
WindowStyle="None"
|
||||||
|
AllowsTransparency="True"
|
||||||
|
Background="Transparent"
|
||||||
|
Topmost="True"
|
||||||
|
ShowInTaskbar="False"
|
||||||
|
FontFamily="Segoe UI">
|
||||||
|
|
||||||
|
<Border Background="#1A1D2E" BorderBrush="#E67E22" BorderThickness="1.5" CornerRadius="10">
|
||||||
|
<Grid Margin="14,10,14,10">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<!-- Pulsierender roter Punkt -->
|
||||||
|
<Ellipse x:Name="PulseDot" Grid.Column="0" Width="10" Height="10" Fill="#E74C3C"
|
||||||
|
VerticalAlignment="Center" Margin="0,0,12,0">
|
||||||
|
<Ellipse.Triggers>
|
||||||
|
</Ellipse.Triggers>
|
||||||
|
</Ellipse>
|
||||||
|
|
||||||
|
<StackPanel Grid.Column="1" VerticalAlignment="Center">
|
||||||
|
<TextBlock Text="Bildschirm wird übertragen" FontSize="12" FontWeight="Bold" Foreground="White"/>
|
||||||
|
<TextBlock x:Name="DurationText" Text="IT-Abteilung sieht zu · 00:00" FontSize="10.5" Foreground="#9099B5" Margin="0,2,0,0"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<Button x:Name="DisconnectButton" Grid.Column="2" Click="DisconnectButton_Click"
|
||||||
|
Background="#3D1414" Foreground="#FF8A80" BorderThickness="1" BorderBrush="#6B2020"
|
||||||
|
Padding="10,6" Cursor="Hand" VerticalAlignment="Center" FontSize="11" FontWeight="Bold">
|
||||||
|
<Button.Template>
|
||||||
|
<ControlTemplate TargetType="Button">
|
||||||
|
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="6" Padding="{TemplateBinding Padding}">
|
||||||
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Button.Template>
|
||||||
|
<TextBlock Text="Trennen"/>
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<Window.Resources>
|
||||||
|
<Storyboard x:Key="PulseAnim" RepeatBehavior="Forever">
|
||||||
|
<DoubleAnimation Storyboard.TargetName="PulseDot" Storyboard.TargetProperty="Opacity"
|
||||||
|
From="1.0" To="0.25" Duration="0:0:0.9" AutoReverse="True"/>
|
||||||
|
</Storyboard>
|
||||||
|
</Window.Resources>
|
||||||
|
</Window>
|
||||||
55
agent-cs/UI/RdpActiveIndicatorWindow.xaml.cs
Normal file
55
agent-cs/UI/RdpActiveIndicatorWindow.xaml.cs
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Media.Animation;
|
||||||
|
|
||||||
|
namespace ITNexusAgent.UI;
|
||||||
|
|
||||||
|
public partial class RdpActiveIndicatorWindow : Window
|
||||||
|
{
|
||||||
|
private readonly int _port;
|
||||||
|
private readonly DateTime _startedAt = DateTime.Now;
|
||||||
|
private readonly System.Windows.Threading.DispatcherTimer _timer = new();
|
||||||
|
private bool _signaled = false;
|
||||||
|
|
||||||
|
public RdpActiveIndicatorWindow(int port)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_port = port;
|
||||||
|
|
||||||
|
Loaded += (s, e) =>
|
||||||
|
{
|
||||||
|
var area = SystemParameters.WorkArea;
|
||||||
|
Left = area.Right - Width - 16;
|
||||||
|
Top = area.Bottom - Height - 16;
|
||||||
|
((Storyboard)Resources["PulseAnim"]).Begin(PulseDot);
|
||||||
|
};
|
||||||
|
|
||||||
|
_timer.Interval = TimeSpan.FromSeconds(1);
|
||||||
|
_timer.Tick += (s, e) =>
|
||||||
|
{
|
||||||
|
var elapsed = DateTime.Now - _startedAt;
|
||||||
|
DurationText.Text = $"IT-Abteilung sieht zu · {elapsed:mm\\:ss}";
|
||||||
|
};
|
||||||
|
_timer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DisconnectButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
SendDisconnectSignal();
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SendDisconnectSignal()
|
||||||
|
{
|
||||||
|
if (_signaled) return;
|
||||||
|
_signaled = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var tcp = new TcpClient();
|
||||||
|
tcp.Connect("127.0.0.1", _port);
|
||||||
|
tcp.GetStream().WriteByte(1);
|
||||||
|
tcp.GetStream().Flush();
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#define MyAppName "IT Nexus Agent"
|
#define MyAppName "IT Nexus Agent"
|
||||||
#define MyAppVersion "2.5.0"
|
#define MyAppVersion "2.6.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"
|
||||||
|
|||||||
@@ -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.5.0';
|
const LATEST_AGENT_VERSION = '2.6.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