testing remote stuff

This commit is contained in:
kkb 2023-11-17 17:12:41 +01:00
parent 1e05d4576d
commit 3c9ccaafeb
374 changed files with 10526 additions and 2037 deletions

View file

@ -33,6 +33,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Insight.Updater", "src\Upda
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Insight.Agent", "src\Agent\Insight.Agent\Insight.Agent.csproj", "{2A391CA2-F96B-4DB7-80AA-0668A5141640}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Remote", "Remote", "{D4D7BF4A-B2E3-470A-A14C-FC658FF7461D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Insight.Remote.Shared", "src\Remote\Insight.Remote.Shared\Insight.Remote.Shared.csproj", "{5C4697BD-BC97-484F-9DB1-CA87E2BEAA4B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Insight.Remote.Windows", "src\Remote\Insight.Remote.Windows\Insight.Remote.Windows.csproj", "{AF313B47-3079-407F-91D1-9989C1E1AF2A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -71,6 +77,14 @@ Global
{2A391CA2-F96B-4DB7-80AA-0668A5141640}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A391CA2-F96B-4DB7-80AA-0668A5141640}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A391CA2-F96B-4DB7-80AA-0668A5141640}.Release|Any CPU.Build.0 = Release|Any CPU
{5C4697BD-BC97-484F-9DB1-CA87E2BEAA4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5C4697BD-BC97-484F-9DB1-CA87E2BEAA4B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5C4697BD-BC97-484F-9DB1-CA87E2BEAA4B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5C4697BD-BC97-484F-9DB1-CA87E2BEAA4B}.Release|Any CPU.Build.0 = Release|Any CPU
{AF313B47-3079-407F-91D1-9989C1E1AF2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AF313B47-3079-407F-91D1-9989C1E1AF2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AF313B47-3079-407F-91D1-9989C1E1AF2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AF313B47-3079-407F-91D1-9989C1E1AF2A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -84,6 +98,8 @@ Global
{1E75F7E9-E6AA-44E7-A2F3-DB4CA85E0118} = {038C3821-E554-496D-B585-A3BC193B7913}
{4875D70F-A96B-4EBA-99BE-218886D29BEB} = {F2D241DB-7692-46DB-8A6A-958B365DAAF8}
{2A391CA2-F96B-4DB7-80AA-0668A5141640} = {140F73DD-29D3-4C44-809B-5B470880AA0D}
{5C4697BD-BC97-484F-9DB1-CA87E2BEAA4B} = {D4D7BF4A-B2E3-470A-A14C-FC658FF7461D}
{AF313B47-3079-407F-91D1-9989C1E1AF2A} = {D4D7BF4A-B2E3-470A-A14C-FC658FF7461D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F376A326-7590-4E7E-AB9B-76CED8527AB0}

View file

@ -6,7 +6,7 @@
<RootNamespace>Insight.Agent</RootNamespace>
<Product>Insight</Product>
<AssemblyName>agent</AssemblyName>
<AssemblyVersion>2023.9.21.0</AssemblyVersion>
<AssemblyVersion>2023.11.17.0</AssemblyVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
@ -26,7 +26,7 @@
<PackageReference Include="Serilog.Extensions.Logging.File" Version="3.0.0" />
<PackageReference Include="System.Management" Version="7.0.2" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="7.0.1" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.3.7" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.3.9" />
<PackageReference Include="Vaitr.Snmp" Version="2023.3.3" />
</ItemGroup>

View file

@ -1,5 +1,5 @@
using Insight.Domain.Interfaces;
using Insight.Domain.Messages;
using Insight.Domain.Network;
using Microsoft.Extensions.Logging;
using Vaitr.Network;

View file

@ -2,8 +2,8 @@
using Insight.Agent.Services;
using Insight.Domain.Constants;
using Insight.Domain.Interfaces;
using Insight.Domain.Messages;
using Insight.Domain.Messages.Agent;
using Insight.Domain.Network;
using Insight.Domain.Network.Agent.Messages;
namespace Insight.Agent.Network.Handlers;
@ -11,28 +11,33 @@ public class AuthenticationHandler : IMessageHandler<AgentSession>
{
public async ValueTask HandleAsync<TMessage>(AgentSession sender, TMessage message, CancellationToken cancellationToken) where TMessage : IMessage
{
if (message is AuthenticationRequest)
switch (message)
{
Config? config = null;
case AuthenticationRequest:
{
Config? config = null;
try
{
config = await Configurator.ReadAsync<Config>(Configuration.DefaultConfig, cancellationToken).ConfigureAwait(false);
}
catch (Exception) { }
try
{
config = await Configurator.ReadAsync<Config>(Configuration.DefaultConfig, cancellationToken).ConfigureAwait(false);
}
catch (Exception) { }
if (config is null)
{
config = new Config { Serial = Guid.NewGuid() };
await Configurator.WriteAsync(config, Configuration.DefaultConfig, cancellationToken).ConfigureAwait(false);
}
if (config is null)
{
config = new Config { Serial = Guid.NewGuid() };
await Configurator.WriteAsync(config, Configuration.DefaultConfig, cancellationToken).ConfigureAwait(false);
}
await sender.SendAsync(new Authentication
{
Serial = config.Serial ?? throw new InvalidDataException(nameof(config.Serial)),
Version = Configuration.Version,
Hostname = Configuration.Hostname
}, cancellationToken);
await sender.SendAsync(new AuthenticationResponse
{
Serial = config.Serial ?? throw new InvalidDataException(nameof(config.Serial)),
Version = Configuration.Version,
Hostname = Configuration.Hostname
}, cancellationToken);
break;
}
}
}
}

View file

@ -0,0 +1,40 @@
using Insight.Agent.Services;
using Insight.Domain.Interfaces;
using Insight.Domain.Network;
using Insight.Domain.Network.Agent.Messages;
using Microsoft.Extensions.Logging;
namespace Insight.Agent.Network.Handlers;
public class CustomHandler : IMessageHandler<AgentSession>
{
private readonly ScriptService _scriptService;
private readonly ILogger<CustomHandler> _logger;
public CustomHandler(ScriptService scriptService, ILogger<CustomHandler> logger)
{
_scriptService = scriptService;
_logger = logger;
}
public async ValueTask HandleAsync<TMessage>(AgentSession sender, TMessage message, CancellationToken cancellationToken) where TMessage : IMessage
{
switch (message)
{
case Request request:
await OnRequestAsync(sender, request, cancellationToken);
break;
}
}
private async ValueTask OnRequestAsync(AgentSession sender, Request request, CancellationToken cancellationToken)
{
var result = await _scriptService.QueryAsync(request.RequestData);
await sender.SendAsync(new Response(request)
{
ResponseData = result.HadErrors ? result.Errors : result.Data,
ResponseError = result.HadErrors
}, cancellationToken);
}
}

View file

@ -1,6 +1,6 @@
using Insight.Domain.Interfaces;
using Insight.Domain.Messages;
using Insight.Domain.Messages.Agent;
using Insight.Domain.Network;
using Insight.Domain.Network.Agent.Messages;
using System.Management;
using System.Runtime.Versioning;
@ -11,12 +11,16 @@ public class DriveHandler : IMessageHandler<AgentSession>
{
public async ValueTask HandleAsync<TMessage>(AgentSession sender, TMessage message, CancellationToken cancellationToken) where TMessage : IMessage
{
if (message is InventoryRequest)
switch (message)
{
var result = new DriveList();
result.AddRange(GetDrives());
case InventoryRequest:
{
var result = new Collection<Drive>();
result.AddRange(GetDrives());
await sender.SendAsync(result, cancellationToken);
await sender.SendAsync(result, cancellationToken);
break;
}
}
}

View file

@ -1,12 +1,11 @@
using Insight.Domain.Interfaces;
using Insight.Domain.Messages;
using Insight.Domain.Messages.Agent;
using Insight.Domain.Network;
using Insight.Domain.Network.Agent.Messages;
using System.Management;
using System.Net;
using System.Net.NetworkInformation;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Route = Insight.Domain.Messages.Agent.Route;
namespace Insight.Agent.Network.Handlers;
@ -15,12 +14,16 @@ public class InterfaceHandler : IMessageHandler<AgentSession>
{
public async ValueTask HandleAsync<TMessage>(AgentSession sender, TMessage message, CancellationToken cancellationToken) where TMessage : IMessage
{
if (message is InventoryRequest)
switch (message)
{
var result = new InterfaceList();
result.AddRange(GetInterfaces());
case InventoryRequest:
{
var result = new Collection<Interface>();
result.AddRange(GetInterfaces());
await sender.SendAsync(result, cancellationToken);
await sender.SendAsync(result, cancellationToken);
break;
}
}
}

View file

@ -1,6 +1,6 @@
using Insight.Domain.Interfaces;
using Insight.Domain.Messages;
using Insight.Domain.Messages.Agent;
using Insight.Domain.Network;
using Insight.Domain.Network.Agent.Messages;
using System.Management;
using System.Runtime.Versioning;
@ -11,9 +11,11 @@ public class MainboardHandler : IMessageHandler<AgentSession>
{
public async ValueTask HandleAsync<TMessage>(AgentSession sender, TMessage message, CancellationToken cancellationToken) where TMessage : IMessage
{
if (message is InventoryRequest)
switch (message)
{
await sender.SendAsync(GetMainboard(), cancellationToken);
case InventoryRequest:
await sender.SendAsync(GetMainboard(), cancellationToken);
break;
}
}

View file

@ -1,6 +1,6 @@
using Insight.Domain.Interfaces;
using Insight.Domain.Messages;
using Insight.Domain.Messages.Agent;
using Insight.Domain.Network;
using Insight.Domain.Network.Agent.Messages;
using System.Management;
using System.Runtime.Versioning;
@ -11,12 +11,16 @@ public class MemoryHandler : IMessageHandler<AgentSession>
{
public async ValueTask HandleAsync<TMessage>(AgentSession sender, TMessage message, CancellationToken cancellationToken) where TMessage : IMessage
{
if (message is InventoryRequest)
switch (message)
{
var result = new MemoryList();
result.AddRange(GetMemory());
case InventoryRequest:
{
var result = new Collection<Memory>();
result.AddRange(GetMemory());
await sender.SendAsync(result, cancellationToken);
await sender.SendAsync(result, cancellationToken);
break;
}
}
}

View file

@ -1,6 +1,6 @@
using Insight.Domain.Interfaces;
using Insight.Domain.Messages;
using Insight.Domain.Messages.Agent;
using Insight.Domain.Network;
using Insight.Domain.Network.Agent.Messages;
using Microsoft.Win32;
using System.Management;
using System.Runtime.InteropServices;
@ -14,9 +14,11 @@ public class OperationSystemHandler : IMessageHandler<AgentSession>
{
public async ValueTask HandleAsync<TMessage>(AgentSession sender, TMessage message, CancellationToken cancellationToken) where TMessage : IMessage
{
if (message is InventoryRequest)
switch (message)
{
await sender.SendAsync(GetOperatingSystem(), cancellationToken);
case InventoryRequest:
await sender.SendAsync(GetOperatingSystem(), cancellationToken);
break;
}
}

View file

@ -1,6 +1,6 @@
using Insight.Domain.Interfaces;
using Insight.Domain.Messages;
using Insight.Domain.Messages.Agent;
using Insight.Domain.Network;
using Insight.Domain.Network.Agent.Messages;
using System.Management;
using System.Runtime.Versioning;
@ -11,12 +11,16 @@ public class PrinterHandler : IMessageHandler<AgentSession>
{
public async ValueTask HandleAsync<TMessage>(AgentSession sender, TMessage message, CancellationToken cancellationToken) where TMessage : IMessage
{
if (message is InventoryRequest)
switch (message)
{
var result = new PrinterList();
result.AddRange(GetPrinters());
case InventoryRequest:
{
var result = new Collection<Printer>();
result.AddRange(GetPrinters());
await sender.SendAsync(result, cancellationToken);
await sender.SendAsync(result, cancellationToken);
break;
}
}
}

View file

@ -1,6 +1,6 @@
using Insight.Domain.Interfaces;
using Insight.Domain.Messages;
using Insight.Domain.Messages.Agent;
using Insight.Domain.Network;
using Insight.Domain.Network.Agent.Messages;
using System.Management;
using System.Runtime.Versioning;
@ -11,12 +11,16 @@ public class ProcessorHandler : IMessageHandler<AgentSession>
{
public async ValueTask HandleAsync<TMessage>(AgentSession sender, TMessage message, CancellationToken cancellationToken) where TMessage : IMessage
{
if (message is InventoryRequest)
switch (message)
{
var result = new ProcessorList();
result.AddRange(GetProcessors());
case InventoryRequest:
{
var result = new Collection<Processor>();
result.AddRange(GetProcessors());
await sender.SendAsync(result, cancellationToken);
await sender.SendAsync(result, cancellationToken);
break;
}
}
}

View file

@ -0,0 +1,44 @@
using Insight.Agent.Services;
using Insight.Domain.Interfaces;
using Insight.Domain.Network;
using Insight.Domain.Network.Agent.Messages;
using Microsoft.Extensions.Logging;
namespace Insight.Agent.Network.Handlers;
public class ProxyHandler : IMessageHandler<AgentSession>
{
private readonly ScriptService _scriptService;
private readonly ILogger<ProxyHandler> _logger;
public ProxyHandler(ScriptService scriptService, ILogger<ProxyHandler> logger)
{
_scriptService = scriptService;
_logger = logger;
}
public async ValueTask HandleAsync<TMessage>(AgentSession sender, TMessage message, CancellationToken cancellationToken) where TMessage : IMessage
{
switch (message)
{
case Proxy<Request> proxyRequest:
await OnProxyRequestAsync(sender, proxyRequest, cancellationToken);
break;
}
}
private async ValueTask OnProxyRequestAsync(AgentSession sender, Proxy<Request> proxyRequest, CancellationToken cancellationToken)
{
var result = await _scriptService.QueryAsync(proxyRequest.Message.RequestData);
await sender.SendAsync(new Proxy<Response>()
{
ProxyId = proxyRequest.ProxyId,
Message = new Response(proxyRequest.Message)
{
ResponseData = result.HadErrors ? result.Errors : result.Data,
ResponseError = result.HadErrors
}
}, cancellationToken);
}
}

View file

@ -1,6 +1,6 @@
using Insight.Domain.Interfaces;
using Insight.Domain.Messages;
using Insight.Domain.Messages.Agent;
using Insight.Domain.Network;
using Insight.Domain.Network.Agent.Messages;
using System.Management;
using System.Runtime.Versioning;
using System.ServiceProcess;
@ -12,12 +12,16 @@ public class ServiceHandler : IMessageHandler<AgentSession>
{
public async ValueTask HandleAsync<TMessage>(AgentSession sender, TMessage message, CancellationToken cancellationToken) where TMessage : IMessage
{
if (message is InventoryRequest)
switch (message)
{
var result = new ServiceList();
result.AddRange(GetServices());
case InventoryRequest:
{
var result = new Collection<Service>();
result.AddRange(GetServices());
await sender.SendAsync(result, cancellationToken);
await sender.SendAsync(result, cancellationToken);
break;
}
}
}

View file

@ -1,6 +1,6 @@
using Insight.Domain.Interfaces;
using Insight.Domain.Messages;
using Insight.Domain.Messages.Agent;
using Insight.Domain.Network;
using Insight.Domain.Network.Agent.Messages;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
@ -11,19 +11,21 @@ public class SessionHandler : IMessageHandler<AgentSession>
{
public async ValueTask HandleAsync<TMessage>(AgentSession sender, TMessage message, CancellationToken cancellationToken) where TMessage : IMessage
{
if (message is InventoryRequest)
switch (message)
{
var result = new SessionList();
result.AddRange(GetSessions());
case InventoryRequest:
{
var result = new Collection<Session>();
result.AddRange(GetSessions());
await sender.SendAsync(result, cancellationToken);
await sender.SendAsync(result, cancellationToken);
break;
}
}
}
private static List<Session> GetSessions()
{
var query = NativeMethods.GetSessions();
var sessions = new List<Session>();
foreach (var s in NativeMethods.GetSessions())

View file

@ -1,6 +1,6 @@
using Insight.Domain.Interfaces;
using Insight.Domain.Messages;
using Insight.Domain.Messages.Agent;
using Insight.Domain.Network;
using Insight.Domain.Network.Agent.Messages;
using Microsoft.Win32;
using System.Globalization;
using System.Runtime.InteropServices;
@ -14,18 +14,22 @@ internal class SoftwareHandler : IMessageHandler<AgentSession>
{
public async ValueTask HandleAsync<TMessage>(AgentSession sender, TMessage message, CancellationToken cancellationToken) where TMessage : IMessage
{
if (message is InventoryRequest)
switch (message)
{
var x64 = Task.Run(() => ApplicationRegistryQuery(RegistryView.Registry64), cancellationToken);
var x86 = Task.Run(() => ApplicationRegistryQuery(RegistryView.Registry32), cancellationToken);
case InventoryRequest:
{
var x64 = Task.Run(() => ApplicationRegistryQuery(RegistryView.Registry64), cancellationToken);
var x86 = Task.Run(() => ApplicationRegistryQuery(RegistryView.Registry32), cancellationToken);
await Task.WhenAll(x64, x86).ConfigureAwait(false);
await Task.WhenAll(x64, x86).ConfigureAwait(false);
var result = new ApplicationList();
result.AddRange(x64.Result);
result.AddRange(x86.Result.Where(p => result.All(app => p.Name != app.Name && p.Version != app.Version)));
var result = new Collection<Application>();
result.AddRange(x64.Result);
result.AddRange(x86.Result.Where(p => result.All(app => p.Name != app.Name && p.Version != app.Version)));
await sender.SendAsync(result, cancellationToken);
await sender.SendAsync(result, cancellationToken);
break;
}
}
}

View file

@ -1,11 +1,11 @@
using Insight.Domain.Interfaces;
using Insight.Domain.Messages;
using Insight.Domain.Messages.Agent;
using Insight.Domain.Network;
using Insight.Domain.Network.Agent.Messages;
using System.Management;
using System.Runtime.Versioning;
using static Insight.Domain.Messages.Agent.PhysicalDisk;
using static Insight.Domain.Messages.Agent.StoragePool;
using static Insight.Domain.Messages.Agent.VirtualDisk;
using static Insight.Domain.Network.Agent.Messages.PhysicalDisk;
using static Insight.Domain.Network.Agent.Messages.StoragePool;
using static Insight.Domain.Network.Agent.Messages.VirtualDisk;
namespace Insight.Agent.Network.Handlers;
@ -14,12 +14,16 @@ public class StoragePoolHandler : IMessageHandler<AgentSession>
{
public async ValueTask HandleAsync<TMessage>(AgentSession sender, TMessage message, CancellationToken cancellationToken) where TMessage : IMessage
{
if (message is InventoryRequest)
switch (message)
{
var result = new StoragePoolList();
result.AddRange(GetStoragePool());
case InventoryRequest:
{
var result = new Collection<StoragePool>();
result.AddRange(GetStoragePool());
await sender.SendAsync(result, cancellationToken);
await sender.SendAsync(result, cancellationToken);
break;
}
}
}

View file

@ -1,6 +1,6 @@
using Insight.Domain.Interfaces;
using Insight.Domain.Messages;
using Insight.Domain.Messages.Agent;
using Insight.Domain.Network;
using Insight.Domain.Network.Agent.Messages;
using Microsoft.Win32;
using System.Collections;
using System.Management;
@ -13,9 +13,11 @@ public class SystemInfoHandler : IMessageHandler<AgentSession>
{
public async ValueTask HandleAsync<TMessage>(AgentSession sender, TMessage message, CancellationToken cancellationToken) where TMessage : IMessage
{
if (message is InventoryRequest)
switch (message)
{
await sender.SendAsync(GetSystem(), cancellationToken);
case InventoryRequest:
await sender.SendAsync(GetSystem(), cancellationToken);
break;
}
}

View file

@ -1,10 +1,11 @@
using Insight.Domain.Interfaces;
using Insight.Domain.Messages;
using Insight.Domain.Messages.Agent;
using Insight.Domain.Network;
using Insight.Domain.Network.Agent.Messages;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using WUApiLib;
using static Insight.Domain.Messages.Agent.Update;
using static Insight.Domain.Network.Agent.Messages.Update;
using UpdateCollection = Insight.Domain.Network.Agent.Messages.UpdateCollection;
namespace Insight.Agent.Network.Handlers;
@ -13,21 +14,18 @@ public class UpdateHandler : IMessageHandler<AgentSession>
{
public async ValueTask HandleAsync<TMessage>(AgentSession sender, TMessage message, CancellationToken cancellationToken) where TMessage : IMessage
{
if (message is InventoryRequest)
switch (message)
{
await sender.SendAsync(GetUpdates(), cancellationToken);
case InventoryRequest:
await sender.SendAsync(new UpdateCollection
{
Installed = QueryInstalledUpdates(),
Pending = QueryPendingUpdates()
}, cancellationToken);
break;
}
}
private static UpdateList GetUpdates()
{
return new UpdateList
{
Installed = QueryInstalledUpdates(),
Pending = QueryPendingUpdates()
};
}
private static List<Update> QueryInstalledUpdates()
{
var updates = new List<Update>();

View file

@ -1,6 +1,6 @@
using Insight.Domain.Interfaces;
using Insight.Domain.Messages;
using Insight.Domain.Messages.Agent;
using Insight.Domain.Network;
using Insight.Domain.Network.Agent.Messages;
using System.Management;
using System.Runtime.Versioning;
@ -11,12 +11,16 @@ public class UserHandler : IMessageHandler<AgentSession>
{
public async ValueTask HandleAsync<TMessage>(AgentSession sender, TMessage message, CancellationToken cancellationToken) where TMessage : IMessage
{
if (message is InventoryRequest)
switch (message)
{
var result = new UserList();
result.AddRange(GetUsers());
case InventoryRequest:
{
var result = new Collection<User>();
result.AddRange(GetUsers());
await sender.SendAsync(result, cancellationToken);
await sender.SendAsync(result, cancellationToken);
break;
}
}
}

View file

@ -1,6 +1,6 @@
using Insight.Domain.Interfaces;
using Insight.Domain.Messages;
using Insight.Domain.Messages.Agent;
using Insight.Domain.Network;
using Insight.Domain.Network.Agent.Messages;
using System.Management;
using System.Runtime.Versioning;
@ -11,12 +11,16 @@ public class VideocardHandler : IMessageHandler<AgentSession>
{
public async ValueTask HandleAsync<TMessage>(AgentSession sender, TMessage message, CancellationToken cancellationToken) where TMessage : IMessage
{
if (message is InventoryRequest)
switch (message)
{
var result = new VideocardList();
result.AddRange(GetVideocards());
case InventoryRequest:
{
var result = new Collection<Videocard>();
result.AddRange(GetVideocards());
await sender.SendAsync(result, cancellationToken);
await sender.SendAsync(result, cancellationToken);
break;
}
}
}

View file

@ -1,10 +1,10 @@
using Insight.Domain.Interfaces;
using Insight.Domain.Messages;
using Insight.Domain.Messages.Agent;
using Insight.Domain.Network;
using Insight.Domain.Network.Agent.Messages;
using System.Management;
using System.Runtime.Versioning;
using static Insight.Domain.Messages.Agent.VirtualMaschine;
using static Insight.Domain.Messages.Agent.VirtualMaschineConfiguration;
using static Insight.Domain.Network.Agent.Messages.VirtualMaschine;
using static Insight.Domain.Network.Agent.Messages.VirtualMaschineConfiguration;
namespace Insight.Agent.Network.Handlers;
@ -13,12 +13,16 @@ public class VirtualMaschineHandler : IMessageHandler<AgentSession>
{
public async ValueTask HandleAsync<TMessage>(AgentSession sender, TMessage message, CancellationToken cancellationToken) where TMessage : IMessage
{
if (message is InventoryRequest)
switch (message)
{
var result = new VirtualMaschineList();
result.AddRange(GetVirtualMaschines());
case InventoryRequest:
{
var result = new Collection<VirtualMaschine>();
result.AddRange(GetVirtualMaschines());
await sender.SendAsync(result, cancellationToken);
await sender.SendAsync(result, cancellationToken);
break;
}
}
}

View file

@ -4,7 +4,7 @@ using Insight.Agent.Network.Handlers;
using Insight.Agent.Services;
using Insight.Domain.Constants;
using Insight.Domain.Interfaces;
using Insight.Domain.Messages;
using Insight.Domain.Network;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@ -44,12 +44,13 @@ internal class Program
builder.ConfigureServices((host, services) =>
{
// SERVICES
// HOST-SERVICES
services.AddHostedService<UpdateService>();
services.AddHostedService<TrapService>();
// SERVICES (WINDOWS)
if (OperatingSystem.IsWindows()) services.AddHostedService<EventService>();
if (OperatingSystem.IsWindows()) services.AddSingleton<ScriptService>();
// AGENT NETWORKING
services.UseHostedClient<AgentSession, IMessage>(options =>
@ -62,9 +63,11 @@ internal class Program
options.Compression = true;
options.Encryption = Encryption.Tls12;
options.UseSerializer<MemPackSerializer<IMessage>, IMessage>();
options.UseSerializer<AgentSession, IMessage, MemPackSerializer<IMessage>>();
});
services.AddSingleton<IMessageHandler<AgentSession>, CustomHandler>();
services.AddSingleton<IMessageHandler<AgentSession>, ProxyHandler>();
services.AddSingleton<IMessageHandler<AgentSession>, AuthenticationHandler>();
services.AddSingleton<IMessageHandler<AgentSession>, DriveHandler>();
services.AddSingleton<IMessageHandler<AgentSession>, InterfaceHandler>();
@ -82,9 +85,10 @@ internal class Program
services.AddSingleton<IMessageHandler<AgentSession>, UserHandler>();
services.AddSingleton<IMessageHandler<AgentSession>, VideocardHandler>();
services.AddSingleton<IMessageHandler<AgentSession>, VirtualMaschineHandler>();
services.AddSingleton<IMessageHandler<AgentSession>, ConsoleHandler>();
// GLOBAL DEPENDENCIES
//services.AddSingleton<Bus>();
services.AddTransient(provider => new HttpClient(new HttpClientHandler
{
ClientCertificateOptions = ClientCertificateOption.Manual,

View file

@ -1,13 +1,13 @@
using Insight.Agent.Network;
using Insight.Domain.Messages;
using Insight.Domain.Messages.Agent;
using Insight.Domain.Network;
using Insight.Domain.Network.Agent.Messages;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System.Diagnostics.Eventing.Reader;
using System.Runtime.Versioning;
using System.Threading.Channels;
using Vaitr.Network;
using static Insight.Domain.Messages.Agent.Event;
using static Insight.Domain.Network.Agent.Messages.Event;
using EventLevel = System.Diagnostics.Tracing.EventLevel;
namespace Insight.Agent.Services;

View file

@ -1,39 +1,19 @@
using Insight.Domain.Interfaces;
using Insight.Domain.Messages;
using Insight.Domain.Messages.Agent;
using Microsoft.Extensions.Logging;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
namespace Insight.Agent.Network.Handlers;
namespace Insight.Agent.Services;
public class ConsoleHandler : IMessageHandler<AgentSession>
public class ScriptService
{
public async ValueTask HandleAsync<TMessage>(AgentSession sender, TMessage message, CancellationToken cancellationToken) where TMessage : IMessage
private readonly ILogger<ScriptService> _logger;
public ScriptService(ILogger<ScriptService> logger)
{
if (message is Proxy<ConsoleQueryRequest> consoleQueryRequest)
{
await OnConsoleQueryRequestAsync(sender, consoleQueryRequest, cancellationToken);
}
_logger = logger;
}
private async ValueTask OnConsoleQueryRequestAsync(AgentSession sender, Proxy<ConsoleQueryRequest> consoleQueryRequest, CancellationToken cancellationToken)
{
var result = await QueryScriptAsync(consoleQueryRequest.Message.Query);
await sender.SendAsync(new Proxy<ConsoleQuery>
{
RequestId = consoleQueryRequest.RequestId,
HostId = consoleQueryRequest.HostId,
Message = new ConsoleQuery
{
Data = result.Data,
Errors = result.Errors,
HadErrors = result.HadErrors
}
}, cancellationToken);
}
private static async Task<QueryResult> QueryScriptAsync(string query)
public async Task<QueryResult> QueryAsync(string query)
{
var result = new QueryResult();
var errors = new List<string>();
@ -47,7 +27,7 @@ public class ConsoleHandler : IMessageHandler<AgentSession>
using var ps = PowerShell.Create(runspace);
ps.AddScript("Set-ExecutionPolicy unrestricted -Scope Process");
ps.AddScript(query);
ps.AddCommand("ConvertTo-Json"); // -Depth 10
//ps.AddCommand("ConvertTo-Json"); // -Depth 10
result.Query = query;
@ -60,7 +40,15 @@ public class ConsoleHandler : IMessageHandler<AgentSession>
}
else
{
result.Data = queryResult[0].ToString();
var newLine = false;
foreach (var data in queryResult)
{
if (newLine) result.Data += "\n";
else newLine = true;
result.Data += data.ToString();
}
//if (string.IsNullOrWhiteSpace(jsonString)) return result;
@ -103,12 +91,12 @@ public class ConsoleHandler : IMessageHandler<AgentSession>
result.Errors = string.Join("\n", errors);
return result;
}
}
public class QueryResult
{
public bool HadErrors { get; set; }
public string? Query { get; set; }
public string? Data { get; set; }
public string? Errors { get; set; }
public class QueryResult
{
public bool HadErrors { get; set; }
public string? Query { get; set; }
public string? Data { get; set; }
public string? Errors { get; set; }
}
}

View file

@ -1,6 +1,6 @@
using Insight.Agent.Network;
using Insight.Domain.Messages;
using Insight.Domain.Messages.Agent;
using Insight.Domain.Network;
using Insight.Domain.Network.Agent.Messages;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

View file

@ -1,5 +1,5 @@
using Insight.Agent.Extensions;
using Insight.Domain.Messages.Agent;
using Insight.Domain.Network.Agent.Messages;
using Microsoft.Extensions.Logging;
using System.Text.RegularExpressions;

View file

@ -1,5 +1,5 @@
using Insight.Agent.Extensions;
using Insight.Domain.Messages.Agent;
using Insight.Domain.Network.Agent.Messages;
using Microsoft.Extensions.Logging;
using System.Text.RegularExpressions;

View file

@ -4,7 +4,7 @@
<TargetFramework>net7.0</TargetFramework>
<Product>Insight</Product>
<AssemblyName>api</AssemblyName>
<AssemblyVersion>2023.9.21.1</AssemblyVersion>
<AssemblyVersion>2023.11.17.0</AssemblyVersion>
<RootNamespace>Insight.Api</RootNamespace>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
@ -30,17 +30,10 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.1" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.11" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.13" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="3.0.0" />
<!--Unix Serilog stuff-->
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
<PackageReference Include="System.Text.Encoding.Extensions" Version="4.3.0" />
<PackageReference Include="System.Runtime.Handles" Version="4.3.0" />
<PackageReference Include="System.IO" Version="4.3.0" />
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
<PackageReference Include="System.Threading" Version="4.3.0" />
<PackageReference Include="System.Threading.Tasks" Version="4.3.0" />
</ItemGroup>
<ItemGroup>

View file

@ -6,4 +6,4 @@
"jwt.exp": 3600,
"jwt.audience": "https://insight.webmatic.de/api",
"jwt.issuer": "https://insight.webmatic.de/api"
}
}

View file

@ -0,0 +1,8 @@
namespace Insight.Domain.Enums;
public enum RemoteControlMode
{
Unknown,
Unattended,
Attended
}

View file

@ -0,0 +1,7 @@
namespace Insight.Domain.Enums;
public enum SessionEndReasons
{
Logoff = 1,
SystemShutdown = 2
}

View file

@ -0,0 +1,14 @@
namespace Insight.Domain.Enums;
public enum SessionSwitchReason
{
ConsoleConnect = 1,
ConsoleDisconnect = 2,
RemoteConnect = 3,
RemoteDisconnect = 4,
SessionLogon = 5,
SessionLogoff = 6,
SessionLock = 7,
SessionUnlock = 8,
SessionRemoteControl = 9
}

View file

@ -6,11 +6,11 @@
<Nullable>enable</Nullable>
<RootNamespace>Insight.Domain</RootNamespace>
<Product>Insight</Product>
<AssemblyVersion>2023.9.21.1</AssemblyVersion>
<AssemblyVersion>2023.11.17.0</AssemblyVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Vaitr.Network" Version="2023.9.21" />
<PackageReference Include="Vaitr.Network" Version="2023.10.22" />
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

View file

@ -1,4 +1,4 @@
using Insight.Domain.Messages;
using Insight.Domain.Network;
namespace Insight.Domain.Interfaces;

View file

@ -1,23 +0,0 @@
using MemoryPack;
namespace Insight.Domain.Messages.Agent;
[MemoryPackable]
public partial class ConsoleQuery : IMessage
{
[MemoryPackOrder(0)]
public string? Data { get; set; }
[MemoryPackOrder(1)]
public string? Errors { get; set; }
[MemoryPackOrder(2)]
public bool HadErrors { get; set; }
}
[MemoryPackable]
public partial class ConsoleQueryRequest : IMessage
{
[MemoryPackOrder(0)]
public string? Query { get; set; }
}

View file

@ -1,46 +0,0 @@
using MemoryPack;
namespace Insight.Domain.Messages;
[MemoryPackable]
[MemoryPackUnion(0, typeof(Keepalive))]
[MemoryPackUnion(1, typeof(Agent.AuthenticationRequest))]
[MemoryPackUnion(2, typeof(Agent.Authentication))]
[MemoryPackUnion(10, typeof(Agent.InventoryRequest))]
[MemoryPackUnion(100, typeof(Agent.Application))]
[MemoryPackUnion(101, typeof(Agent.ApplicationList))]
[MemoryPackUnion(102, typeof(Agent.Drive))]
[MemoryPackUnion(103, typeof(Agent.DriveList))]
[MemoryPackUnion(104, typeof(Agent.Event))]
[MemoryPackUnion(105, typeof(Agent.Interface))]
[MemoryPackUnion(106, typeof(Agent.InterfaceList))]
[MemoryPackUnion(107, typeof(Agent.Mainboard))]
[MemoryPackUnion(108, typeof(Agent.Memory))]
[MemoryPackUnion(109, typeof(Agent.MemoryList))]
[MemoryPackUnion(110, typeof(Agent.OperationSystem))]
[MemoryPackUnion(111, typeof(Agent.Printer))]
[MemoryPackUnion(112, typeof(Agent.PrinterList))]
[MemoryPackUnion(113, typeof(Agent.Processor))]
[MemoryPackUnion(114, typeof(Agent.ProcessorList))]
[MemoryPackUnion(115, typeof(Agent.Service))]
[MemoryPackUnion(116, typeof(Agent.ServiceList))]
[MemoryPackUnion(117, typeof(Agent.Session))]
[MemoryPackUnion(118, typeof(Agent.SessionList))]
[MemoryPackUnion(119, typeof(Agent.Status))]
[MemoryPackUnion(120, typeof(Agent.StoragePool))]
[MemoryPackUnion(121, typeof(Agent.StoragePoolList))]
[MemoryPackUnion(122, typeof(Agent.SystemInfo))]
[MemoryPackUnion(123, typeof(Agent.Trap))]
[MemoryPackUnion(124, typeof(Agent.Update))]
[MemoryPackUnion(125, typeof(Agent.UpdateList))]
[MemoryPackUnion(126, typeof(Agent.User))]
[MemoryPackUnion(127, typeof(Agent.UserList))]
[MemoryPackUnion(128, typeof(Agent.Videocard))]
[MemoryPackUnion(129, typeof(Agent.VideocardList))]
[MemoryPackUnion(130, typeof(Agent.VirtualMaschine))]
[MemoryPackUnion(131, typeof(Agent.VirtualMaschineList))]
[MemoryPackUnion(132, typeof(Agent.ConsoleQuery))]
[MemoryPackUnion(133, typeof(Agent.ConsoleQueryRequest))]
[MemoryPackUnion(1000, typeof(Proxy<Agent.ConsoleQuery>))]
[MemoryPackUnion(1001, typeof(Proxy<Agent.ConsoleQueryRequest>))]
public partial interface IMessage { }

View file

@ -1,6 +0,0 @@
using MemoryPack;
namespace Insight.Domain.Messages;
[MemoryPackable]
public partial class Keepalive : IMessage { }

View file

@ -0,0 +1,148 @@
using MessagePack;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
namespace RemoteControl.Shared;
/// <summary>
/// Describes the success or failure of any kind of operation.
/// </summary>
[DataContract]
public class Result
{
/// <summary>
/// For serialization only.
/// </summary>
[SerializationConstructor]
[JsonConstructor]
public Result() { }
public Result(bool isSuccess, string reason = "", Exception? exception = null)
{
if (!isSuccess && exception is null && string.IsNullOrWhiteSpace(reason))
{
throw new ArgumentException("A reason or exception must be supplied for an unsuccessful result.");
}
IsSuccess = isSuccess;
Exception = exception;
Reason = reason;
}
[IgnoreDataMember]
public Exception? Exception { get; init; }
[IgnoreDataMember]
[MemberNotNullWhen(true, nameof(Exception))]
public bool HadException => Exception is not null;
[DataMember]
public bool IsSuccess { get; init; }
[DataMember]
public string Reason { get; init; } = string.Empty;
public static Result Fail(string reason)
{
return new Result(false, reason);
}
public static Result Fail(Exception ex)
{
return new Result(false, string.Empty, ex);
}
public static Result<T> Fail<T>(string reason)
{
return new Result<T>(reason);
}
public static Result<T> Fail<T>(Exception ex)
{
return new Result<T>(ex);
}
public static Result Ok()
{
return new Result(true);
}
public static Result<T> Ok<T>(T value)
{
return new Result<T>(value);
}
}
/// <summary>
/// Describes the success or failure of any kind of operation.
/// </summary>
[DataContract]
public class Result<T>
{
/// <summary>
/// Returns a successful result with the given value.
/// </summary>
/// <param name="value"></param>
public Result(T value)
{
IsSuccess = true;
Value = value;
}
/// <summary>
/// Returns an unsuccessful result with the given exception.
/// </summary>
/// <param name="exception"></param>
public Result(Exception exception)
{
IsSuccess = false;
Exception = exception;
Reason = exception.Message;
}
/// <summary>
/// Returns an unsuccessful result with the given reason.
/// </summary>
/// <param name="errorMessage"></param>
/// <exception cref="ArgumentException"></exception>
public Result(string reason)
{
IsSuccess = false;
Reason = reason;
}
/// <summary>
/// For serialization only.
/// </summary>
[SerializationConstructor]
[JsonConstructor]
public Result() { }
public Result(Exception? exception, bool isSuccess, string reason, T? value)
{
Exception = exception;
IsSuccess = isSuccess;
Reason = reason;
Value = value;
}
[IgnoreDataMember]
public Exception? Exception { get; init; }
[IgnoreDataMember]
[MemberNotNullWhen(true, nameof(Exception))]
public bool HadException => Exception is not null;
[DataMember]
[MemberNotNullWhen(true, nameof(Value))]
public bool IsSuccess { get; init; }
[DataMember]
public string Reason { get; init; } = string.Empty;
[DataMember]
public T? Value { get; init; }
}

View file

@ -1,7 +1,7 @@
using MemoryPack;
using System.Runtime.InteropServices;
namespace Insight.Domain.Messages.Agent;
namespace Insight.Domain.Network.Agent.Messages;
[MemoryPackable]
public partial class Application : IMessage
@ -29,7 +29,4 @@ public partial class Application : IMessage
[MemoryPackOrder(7)]
public Architecture? Architecture { get; set; }
}
[MemoryPackable(GenerateType.Collection)]
public partial class ApplicationList : List<Application>, IMessage { }
}

View file

@ -1,9 +1,12 @@
using MemoryPack;
namespace Insight.Domain.Messages.Agent;
namespace Insight.Domain.Network.Agent.Messages;
[MemoryPackable]
public partial class Authentication : IMessage
public partial class AuthenticationRequest : IMessage { }
[MemoryPackable]
public partial class AuthenticationResponse : IMessage
{
[MemoryPackOrder(0)]
public PlatformType? Platform { get; set; }
@ -23,7 +26,4 @@ public partial class Authentication : IMessage
Windows = 1,
Unix = 2
}
}
[MemoryPackable]
public partial class AuthenticationRequest : IMessage { }
}

View file

@ -1,6 +1,6 @@
using MemoryPack;
namespace Insight.Domain.Messages.Agent;
namespace Insight.Domain.Network.Agent.Messages;
[MemoryPackable]
public partial class InventoryRequest : IMessage { }

View file

@ -1,6 +1,6 @@
using MemoryPack;
namespace Insight.Domain.Messages.Agent;
namespace Insight.Domain.Network.Agent.Messages;
[MemoryPackable]
public partial class Drive : IMessage
@ -39,9 +39,6 @@ public partial class Drive : IMessage
public List<Volume>? Volumes { get; set; }
}
[MemoryPackable(GenerateType.Collection)]
public partial class DriveList : List<Drive>, IMessage { }
[MemoryPackable]
public partial class Volume : IMessage
{

View file

@ -1,6 +1,6 @@
using MemoryPack;
namespace Insight.Domain.Messages.Agent;
namespace Insight.Domain.Network.Agent.Messages;
[MemoryPackable]
public partial class Event : IMessage

View file

@ -3,7 +3,7 @@ using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
namespace Insight.Domain.Messages.Agent;
namespace Insight.Domain.Network.Agent.Messages;
[MemoryPackable]
public partial class Interface : IMessage
@ -90,9 +90,6 @@ public partial class Interface : IMessage
public List<Route>? Routes { get; set; }
}
[MemoryPackable(GenerateType.Collection)]
public partial class InterfaceList : List<Interface>, IMessage { }
[MemoryPackable]
public partial class Unicast : IMessage
{

View file

@ -1,6 +1,6 @@
using MemoryPack;
namespace Insight.Domain.Messages.Agent;
namespace Insight.Domain.Network.Agent.Messages;
[MemoryPackable]
public partial class Mainboard : IMessage

View file

@ -1,6 +1,6 @@
using MemoryPack;
namespace Insight.Domain.Messages.Agent;
namespace Insight.Domain.Network.Agent.Messages;
[MemoryPackable]
public partial class Memory : IMessage
@ -39,9 +39,6 @@ public partial class Memory : IMessage
public uint? ConfiguredVoltage { get; set; }
}
[MemoryPackable(GenerateType.Collection)]
public partial class MemoryList : List<Memory>, IMessage { }
[MemoryPackable]
public partial class MemoryMetric : IMessage
{

View file

@ -1,7 +1,7 @@
using MemoryPack;
using System.Runtime.InteropServices;
namespace Insight.Domain.Messages.Agent;
namespace Insight.Domain.Network.Agent.Messages;
[MemoryPackable]
public partial class OperationSystem : IMessage

View file

@ -1,6 +1,6 @@
using MemoryPack;
namespace Insight.Domain.Messages.Agent;
namespace Insight.Domain.Network.Agent.Messages;
[MemoryPackable]
public partial class Printer : IMessage
@ -19,7 +19,4 @@ public partial class Printer : IMessage
[MemoryPackOrder(4)]
public string? Comment { get; set; }
}
[MemoryPackable(GenerateType.Collection)]
public partial class PrinterList : List<Printer>, IMessage { }
}

View file

@ -1,6 +1,6 @@
using MemoryPack;
namespace Insight.Domain.Messages.Agent;
namespace Insight.Domain.Network.Agent.Messages;
[MemoryPackable]
public partial class Processor : IMessage
@ -51,9 +51,6 @@ public partial class Processor : IMessage
public bool? Virtualization { get; set; }
}
[MemoryPackable(GenerateType.Collection)]
public partial class ProcessorList : List<Processor>, IMessage { }
[MemoryPackable]
public partial class ProcessorMetric : IMessage
{

View file

@ -0,0 +1,61 @@
using MemoryPack;
namespace Insight.Domain.Network.Agent.Messages;
[MemoryPackable]
public partial class Request : IMessage
{
[MemoryPackOrder(0)]
public string? RequestId { get; set; }
[MemoryPackOrder(1)]
public string? RequestData { get; set; }
}
[MemoryPackable]
public partial class Response : IMessage
{
[MemoryPackOrder(0)]
public string? RequestId { get; set; }
[MemoryPackOrder(1)]
public string? RequestData { get; set; }
[MemoryPackOrder(2)]
public string? ResponseId { get; set; }
[MemoryPackOrder(3)]
public string? ResponseData { get; set; }
[MemoryPackOrder(4)]
public bool? ResponseError { get; set; }
[MemoryPackConstructor]
public Response() { }
public Response(Request request)
{
RequestId = request.RequestId;
RequestData = request.RequestData;
}
}
//[MemoryPackable]
//public partial class ConsoleQueryRequest : IMessage
//{
// [MemoryPackOrder(0)]
// public string? Query { get; set; }
//}
//[MemoryPackable]
//public partial class ConsoleQueryResponse : IMessage
//{
// [MemoryPackOrder(0)]
// public string? Data { get; set; }
// [MemoryPackOrder(1)]
// public string? Errors { get; set; }
// [MemoryPackOrder(2)]
// public bool HadErrors { get; set; }
//}

View file

@ -1,6 +1,6 @@
using MemoryPack;
namespace Insight.Domain.Messages.Agent;
namespace Insight.Domain.Network.Agent.Messages;
[MemoryPackable]
public partial class Service : IMessage
@ -53,7 +53,4 @@ public partial class Service : IMessage
Manual = 3,
Disabled = 4
}
}
[MemoryPackable(GenerateType.Collection)]
public partial class ServiceList : List<Service>, IMessage { }
}

View file

@ -1,6 +1,6 @@
using MemoryPack;
namespace Insight.Domain.Messages.Agent;
namespace Insight.Domain.Network.Agent.Messages;
[MemoryPackable]
public partial class Session : IMessage
@ -19,7 +19,4 @@ public partial class Session : IMessage
[MemoryPackOrder(4)]
public string? Remote { get; set; }
}
[MemoryPackable(GenerateType.Collection)]
public partial class SessionList : List<Session>, IMessage { }
}

View file

@ -1,6 +1,6 @@
using MemoryPack;
namespace Insight.Domain.Messages.Agent;
namespace Insight.Domain.Network.Agent.Messages;
[MemoryPackable]
public partial class Status : IMessage

View file

@ -1,6 +1,6 @@
using MemoryPack;
namespace Insight.Domain.Messages.Agent;
namespace Insight.Domain.Network.Agent.Messages;
[MemoryPackable]
public partial class StoragePool : IMessage
@ -90,9 +90,6 @@ public partial class StoragePool : IMessage
}
}
[MemoryPackable(GenerateType.Collection)]
public partial class StoragePoolList : List<StoragePool>, IMessage { }
[MemoryPackable]
public partial class PhysicalDisk : IMessage
{

View file

@ -1,6 +1,6 @@
using MemoryPack;
namespace Insight.Domain.Messages.Agent;
namespace Insight.Domain.Network.Agent.Messages;
[MemoryPackable]
public partial class SystemInfo : IMessage

View file

@ -1,6 +1,6 @@
using MemoryPack;
namespace Insight.Domain.Messages.Agent;
namespace Insight.Domain.Network.Agent.Messages;
[MemoryPackable]
public partial class Trap : IMessage

View file

@ -1,6 +1,6 @@
using MemoryPack;
namespace Insight.Domain.Messages.Agent;
namespace Insight.Domain.Network.Agent.Messages;
[MemoryPackable]
public partial class Update : IMessage
@ -68,7 +68,7 @@ public partial class Update : IMessage
}
[MemoryPackable]
public partial class UpdateList : IMessage
public partial class UpdateCollection : IMessage
{
[MemoryPackOrder(0)]
public List<Update>? Installed { get; set; }

View file

@ -1,6 +1,6 @@
using MemoryPack;
namespace Insight.Domain.Messages.Agent;
namespace Insight.Domain.Network.Agent.Messages;
[MemoryPackable]
public partial class User : IMessage
@ -45,9 +45,6 @@ public partial class User : IMessage
public List<Group>? Groups { get; set; }
}
[MemoryPackable(GenerateType.Collection)]
public partial class UserList : List<User>, IMessage { }
[MemoryPackable]
public partial class Group : IMessage
{

View file

@ -1,6 +1,6 @@
using MemoryPack;
namespace Insight.Domain.Messages.Agent;
namespace Insight.Domain.Network.Agent.Messages;
[MemoryPackable]
public partial class Videocard : IMessage
@ -19,7 +19,4 @@ public partial class Videocard : IMessage
[MemoryPackOrder(4)]
public string? DriverVersion { get; set; }
}
[MemoryPackable(GenerateType.Collection)]
public partial class VideocardList : List<Videocard>, IMessage { }
}

View file

@ -1,6 +1,6 @@
using MemoryPack;
namespace Insight.Domain.Messages.Agent;
namespace Insight.Domain.Network.Agent.Messages;
[MemoryPackable]
public partial class VirtualMaschine : IMessage
@ -150,9 +150,6 @@ public partial class VirtualMaschine : IMessage
}
}
[MemoryPackable(GenerateType.Collection)]
public partial class VirtualMaschineList : List<VirtualMaschine>, IMessage { }
[MemoryPackable]
public partial class VirtualMaschineConfiguration : IMessage
{

View file

@ -0,0 +1,7 @@
using MemoryPack;
namespace Insight.Domain.Network;
[MemoryPackable(GenerateType.Collection)]
public partial class Collection<TMessage> : List<TMessage>, IMessage where TMessage : IMessage
{ }

View file

@ -0,0 +1,54 @@
using MemoryPack;
namespace Insight.Domain.Network;
// AGENT [0 - 99]
[MemoryPackUnion(0, typeof(Agent.Messages.AuthenticationRequest))]
[MemoryPackUnion(1, typeof(Agent.Messages.AuthenticationResponse))]
[MemoryPackUnion(2, typeof(Agent.Messages.InventoryRequest))]
//[MemoryPackUnion(3, typeof(Agent.Messages.ConsoleQueryRequest))]
//[MemoryPackUnion(4, typeof(Agent.Messages.ConsoleQueryResponse))]
//[MemoryPackUnion(5, typeof(Proxy<Agent.Messages.ConsoleQueryResponse>))]
//[MemoryPackUnion(6, typeof(Proxy<Agent.Messages.ConsoleQueryRequest>))]
[MemoryPackUnion(7, typeof(Agent.Messages.Event))]
[MemoryPackUnion(8, typeof(Agent.Messages.Trap))]
[MemoryPackUnion(9, typeof(Agent.Messages.Mainboard))]
[MemoryPackUnion(10, typeof(Agent.Messages.OperationSystem))]
[MemoryPackUnion(11, typeof(Agent.Messages.Status))]
[MemoryPackUnion(12, typeof(Agent.Messages.SystemInfo))]
[MemoryPackUnion(13, typeof(Collection<Agent.Messages.Application>))]
[MemoryPackUnion(14, typeof(Collection<Agent.Messages.Drive>))]
[MemoryPackUnion(15, typeof(Collection<Agent.Messages.Interface>))]
[MemoryPackUnion(16, typeof(Collection<Agent.Messages.Memory>))]
[MemoryPackUnion(17, typeof(Collection<Agent.Messages.Printer>))]
[MemoryPackUnion(18, typeof(Collection<Agent.Messages.Processor>))]
[MemoryPackUnion(19, typeof(Collection<Agent.Messages.Service>))]
[MemoryPackUnion(20, typeof(Collection<Agent.Messages.Session>))]
[MemoryPackUnion(21, typeof(Collection<Agent.Messages.StoragePool>))]
[MemoryPackUnion(22, typeof(Agent.Messages.UpdateCollection))]
[MemoryPackUnion(23, typeof(Collection<Agent.Messages.User>))]
[MemoryPackUnion(24, typeof(Collection<Agent.Messages.Videocard>))]
[MemoryPackUnion(25, typeof(Collection<Agent.Messages.VirtualMaschine>))]
[MemoryPackUnion(50, typeof(Agent.Messages.Request))]
[MemoryPackUnion(51, typeof(Agent.Messages.Response))]
[MemoryPackUnion(52, typeof(Proxy<Agent.Messages.Request>))]
[MemoryPackUnion(53, typeof(Proxy<Agent.Messages.Response>))]
// REMOTE [100 - 199]
[MemoryPackUnion(102, typeof(Remote.Messages.RemoteSessionRequest))]
[MemoryPackUnion(103, typeof(Remote.Messages.RemoteSessionResponse))]
[MemoryPackUnion(104, typeof(Remote.Messages.CastRequest))]
[MemoryPackUnion(105, typeof(Remote.Messages.CastRequestResponse))]
[MemoryPackUnion(107, typeof(Remote.Messages.CastAbort))]
[MemoryPackUnion(108, typeof(Remote.Messages.CastMetric))]
[MemoryPackUnion(109, typeof(Remote.Messages.CastDisplay))]
[MemoryPackUnion(110, typeof(Remote.Messages.CastScreen))]
[MemoryPackUnion(111, typeof(Remote.Messages.CastScreenReceived))]
[MemoryPackUnion(112, typeof(Remote.Messages.CastCursor))]
[MemoryPackUnion(113, typeof(Remote.Messages.CastCursorReceived))]
[MemoryPackUnion(114, typeof(Remote.Messages.CastClipboardReceived))]
[MemoryPackUnion(115, typeof(Remote.Messages.CastAudio))]
[MemoryPackable]
public partial interface IMessage { }

View file

@ -1,17 +1,14 @@
using MemoryPack;
namespace Insight.Domain.Messages;
namespace Insight.Domain.Network;
[MemoryPackable]
public partial class Proxy<TMessage> : IMessage
where TMessage : IMessage
{
[MemoryPackOrder(0)]
public string? RequestId { get; set; }
public string? ProxyId { get; set; }
[MemoryPackOrder(1)]
public string? HostId { get; set; }
[MemoryPackOrder(2)]
public TMessage? Message { get; set; }
}

View file

@ -0,0 +1,24 @@
using Insight.Domain.Enums;
using MemoryPack;
namespace Insight.Domain.Network.Remote.Messages;
[MemoryPackable]
public partial class RemoteSessionRequest : IMessage
{
[MemoryPackOrder(0)]
public RemoteControlMode Mode { get; set; }
[MemoryPackOrder(1)]
public string? AccessKey { get; set; }
[MemoryPackOrder(2)]
public string? Hostname { get; set; }
}
[MemoryPackable]
public partial class RemoteSessionResponse : IMessage
{
[MemoryPackOrder(0)]
public string? SessionId { get; set; }
}

View file

@ -0,0 +1,185 @@
using Insight.Domain.Enums;
using MemoryPack;
namespace Insight.Domain.Network.Remote.Messages;
[MemoryPackable]
public partial class CastRequest : IMessage
{
[MemoryPackOrder(0)]
public string? Id { get; set; }
[MemoryPackOrder(1)]
public RemoteControlMode Mode { get; set; }
[MemoryPackOrder(2)]
public string? RequesterName { get; set; }
[MemoryPackOrder(3)]
public string? AccessKey { get; set; }
}
[MemoryPackable]
public partial class CastRequestResponse : IMessage
{
[MemoryPackOrder(0)]
public string? Id { get; set; }
[MemoryPackOrder(0)]
public bool Accepted { get; set; }
[MemoryPackConstructor]
public CastRequestResponse() { }
public CastRequestResponse(CastRequest request)
{
Id = request.Id;
}
}
[MemoryPackable]
public partial class CastAbort : IMessage
{
[MemoryPackOrder(0)]
public string? Id { get; set; }
}
[MemoryPackable]
public partial class CastMetric : IMessage
{
[MemoryPackOrder(0)]
public string? Id { get; set; }
[MemoryPackOrder(1)]
public DateTimeOffset? Timestamp { get; set; }
[MemoryPackOrder(2)]
public double? Mbps { get; set; }
[MemoryPackOrder(3)]
public double? Fps { get; set; }
[MemoryPackOrder(4)]
public double? RTT { get; set; }
}
[MemoryPackable]
public partial class CastDisplay : IMessage
{
[MemoryPackOrder(0)]
public string? Id { get; set; }
[MemoryPackOrder(1)]
public IEnumerable<string>? DisplayNames { get; set; }
[MemoryPackOrder(2)]
public string? SelectedDisplay { get; set; }
[MemoryPackOrder(3)]
public int ScreenWidth { get; set; }
[MemoryPackOrder(4)]
public int ScreenHeight { get; set; }
[MemoryPackOrder(5)]
public string? MachineName { get; set; }
}
[MemoryPackable]
public partial class CastScreen : IMessage
{
[MemoryPackOrder(0)]
public string? Id { get; set; }
[MemoryPackOrder(1)]
public DateTimeOffset? Timestamp { get; set; }
[MemoryPackOrder(2)]
public float? ViewWidth { get; set; }
[MemoryPackOrder(3)]
public float? ViewHeight { get; set; }
[MemoryPackOrder(4)]
public float? Left { get; set; }
[MemoryPackOrder(5)]
public float? Top { get; set; }
[MemoryPackOrder(6)]
public float? Width { get; set; }
[MemoryPackOrder(7)]
public float? Height { get; set; }
[MemoryPackOrder(8)]
public byte[]? Image { get; set; }
}
[MemoryPackable]
public partial class CastScreenReceived : IMessage
{
[MemoryPackOrder(0)]
public string? Id { get; set; }
[MemoryPackOrder(1)]
public DateTimeOffset? Timestamp { get; set; }
[MemoryPackConstructor]
public CastScreenReceived() { }
public CastScreenReceived(CastScreen screenData)
{
Id = screenData.Id;
Timestamp = screenData.Timestamp;
}
}
[MemoryPackable]
public partial class CastCursor : IMessage
{
[MemoryPackOrder(0)]
public string? Id { get; set; }
[MemoryPackOrder(1)]
public int X { get; set; }
[MemoryPackOrder(2)]
public int Y { get; set; }
[MemoryPackOrder(3)]
public byte[]? Icon { get; set; }
}
[MemoryPackable]
public partial class CastCursorReceived : IMessage
{
[MemoryPackOrder(0)]
public string? Id { get; set; }
[MemoryPackOrder(1)]
public int X { get; set; }
[MemoryPackOrder(2)]
public int Y { get; set; }
}
[MemoryPackable]
public partial class CastClipboardReceived : IMessage
{
[MemoryPackOrder(0)]
public string? Id { get; set; }
[MemoryPackOrder(1)]
public string? Text { get; set; }
}
[MemoryPackable]
public partial class CastAudio : IMessage
{
[MemoryPackOrder(0)]
public string? Id { get; set; }
[MemoryPackOrder(1)]
public byte[]? Buffer { get; set; }
}

View file

@ -10,4 +10,8 @@ public class Appsettings
public const string ServerHost = "server.host";
public const string ServerPort = "server.port";
public const string RemoteServerPort = "remote.port";
public const string RemoteServerCertificate = "remote.certificate";
public const string RemoteServerCertificatePassword = "remote.certificate.password";
}

View file

@ -1,10 +1,16 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<AgentEntity> Agent(this IMongoDatabase database) => database.GetCollection<AgentEntity>("agent");
}
[BsonIgnoreExtraElements]
public class AgentEntity
{

View file

@ -1,9 +1,15 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<AgentLogEntity> AgentLog(this IMongoDatabase database) => database.GetCollection<AgentLogEntity>("agent_log");
}
[BsonIgnoreExtraElements]
public class AgentLogEntity
{

View file

@ -1,10 +1,16 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<CustomerEntity> Customer(this IMongoDatabase database) => database.GetCollection<CustomerEntity>("customer");
}
[BsonIgnoreExtraElements]
public class CustomerEntity
{

View file

@ -1,10 +1,16 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<HostEntity> Host(this IMongoDatabase database) => database.GetCollection<HostEntity>("host");
}
[BsonIgnoreExtraElements]
public class HostEntity
{

View file

@ -1,9 +1,15 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<HostApplicationEntity> HostApplication(this IMongoDatabase database) => database.GetCollection<HostApplicationEntity>("host_app");
}
[BsonIgnoreExtraElements]
public class HostApplicationEntity
{

View file

@ -1,9 +1,15 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<HostDriveEntity> HostDrive(this IMongoDatabase database) => database.GetCollection<HostDriveEntity>("host_drv");
}
[BsonIgnoreExtraElements]
public class HostDriveEntity
{

View file

@ -1,9 +1,16 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<HostHypervisorVirtualMaschineEntity> HostHypervisorVirtualMaschine(this IMongoDatabase database) => database.GetCollection<HostHypervisorVirtualMaschineEntity>("host_hv_vm");
public static IMongoCollection<HostHypervisorVirtualMaschineConfigEntity> HostVirtualMaschineConfig(this IMongoDatabase database) => database.GetCollection<HostHypervisorVirtualMaschineConfigEntity>("host_hv_vm_cfg");
}
[BsonIgnoreExtraElements]
public class HostHypervisorVirtualMaschineEntity
{

View file

@ -1,9 +1,19 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<HostInterfaceEntity> HostInterface(this IMongoDatabase database) => database.GetCollection<HostInterfaceEntity>("host_if");
public static IMongoCollection<HostInterfaceAddressEntity> HostInterfaceAddress(this IMongoDatabase database) => database.GetCollection<HostInterfaceAddressEntity>("host_if_addr");
public static IMongoCollection<HostInterfaceGatewayEntity> HostInterfaceGateway(this IMongoDatabase database) => database.GetCollection<HostInterfaceGatewayEntity>("host_if_gw");
public static IMongoCollection<HostInterfaceNameserverEntity> HostInterfaceNameserver(this IMongoDatabase database) => database.GetCollection<HostInterfaceNameserverEntity>("host_if_ns");
public static IMongoCollection<HostInterfaceRouteEntity> HostInterfaceRoute(this IMongoDatabase database) => database.GetCollection<HostInterfaceRouteEntity>("host_if_rt");
}
[BsonIgnoreExtraElements]
public class HostInterfaceEntity
{

View file

@ -1,9 +1,15 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<HostLogEntity> HostLog(this IMongoDatabase database) => database.GetCollection<HostLogEntity>("host_log");
}
[BsonIgnoreExtraElements]
public class HostLogEntity
{

View file

@ -1,9 +1,15 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<HostLogMonitoringEntity> HostLogMonitoring(this IMongoDatabase database) => database.GetCollection<HostLogMonitoringEntity>("host_log_mon");
}
[BsonIgnoreExtraElements]
public class HostLogMonitoringEntity
{

View file

@ -1,9 +1,15 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<HostMainboardEntity> HostMainboard(this IMongoDatabase database) => database.GetCollection<HostMainboardEntity>("host_board");
}
[BsonIgnoreExtraElements]
public class HostMainboardEntity
{

View file

@ -1,9 +1,15 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<HostMemoryEntity> HostMemory(this IMongoDatabase database) => database.GetCollection<HostMemoryEntity>("host_mem");
}
[BsonIgnoreExtraElements]
public class HostMemoryEntity
{

View file

@ -1,9 +1,15 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<HostOsEntity> HostOs(this IMongoDatabase database) => database.GetCollection<HostOsEntity>("host_os");
}
[BsonIgnoreExtraElements]
public class HostOsEntity
{

View file

@ -1,9 +1,15 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<HostPrinterEntity> HostPrinter(this IMongoDatabase database) => database.GetCollection<HostPrinterEntity>("host_prn");
}
[BsonIgnoreExtraElements]
public class HostPrinterEntity
{

View file

@ -1,9 +1,15 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<HostProcessorEntity> HostProcessor(this IMongoDatabase database) => database.GetCollection<HostProcessorEntity>("host_cpu");
}
[BsonIgnoreExtraElements]
public class HostProcessorEntity
{

View file

@ -1,9 +1,15 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<HostServiceEntity> HostService(this IMongoDatabase database) => database.GetCollection<HostServiceEntity>("host_svc");
}
[BsonIgnoreExtraElements]
public class HostServiceEntity
{

View file

@ -1,9 +1,15 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<HostSessionEntity> HostSession(this IMongoDatabase database) => database.GetCollection<HostSessionEntity>("host_session");
}
[BsonIgnoreExtraElements]
public class HostSessionEntity
{

View file

@ -1,9 +1,17 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<HostStoragePoolEntity> HostStoragePool(this IMongoDatabase database) => database.GetCollection<HostStoragePoolEntity>("host_sp");
public static IMongoCollection<HostStoragePoolPhysicalDiskEntity> HostStoragePoolPhysicalDisk(this IMongoDatabase database) => database.GetCollection<HostStoragePoolPhysicalDiskEntity>("host_sp.pd");
public static IMongoCollection<HostStoragePoolVirtualDiskEntity> HostStoragePoolVirtualDisk(this IMongoDatabase database) => database.GetCollection<HostStoragePoolVirtualDiskEntity>("host_sp.vd");
}
[BsonIgnoreExtraElements]
public class HostStoragePoolEntity
{

View file

@ -0,0 +1,45 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<HostSysGroupEntity> HostSystemGroup(this IMongoDatabase database) => database.GetCollection<HostSysGroupEntity>("host_sysgrp");
}
[BsonIgnoreExtraElements]
public class HostSysGroupEntity
{
[BsonId, BsonRepresentation(BsonType.ObjectId), JsonPropertyName("id")]
public string? Id { get; set; }
[BsonElement("_host"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("host")]
public string? Host { get; set; }
[BsonElement("_batch"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("batch")]
public string? Batch { get; set; }
[BsonElement("insert")]
public DateTime? Insert { get; set; }
[BsonElement("update")]
public DateTime? Update { get; set; }
[BsonElement("sid")]
public string? Sid { get; set; }
[BsonElement("name")]
public string? Name { get; set; }
[BsonElement("domain")]
public string? Domain { get; set; }
[BsonElement("description")]
public string? Description { get; set; }
[BsonElement("localaccount")]
public bool? LocalAccount { get; set; }
}

View file

@ -0,0 +1,66 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<HostSysUserEntity> HostSystemUser(this IMongoDatabase database) => database.GetCollection<HostSysUserEntity>("host_sysusr");
}
[BsonIgnoreExtraElements]
public class HostSysUserEntity
{
[BsonId, BsonRepresentation(BsonType.ObjectId), JsonPropertyName("id")]
public string? Id { get; set; }
[BsonElement("_host"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("host")]
public string? Host { get; set; }
[BsonElement("_batch"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("batch")]
public string? Batch { get; set; }
[BsonElement("insert")]
public DateTime? Insert { get; set; }
[BsonElement("update")]
public DateTime? Update { get; set; }
[BsonElement("sid")]
public string? Sid { get; set; }
[BsonElement("name")]
public string? Name { get; set; }
[BsonElement("domain")]
public string? Domain { get; set; }
[BsonElement("fullname")]
public string? FullName { get; set; }
[BsonElement("description")]
public string? Description { get; set; }
[BsonElement("status")]
public string? Status { get; set; }
[BsonElement("localaccount")]
public bool? LocalAccount { get; set; }
[BsonElement("disabled")]
public bool? Disabled { get; set; }
[BsonElement("lockout")]
public bool? Lockout { get; set; }
[BsonElement("password_changeable")]
public bool? PasswordChangeable { get; set; }
[BsonElement("password_expires")]
public bool? PasswordExpires { get; set; }
[BsonElement("password_required")]
public bool? PasswordRequired { get; set; }
}

View file

@ -0,0 +1,36 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<HostSysUserSysGroupEntity> HostSystemUserSystemGroup(this IMongoDatabase database) => database.GetCollection<HostSysUserSysGroupEntity>("host_sysusr_sysgrp");
}
[BsonIgnoreExtraElements]
public class HostSysUserSysGroupEntity
{
[BsonId, BsonRepresentation(BsonType.ObjectId), JsonPropertyName("id")]
public string? Id { get; set; }
[BsonElement("_host"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("host")]
public string? Host { get; set; }
[BsonElement("_user"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("user")]
public string? User { get; set; }
[BsonElement("_group"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("group")]
public string? Group { get; set; }
[BsonElement("_batch"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("batch")]
public string? Batch { get; set; }
[BsonElement("insert")]
public DateTime? Insert { get; set; }
[BsonElement("update")]
public DateTime? Update { get; set; }
}

View file

@ -1,9 +1,15 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<HostSystemEntity> HostSystem(this IMongoDatabase database) => database.GetCollection<HostSystemEntity>("host_sys");
}
[BsonIgnoreExtraElements]
public class HostSystemEntity
{

View file

@ -1,9 +1,15 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<HostUpdateEntity> HostUpdate(this IMongoDatabase database) => database.GetCollection<HostUpdateEntity>("host_upd");
}
[BsonIgnoreExtraElements]
public class HostUpdateEntity
{

View file

@ -1,9 +1,15 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<HostVideocardEntity> HostVideocard(this IMongoDatabase database) => database.GetCollection<HostVideocardEntity>("host_gpu");
}
[BsonIgnoreExtraElements]
public class HostVideocardEntity
{

View file

@ -1,9 +1,15 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<HostVolumeEntity> HostVolume(this IMongoDatabase database) => database.GetCollection<HostVolumeEntity>("host_vol");
}
[BsonIgnoreExtraElements]
public class HostVolumeEntity
{

View file

@ -0,0 +1,31 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<HostGroupEntity> HostGroup(this IMongoDatabase database) => database.GetCollection<HostGroupEntity>("hostgroup");
}
[BsonIgnoreExtraElements]
public class HostGroupEntity
{
[BsonId, BsonRepresentation(BsonType.ObjectId), JsonPropertyName("id")]
public string? Id { get; set; }
[BsonElement("name"), Required]
public string? Name { get; set; }
[BsonElement("description")]
public string? Description { get; set; }
[BsonElement("insert")]
public DateTime? Insert { get; set; }
[BsonElement("update")]
public DateTime? Update { get; set; }
}

View file

@ -0,0 +1,30 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<HostGroupHostEntity> HostGroupHost(this IMongoDatabase database) => database.GetCollection<HostGroupHostEntity>("hostgroup_host");
}
[BsonIgnoreExtraElements]
public class HostGroupHostEntity
{
[BsonId, BsonRepresentation(BsonType.ObjectId), JsonPropertyName("id")]
public string? Id { get; set; }
[BsonElement("_hostgroup"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("hostgroup")]
public string? HostGroup { get; set; }
[BsonElement("_host"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("host")]
public string? Host { get; set; }
[BsonElement("insert")]
public DateTime? Insert { get; set; }
[BsonElement("update")]
public DateTime? Update { get; set; }
}

View file

@ -1,119 +0,0 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
[BsonIgnoreExtraElements]
public class HostUserEntity
{
[BsonId, BsonRepresentation(BsonType.ObjectId), JsonPropertyName("id")]
public string? Id { get; set; }
[BsonElement("_host"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("host")]
public string? Host { get; set; }
[BsonElement("_batch"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("batch")]
public string? Batch { get; set; }
[BsonElement("insert")]
public DateTime? Insert { get; set; }
[BsonElement("update")]
public DateTime? Update { get; set; }
[BsonElement("sid")]
public string? Sid { get; set; }
[BsonElement("name")]
public string? Name { get; set; }
[BsonElement("domain")]
public string? Domain { get; set; }
[BsonElement("fullname")]
public string? FullName { get; set; }
[BsonElement("description")]
public string? Description { get; set; }
[BsonElement("status")]
public string? Status { get; set; }
[BsonElement("localaccount")]
public bool? LocalAccount { get; set; }
[BsonElement("disabled")]
public bool? Disabled { get; set; }
[BsonElement("lockout")]
public bool? Lockout { get; set; }
[BsonElement("password_changeable")]
public bool? PasswordChangeable { get; set; }
[BsonElement("password_expires")]
public bool? PasswordExpires { get; set; }
[BsonElement("password_required")]
public bool? PasswordRequired { get; set; }
}
[BsonIgnoreExtraElements]
public class HostGroupEntity
{
[BsonId, BsonRepresentation(BsonType.ObjectId), JsonPropertyName("id")]
public string? Id { get; set; }
[BsonElement("_host"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("host")]
public string? Host { get; set; }
[BsonElement("_batch"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("batch")]
public string? Batch { get; set; }
[BsonElement("insert")]
public DateTime? Insert { get; set; }
[BsonElement("update")]
public DateTime? Update { get; set; }
[BsonElement("sid")]
public string? Sid { get; set; }
[BsonElement("name")]
public string? Name { get; set; }
[BsonElement("domain")]
public string? Domain { get; set; }
[BsonElement("description")]
public string? Description { get; set; }
[BsonElement("localaccount")]
public bool? LocalAccount { get; set; }
}
[BsonIgnoreExtraElements]
public class HostUserGroupEntity
{
[BsonId, BsonRepresentation(BsonType.ObjectId), JsonPropertyName("id")]
public string? Id { get; set; }
[BsonElement("_host"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("host")]
public string? Host { get; set; }
[BsonElement("_user"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("user")]
public string? User { get; set; }
[BsonElement("_group"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("group")]
public string? Group { get; set; }
[BsonElement("_batch"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("batch")]
public string? Batch { get; set; }
[BsonElement("insert")]
public DateTime? Insert { get; set; }
[BsonElement("update")]
public DateTime? Update { get; set; }
}

View file

@ -1,11 +1,20 @@
using AspNetCore.Identity.MongoDbCore.Models;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using MongoDbGenericRepository.Attributes;
using System.Text.Json.Serialization;
namespace Insight.Infrastructure.Entities;
public static partial class MongoDatabaseExtensions
{
public static IMongoCollection<InsightUser> User(this IMongoDatabase database) => database.GetCollection<InsightUser>("user");
public static IMongoCollection<InsightUserLogEntity> UserLog(this IMongoDatabase database) => database.GetCollection<InsightUserLogEntity>("user_log");
public static IMongoCollection<InsightUserPreferences> UserPreference(this IMongoDatabase database) => database.GetCollection<InsightUserPreferences>("user_pref");
public static IMongoCollection<InsightRole> Role(this IMongoDatabase database) => database.GetCollection<InsightRole>("role");
}
[CollectionName("user"), BsonIgnoreExtraElements]
public class InsightUser : MongoIdentityUser<ObjectId>
{

View file

@ -1,56 +0,0 @@
using Insight.Infrastructure.Entities;
using MongoDB.Driver;
namespace Insight.Infrastructure;
public static class MongoDatabaseExtensions
{
// internal users (roles), groups...
public static IMongoCollection<InsightUser> User(this IMongoDatabase database) => database.GetCollection<InsightUser>("user");
public static IMongoCollection<InsightUserLogEntity> UserLog(this IMongoDatabase database) => database.GetCollection<InsightUserLogEntity>("user_log");
public static IMongoCollection<InsightUserPreferences> UserPreference(this IMongoDatabase database) => database.GetCollection<InsightUserPreferences>("user_pref");
public static IMongoCollection<InsightRole> Role(this IMongoDatabase database) => database.GetCollection<InsightRole>("role");
// customers
public static IMongoCollection<CustomerEntity> Customer(this IMongoDatabase database) => database.GetCollection<CustomerEntity>("customer");
// agents
public static IMongoCollection<AgentEntity> Agent(this IMongoDatabase database) => database.GetCollection<AgentEntity>("agent");
public static IMongoCollection<AgentLogEntity> AgentLog(this IMongoDatabase database) => database.GetCollection<AgentLogEntity>("agent_log");
// host groups
public static IMongoCollection<HostEntity> HostGroup(this IMongoDatabase database) => database.GetCollection<HostEntity>("host");
// hosts
public static IMongoCollection<HostEntity> Host(this IMongoDatabase database) => database.GetCollection<HostEntity>("host");
public static IMongoCollection<HostLogEntity> HostLog(this IMongoDatabase database) => database.GetCollection<HostLogEntity>("host_log");
// hosts extensions
public static IMongoCollection<HostLogMonitoringEntity> HostLogMonitoring(this IMongoDatabase database) => database.GetCollection<HostLogMonitoringEntity>("host_log_mon");
public static IMongoCollection<HostApplicationEntity> HostApplication(this IMongoDatabase database) => database.GetCollection<HostApplicationEntity>("host_app");
public static IMongoCollection<HostDriveEntity> HostDrive(this IMongoDatabase database) => database.GetCollection<HostDriveEntity>("host_drv");
public static IMongoCollection<HostVolumeEntity> HostVolume(this IMongoDatabase database) => database.GetCollection<HostVolumeEntity>("host_vol");
public static IMongoCollection<HostOsEntity> HostOs(this IMongoDatabase database) => database.GetCollection<HostOsEntity>("host_os");
public static IMongoCollection<HostUpdateEntity> HostUpdate(this IMongoDatabase database) => database.GetCollection<HostUpdateEntity>("host_upd");
public static IMongoCollection<HostSessionEntity> HostSession(this IMongoDatabase database) => database.GetCollection<HostSessionEntity>("host_session");
public static IMongoCollection<HostServiceEntity> HostService(this IMongoDatabase database) => database.GetCollection<HostServiceEntity>("host_svc");
public static IMongoCollection<HostPrinterEntity> HostPrinter(this IMongoDatabase database) => database.GetCollection<HostPrinterEntity>("host_prn");
public static IMongoCollection<HostMainboardEntity> HostMainboard(this IMongoDatabase database) => database.GetCollection<HostMainboardEntity>("host_board");
public static IMongoCollection<HostProcessorEntity> HostProcessor(this IMongoDatabase database) => database.GetCollection<HostProcessorEntity>("host_cpu");
public static IMongoCollection<HostMemoryEntity> HostMemory(this IMongoDatabase database) => database.GetCollection<HostMemoryEntity>("host_mem");
public static IMongoCollection<HostVideocardEntity> HostVideocard(this IMongoDatabase database) => database.GetCollection<HostVideocardEntity>("host_gpu");
public static IMongoCollection<HostUserEntity> HostSystemUser(this IMongoDatabase database) => database.GetCollection<HostUserEntity>("host_sysusr");
public static IMongoCollection<HostGroupEntity> HostSystemGroup(this IMongoDatabase database) => database.GetCollection<HostGroupEntity>("host_sysgrp");
public static IMongoCollection<HostUserGroupEntity> HostSystemUserSystemGroup(this IMongoDatabase database) => database.GetCollection<HostUserGroupEntity>("host_sysusr_sysgrp");
public static IMongoCollection<HostSystemEntity> HostSystem(this IMongoDatabase database) => database.GetCollection<HostSystemEntity>("host_sys");
public static IMongoCollection<HostStoragePoolEntity> HostStoragePool(this IMongoDatabase database) => database.GetCollection<HostStoragePoolEntity>("host_sp");
public static IMongoCollection<HostStoragePoolPhysicalDiskEntity> HostStoragePoolPhysicalDisk(this IMongoDatabase database) => database.GetCollection<HostStoragePoolPhysicalDiskEntity>("host_sp.pd");
public static IMongoCollection<HostStoragePoolVirtualDiskEntity> HostStoragePoolVirtualDisk(this IMongoDatabase database) => database.GetCollection<HostStoragePoolVirtualDiskEntity>("host_sp.vd");
public static IMongoCollection<HostHypervisorVirtualMaschineEntity> HostHypervisorVirtualMaschine(this IMongoDatabase database) => database.GetCollection<HostHypervisorVirtualMaschineEntity>("host_hv_vm");
public static IMongoCollection<HostHypervisorVirtualMaschineConfigEntity> HostVirtualMaschineConfig(this IMongoDatabase database) => database.GetCollection<HostHypervisorVirtualMaschineConfigEntity>("host_hv_vm_cfg");
public static IMongoCollection<HostInterfaceEntity> HostInterface(this IMongoDatabase database) => database.GetCollection<HostInterfaceEntity>("host_if");
public static IMongoCollection<HostInterfaceAddressEntity> HostInterfaceAddress(this IMongoDatabase database) => database.GetCollection<HostInterfaceAddressEntity>("host_if_addr");
public static IMongoCollection<HostInterfaceGatewayEntity> HostInterfaceGateway(this IMongoDatabase database) => database.GetCollection<HostInterfaceGatewayEntity>("host_if_gw");
public static IMongoCollection<HostInterfaceNameserverEntity> HostInterfaceNameserver(this IMongoDatabase database) => database.GetCollection<HostInterfaceNameserverEntity>("host_if_ns");
public static IMongoCollection<HostInterfaceRouteEntity> HostInterfaceRoute(this IMongoDatabase database) => database.GetCollection<HostInterfaceRouteEntity>("host_if_rt");
}

View file

@ -4,7 +4,7 @@
<TargetFramework>net7.0</TargetFramework>
<RootNamespace>Insight.Infrastructure</RootNamespace>
<Product>Insight</Product>
<AssemblyVersion>2023.9.21.1</AssemblyVersion>
<AssemblyVersion>2023.11.17.0</AssemblyVersion>
<ImplicitUsings>true</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
@ -18,10 +18,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.11" />
<PackageReference Include="MongoDB.Driver" Version="2.21.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.13" />
<PackageReference Include="MongoDB.Driver" Version="2.22.0" />
<PackageReference Include="AspNetCore.Identity.MongoDbCore" Version="3.1.2" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.0.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.0.3" />
</ItemGroup>
<ItemGroup>

View file

@ -0,0 +1,6 @@
namespace Insight.Remote.Shared.Abstractions;
public interface IAudioProvider
{
Task InitAsync(CancellationToken cancellationToken);
}

View file

@ -0,0 +1,7 @@
namespace Insight.Remote.Shared.Abstractions;
public interface IClipboardProvider
{
Task InitAsync(CancellationToken cancellationToken);
Task SetText(string clipboardText);
}

Some files were not shown because too many files have changed in this diff Show more