diff --git a/src/Agent/Insight.Agent.Assets/Insight.Agent.Assets.csproj b/src/Agent/Insight.Agent.Assets/Insight.Agent.Assets.csproj index 540ca66..26c306e 100644 --- a/src/Agent/Insight.Agent.Assets/Insight.Agent.Assets.csproj +++ b/src/Agent/Insight.Agent.Assets/Insight.Agent.Assets.csproj @@ -7,7 +7,10 @@ Insight.Agent.Assets Insight.Agent Insight - 2023.9.14.0 + 2025.2.24.0 + 2025.2.24.0 + none + true @@ -19,8 +22,8 @@ - - + + diff --git a/src/Agent/Insight.Agent/Insight.Agent.csproj b/src/Agent/Insight.Agent/Insight.Agent.csproj index 59ff570..59caaa1 100644 --- a/src/Agent/Insight.Agent/Insight.Agent.csproj +++ b/src/Agent/Insight.Agent/Insight.Agent.csproj @@ -3,12 +3,16 @@ Exe net7.0 + latest Insight.Agent Insight agent - 2023.9.14.0 + 2025.2.24.0 + 2025.2.24.0 enable enable + none + true diff --git a/src/Agent/Insight.Agent/Network/AgentSession.cs b/src/Agent/Insight.Agent/Network/AgentSession.cs index 84678ea..4b17ea0 100644 --- a/src/Agent/Insight.Agent/Network/AgentSession.cs +++ b/src/Agent/Insight.Agent/Network/AgentSession.cs @@ -1,57 +1,30 @@ using Insight.Agent.Interfaces; using Insight.Agent.Messages; using Microsoft.Extensions.Logging; +using System.Net.Sockets; using Vaitr.Network; -namespace Insight.Agent.Network +namespace Insight.Agent.Network; + +public class AgentSession(IEnumerable> handlers, Socket socket, Stream stream, TcpConnectionOptions options, MemPackSerializer serializer, ILogger logger) + : TcpSession(socket, stream, options, serializer, logger) { - public class AgentSession : TcpSession + private readonly IEnumerable> _handlers = handlers; + + protected override async ValueTask OnReceivedAsync(PacketContext context, CancellationToken cancellationToken) { - private readonly IEnumerable> _handlers; + await base.OnReceivedAsync(context, cancellationToken); - public AgentSession(IEnumerable> handlers, ISerializer serializer, ILogger logger) : base(serializer, logger) + foreach (var handler in _handlers) { - _handlers = handlers; - } - - protected override ValueTask OnConnectedAsync(CancellationToken cancellationToken) - { - _logger.LogInformation("Agent ({ep?}) connected", RemoteEndPoint); - return default; - } - - protected override ValueTask OnDisconnectedAsync(CancellationToken cancellationToken) - { - _logger.LogInformation("Agent ({ep?}) disconnected", RemoteEndPoint); - return default; - } - - protected override ValueTask OnSentAsync(IPacketContext context, CancellationToken cancellationToken) - { - return base.OnSentAsync(context, cancellationToken); - } - - protected override async ValueTask OnReceivedAsync(IPacketContext context, CancellationToken cancellationToken) - { - await base.OnReceivedAsync(context, cancellationToken); - - foreach (var handler in _handlers) + try { - try - { - await handler.HandleAsync(this, context.Packet, cancellationToken); - } - catch (Exception ex) - { - _logger.LogWarning("Agent ({ep?}) {ex}", RemoteEndPoint, ex.ToString()); - } + await handler.HandleAsync(this, context.Data, cancellationToken); + } + catch (Exception ex) + { + _logger.LogWarning("Agent ({ep?}) {ex}", RemoteEndPoint, ex.ToString()); } - } - - protected override ValueTask OnHeartbeatAsync(CancellationToken cancellationToken) - { - _logger.LogInformation("Agent ({ep?}) Heartbeat", RemoteEndPoint); - return default; } } } \ No newline at end of file diff --git a/src/Agent/Insight.Agent/Program.cs b/src/Agent/Insight.Agent/Program.cs index 005cb9e..15ed188 100644 --- a/src/Agent/Insight.Agent/Program.cs +++ b/src/Agent/Insight.Agent/Program.cs @@ -10,7 +10,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Vaitr.Network; -using Vaitr.Network.Hosting; namespace Insight.Agent.Windows { @@ -52,15 +51,20 @@ namespace Insight.Agent.Windows if (OperatingSystem.IsWindows()) services.AddHostedService(); // AGENT NETWORKING - services.UseHostedClient(options => + services.UseHostedTcpClient(options => { options.Host = host.Configuration.GetValue(Appsettings.ServerHost) ?? throw new Exception($"{Appsettings.ServerHost} value not set (appsettings)"); options.Port = host.Configuration.GetValue(Appsettings.ServerPort) ?? throw new Exception($"{Appsettings.ServerPort} value not set (appsettings)"); - options.Keepalive = 10000; + options.Buffer = 1024 * 1024; + options.KeepAlive = 10000; options.Timeout = 30000; + options.Parallelism = 0; + options.Compression = Compression.None; options.Encryption = Encryption.Tls12; + options.SslPolicy = SslPolicy.None; - options.UseSerializer, IAgentMessage>(); + //options.InputRateLimit = 1024 * 1024 * 100; + //options.OutputRateLimit = 1024 * 1024 * 100; }); services.AddSingleton, AuthenticationHandler>(); diff --git a/src/Agent/Insight.Agent/Services/EventService.cs b/src/Agent/Insight.Agent/Services/EventService.cs index 95a56e1..2400023 100644 --- a/src/Agent/Insight.Agent/Services/EventService.cs +++ b/src/Agent/Insight.Agent/Services/EventService.cs @@ -15,10 +15,10 @@ namespace Insight.Agent.Services internal class EventService : BackgroundService { private readonly Channel _queue; - private readonly ISessionPool _pool; + private readonly TcpSessionPool _pool; private readonly ILogger _logger; - public EventService(ISessionPool pool, ILogger logger) + public EventService(TcpSessionPool pool, ILogger logger) { _pool = pool; _logger = logger; diff --git a/src/Agent/Insight.Agent/Services/TrapService.cs b/src/Agent/Insight.Agent/Services/TrapService.cs index b386e7f..13051d5 100644 --- a/src/Agent/Insight.Agent/Services/TrapService.cs +++ b/src/Agent/Insight.Agent/Services/TrapService.cs @@ -18,10 +18,10 @@ namespace Insight.Agent.Services private readonly int _port; - private readonly ISessionPool _pool; + private readonly TcpSessionPool _pool; private readonly ILogger _logger; - public TrapService(ISessionPool pool, IConfiguration configuration, ILogger logger) + public TrapService(TcpSessionPool pool, IConfiguration configuration, ILogger logger) { _port = configuration.GetValue(Appsettings.TrapPort) ?? throw new Exception($"{Appsettings.TrapPort} value not set (appsettings)"); _pool = pool; diff --git a/src/Api/Insight.Api/Insight.Api.csproj b/src/Api/Insight.Api/Insight.Api.csproj index 95b64f1..4d54881 100644 --- a/src/Api/Insight.Api/Insight.Api.csproj +++ b/src/Api/Insight.Api/Insight.Api.csproj @@ -4,10 +4,13 @@ net7.0 Insight api - 2023.8.23.1 + 2025.2.24.0 + 2025.2.24.0 Insight.Api enable enable + none + true 4ae1d3bf-869e-4963-8a19-35634507d3b3 false diff --git a/src/Api/Insight.Api/appsettings.Development.json b/src/Api/Insight.Api/appsettings.Development.json index fff92f2..1ccded8 100644 --- a/src/Api/Insight.Api/appsettings.Development.json +++ b/src/Api/Insight.Api/appsettings.Development.json @@ -1,7 +1,7 @@ { "AllowedHosts": "*", "Urls": "http://127.0.0.1:5000", - "database": "mongodb://db.insight.local:27017", + "database": "mongodb://10.22.70.40:32768", "jwt.key": "x5dcaE8fiBmHfgsNrwIEtSWzZkz6gpouzKOIgEiVjxJnW28V1aUnYXF19IcnF5x", "jwt.exp": 3600, "jwt.audience": "http://127.0.0.1:5000", diff --git a/src/Core/Insight.Domain/Insight.Domain.csproj b/src/Core/Insight.Domain/Insight.Domain.csproj index 7386681..d3ad1de 100644 --- a/src/Core/Insight.Domain/Insight.Domain.csproj +++ b/src/Core/Insight.Domain/Insight.Domain.csproj @@ -6,7 +6,10 @@ enable Insight.Domain Insight - 2023.7.3.0 + 2025.2.24.0 + 2025.2.24.0 + none + true diff --git a/src/Core/Insight.Infrastructure/Constants/Monitoring.cs b/src/Core/Insight.Infrastructure/Constants/Monitoring.cs index eb6c355..c8bcf72 100644 --- a/src/Core/Insight.Infrastructure/Constants/Monitoring.cs +++ b/src/Core/Insight.Infrastructure/Constants/Monitoring.cs @@ -2,7 +2,7 @@ { public static class Monitoring { - public static readonly Uri StatusUri = new("https://admin.webmatic.de/monitoring/computer/send/status"); - public static readonly Uri LogUri = new("https://admin.webmatic.de/monitoring/computer/send/log"); + public static readonly Uri StatusUri = new("https://nexus.webmatic.de/rest/monitoring/send/status"); + public static readonly Uri LogUri = new("https://nexus.webmatic.de/rest/monitoring/send/log"); } } \ No newline at end of file diff --git a/src/Core/Insight.Infrastructure/Insight.Infrastructure.csproj b/src/Core/Insight.Infrastructure/Insight.Infrastructure.csproj index d4cec7c..363fd02 100644 --- a/src/Core/Insight.Infrastructure/Insight.Infrastructure.csproj +++ b/src/Core/Insight.Infrastructure/Insight.Infrastructure.csproj @@ -4,9 +4,12 @@ net7.0 Insight.Infrastructure Insight - 2023.7.12.0 + 2025.2.24.0 + 2025.2.24.0 true enable + none + true diff --git a/src/Server/Insight.Server/Insight.Server.csproj b/src/Server/Insight.Server/Insight.Server.csproj index 3fde5e7..8c489df 100644 --- a/src/Server/Insight.Server/Insight.Server.csproj +++ b/src/Server/Insight.Server/Insight.Server.csproj @@ -3,12 +3,16 @@ Exe net7.0 + latest Insight server - 2023.9.14.0 + 2025.2.24.0 + 2025.2.24.0 Insight.Server enable enable + none + true @@ -49,7 +53,7 @@ - + diff --git a/src/Server/Insight.Server/Network/AgentSession.cs b/src/Server/Insight.Server/Network/AgentSession.cs index caa907a..31871b6 100644 --- a/src/Server/Insight.Server/Network/AgentSession.cs +++ b/src/Server/Insight.Server/Network/AgentSession.cs @@ -2,88 +2,79 @@ using Insight.Agent.Messages; using Insight.Server.Network.Handlers.Agent; using Microsoft.Extensions.Logging; +using System.Net.Sockets; using Vaitr.Network; -namespace Insight.Server.Network +namespace Insight.Server.Network; + +public class AgentSession(AgentHandler agentHandler, IEnumerable> handlers, Socket socket, Stream stream, TcpConnectionOptions options, MemPackSerializer serializer, ILogger logger) + : TcpSession(socket, stream, options, serializer, logger) { - public class AgentSession : TcpSession + public string? Id { get; set; } + + private readonly AgentHandler _agentHandler = agentHandler; + private readonly IEnumerable> _handlers = handlers; + + protected override async ValueTask OnConnectedAsync(CancellationToken cancellationToken) { - public string? Id { get; set; } + _logger.LogInformation("Agent ({ep?}) connected", RemoteEndPoint); - private readonly AgentHandler _agentHandler; - private readonly IEnumerable> _handlers; + var request = new AuthenticationRequest(); - public AgentSession(AgentHandler agentHandler, IEnumerable> handlers, ISerializer serializer, ILogger logger) : base(serializer, logger) + foreach (var handler in _handlers) { - _agentHandler = agentHandler; - _handlers = handlers; + await handler.HandleAsync(this, request, cancellationToken); } - protected override async ValueTask OnConnectedAsync(CancellationToken cancellationToken) + await _agentHandler.ConnectedAsync(this, default); + await _agentHandler.StatisticUpdateAsync(this, default); + + _logger.LogInformation("Agent ({ep?}) ID: {id}", RemoteEndPoint, Id); + } + + protected override async ValueTask OnDisconnectedAsync(CancellationToken cancellationToken) + { + _logger.LogInformation("Agent ({ep?}) disconnected", RemoteEndPoint); + + await _agentHandler.StatisticUpdateAsync(this, default); + await _agentHandler.DisconnectedAsync(this, default); + } + + protected override async ValueTask OnSentAsync(PacketContext context, CancellationToken cancellationToken) + { + await _agentHandler.StatisticUpdateAsync(this, cancellationToken); + } + + protected override async ValueTask OnReceivedAsync(PacketContext context, CancellationToken cancellationToken) + { + if (Id is null && context.Data is not Authentication) return; + + await _agentHandler.StatisticUpdateAsync(this, cancellationToken); + + foreach (var handler in _handlers) { - _logger.LogInformation("Agent ({ep?}) connected", RemoteEndPoint); - - var request = new AuthenticationRequest(); - - foreach (var handler in _handlers) + try { - await handler.HandleAsync(this, request, cancellationToken); + await handler.HandleAsync(this, context.Data, cancellationToken); } - - await _agentHandler.ConnectedAsync(this, default); - await _agentHandler.StatisticUpdateAsync(this, default); - - _logger.LogInformation("Agent ({ep?}) ID: {id}", RemoteEndPoint, Id); - } - - protected override async ValueTask OnDisconnectedAsync(CancellationToken cancellationToken) - { - _logger.LogInformation("Agent ({ep?}) disconnected", RemoteEndPoint); - - await _agentHandler.StatisticUpdateAsync(this, default); - await _agentHandler.DisconnectedAsync(this, default); - } - - protected override async ValueTask OnSentAsync(IPacketContext context, CancellationToken cancellationToken) - { - await base.OnSentAsync(context, cancellationToken); - - await _agentHandler.StatisticUpdateAsync(this, cancellationToken); - } - - protected override async ValueTask OnReceivedAsync(IPacketContext context, CancellationToken cancellationToken) - { - await base.OnReceivedAsync(context, cancellationToken); - - if (Id is null && context.Packet is not Authentication) return; - - await _agentHandler.StatisticUpdateAsync(this, cancellationToken); - - foreach (var handler in _handlers) + catch (Exception ex) { - try - { - await handler.HandleAsync(this, context.Packet, cancellationToken); - } - catch (Exception ex) - { - _logger.LogWarning("Agent ({ep?}) {ex}", RemoteEndPoint, ex.ToString()); + _logger.LogWarning("Agent ({ep?}) {ex}", RemoteEndPoint, ex.ToString()); - //await _mediator.Send(new AgentLog(new AgentLogEntity - //{ - // Category = CategoryEnum.Network.ToString(), - // Status = StatusEnum.Error.ToString(), - // Message = e.StackTrace - //}, this), cancellationToken).ConfigureAwait(false); - } + //await _mediator.Send(new AgentLog(new AgentLogEntity + //{ + // Category = CategoryEnum.Network.ToString(), + // Status = StatusEnum.Error.ToString(), + // Message = e.StackTrace + //}, this), cancellationToken).ConfigureAwait(false); } } - - protected override async ValueTask OnHeartbeatAsync(CancellationToken cancellationToken) - { - _logger.LogInformation("Agent ({ep?}) Heartbeat", RemoteEndPoint); - - await _agentHandler.StatisticUpdateAsync(this, cancellationToken); - } + } + + protected override async ValueTask OnKeepAliveAsync(CancellationToken cancellationToken) + { + _logger.LogInformation("Agent ({ep?}) Heartbeat", RemoteEndPoint); + + await _agentHandler.StatisticUpdateAsync(this, cancellationToken); } } \ No newline at end of file diff --git a/src/Server/Insight.Server/Network/Handlers/Agent/AgentHandler.cs b/src/Server/Insight.Server/Network/Handlers/Agent/AgentHandler.cs index c7de5d8..d3f08be 100644 --- a/src/Server/Insight.Server/Network/Handlers/Agent/AgentHandler.cs +++ b/src/Server/Insight.Server/Network/Handlers/Agent/AgentHandler.cs @@ -143,10 +143,10 @@ namespace Insight.Server.Network.Handlers.Agent .Update .Set(p => p.Update, DateTime.Now) .Set(p => p.Activity, session.Activity) - .Set(p => p.SentBytes, session.SentBytes) - .Set(p => p.ReceivedBytes, session.ReceivedBytes) - .Set(p => p.SentPackets, session.SentPackets) - .Set(p => p.ReceivedPackets, session.ReceivedPackets), null, cancellationToken) + .Set(p => p.SentBytes, session.TotalOutputBytes) + .Set(p => p.ReceivedBytes, session.TotalInputBytes) + .Set(p => p.SentPackets, session.TotalOutputPackets) + .Set(p => p.ReceivedPackets, session.TotalInputPackets), null, cancellationToken) .ConfigureAwait(false); } diff --git a/src/Server/Insight.Server/Network/Handlers/Agent/ConsoleHandler.cs b/src/Server/Insight.Server/Network/Handlers/Agent/ConsoleHandler.cs index 23eb2d3..2d9946e 100644 --- a/src/Server/Insight.Server/Network/Handlers/Agent/ConsoleHandler.cs +++ b/src/Server/Insight.Server/Network/Handlers/Agent/ConsoleHandler.cs @@ -9,12 +9,12 @@ namespace Insight.Server.Network.Handlers.Agent { public class ConsoleHandler : IAgentMessageHandler { - private readonly ISessionPool _webPool; + private readonly TcpSessionPool _webPool; private readonly IMongoDatabase _database; private readonly ILogger _logger; public ConsoleHandler( - ISessionPool webPool, + TcpSessionPool webPool, IMongoDatabase database, ILogger logger) { diff --git a/src/Server/Insight.Server/Network/Handlers/Web/ConsoleProxyHandler.cs b/src/Server/Insight.Server/Network/Handlers/Web/ConsoleProxyHandler.cs index 416ee10..e7cc5c9 100644 --- a/src/Server/Insight.Server/Network/Handlers/Web/ConsoleProxyHandler.cs +++ b/src/Server/Insight.Server/Network/Handlers/Web/ConsoleProxyHandler.cs @@ -5,7 +5,7 @@ using Insight.Web.Interfaces; using Insight.Web.Messages; using Microsoft.Extensions.Logging; using MongoDB.Driver; -using Vaitr.Bus; +using Vaitr.MemoryBus; using Vaitr.Network; namespace Insight.Server.Network.Handlers.Web @@ -14,17 +14,17 @@ namespace Insight.Server.Network.Handlers.Web { private readonly List _subscriptions = new(); - private readonly ISessionPool _agentPool; - private readonly ISessionPool _webPool; + private readonly TcpSessionPool _agentPool; + private readonly TcpSessionPool _webPool; private readonly IMongoDatabase _database; - private readonly Bus _bus; + private readonly IMemoryBus _bus; private readonly ILogger _logger; public ConsoleProxyHandler( - ISessionPool agentPool, - ISessionPool webPool, + TcpSessionPool agentPool, + TcpSessionPool webPool, IMongoDatabase database, - Bus bus, + IMemoryBus bus, ILogger logger) { _agentPool = agentPool; diff --git a/src/Server/Insight.Server/Network/WebSession.cs b/src/Server/Insight.Server/Network/WebSession.cs index 8c2e31c..1a949ac 100644 --- a/src/Server/Insight.Server/Network/WebSession.cs +++ b/src/Server/Insight.Server/Network/WebSession.cs @@ -1,45 +1,25 @@ using Insight.Web.Interfaces; using Insight.Web.Messages; using Microsoft.Extensions.Logging; +using System.Net.Sockets; using Vaitr.Network; namespace Insight.Server.Network; -public class WebSession : TcpSession +public class WebSession(IEnumerable> handlers, Socket socket, Stream stream, TcpConnectionOptions options, MemPackSerializer serializer, ILogger logger) + : TcpSession(socket, stream, options, serializer, logger) { public string? Id { get; set; } - private readonly IEnumerable> _handlers; + private readonly IEnumerable> _handlers = handlers; - public WebSession(IEnumerable> handlers, ISerializer serializer, ILogger logger) : base(serializer, logger) + protected override async ValueTask OnReceivedAsync(PacketContext context, CancellationToken cancellationToken) { - _handlers = handlers; - } - - protected override async ValueTask OnConnectedAsync(CancellationToken cancellationToken) - { - _logger.LogInformation("Web ({ep?}) connected", RemoteEndPoint); - } - - protected override async ValueTask OnDisconnectedAsync(CancellationToken cancellationToken) - { - _logger.LogInformation("Web ({ep?}) disconnected", RemoteEndPoint); - } - - protected override async ValueTask OnSentAsync(IPacketContext context, CancellationToken cancellationToken) - { - await base.OnSentAsync(context, cancellationToken); - } - - protected override async ValueTask OnReceivedAsync(IPacketContext context, CancellationToken cancellationToken) - { - await base.OnReceivedAsync(context, cancellationToken); - foreach (var handler in _handlers) { try { - await handler.HandleAsync(this, context.Packet, cancellationToken); + await handler.HandleAsync(this, context.Data, cancellationToken); } catch (Exception ex) { @@ -47,9 +27,4 @@ public class WebSession : TcpSession } } } - - protected override async ValueTask OnHeartbeatAsync(CancellationToken cancellationToken) - { - _logger.LogInformation("Web ({ep?}) Heartbeat", RemoteEndPoint); - } } \ No newline at end of file diff --git a/src/Server/Insight.Server/Program.cs b/src/Server/Insight.Server/Program.cs index 6a0659c..1ee789d 100644 --- a/src/Server/Insight.Server/Program.cs +++ b/src/Server/Insight.Server/Program.cs @@ -14,9 +14,8 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using System.Net; -using Vaitr.Bus; +using Vaitr.MemoryBus.Hosting; using Vaitr.Network; -using Vaitr.Network.Hosting; namespace Insight.Server { @@ -60,19 +59,23 @@ namespace Insight.Server services.AddDatabase(host.Configuration); // AGENT SERVER - services.UseHostedServer(options => + services.UseHostedTcpServer(options => { options.Address = IPAddress.Any; options.Port = host.Configuration.GetValue(Appsettings.AgentServerPort) ?? throw new Exception($"{Appsettings.AgentServerPort} value not set (appsettings)"); - options.Keepalive = 10000; + options.KeepAlive = 10000; options.Timeout = 30000; options.Backlog = 128; - - options.Encryption = Encryption.Tls12; + options.Buffer = 1024 * 1024; + options.Parallelism = 0; options.Certificate = host.Configuration.GetValue(Appsettings.AgentServerCertificate) ?? throw new Exception($"{Appsettings.AgentServerCertificate} value not set (appsettings)"); options.CertificatePassword = host.Configuration.GetValue(Appsettings.AgentServerCertificatePassword) ?? throw new Exception($"{Appsettings.AgentServerCertificatePassword} value not set (appsettings)"); + options.Compression = Compression.None; + options.Encryption = Encryption.Tls12; + options.SslPolicy = SslPolicy.None; - options.UseSerializer, IAgentMessage>(); + //options.InputRateLimit = 1024 * 1024; + //options.OutputRateLimit = 1024 * 1024; }); services.AddSingleton(); @@ -98,19 +101,23 @@ namespace Insight.Server services.AddSingleton, ConsoleHandler>(); // WEB (FRONTEND-PROXY) SERVER - services.UseHostedServer(options => + services.UseHostedTcpServer(options => { options.Address = IPAddress.Any; options.Port = host.Configuration.GetValue(Appsettings.WebServerPort) ?? throw new Exception($"{Appsettings.WebServerPort} value not set (appsettings)"); - options.Keepalive = 10000; + options.KeepAlive = 10000; options.Timeout = 30000; options.Backlog = 128; - - options.Encryption = Encryption.Tls12; + options.Buffer = 1024 * 1024; + options.Parallelism = 0; options.Certificate = host.Configuration.GetValue(Appsettings.WebServerCertificate) ?? throw new Exception($"{Appsettings.WebServerCertificate} value not set (appsettings)"); options.CertificatePassword = host.Configuration.GetValue(Appsettings.WebServerCertificatePassword) ?? throw new Exception($"{Appsettings.WebServerCertificatePassword} value not set (appsettings)"); + options.Compression = Compression.None; + options.Encryption = Encryption.Tls12; + options.SslPolicy = SslPolicy.None; - options.UseSerializer, IWebMessage>(); + //options.InputRateLimit = 1024 * 1024; + //options.OutputRateLimit = 1024 * 1024; }); services.AddSingleton, ConsoleProxyHandler>(); @@ -120,7 +127,7 @@ namespace Insight.Server services.AddHostedService(); // GLOBAL DEPENDENCIES - services.AddSingleton(); + services.AddMemoryBus(); services.AddTransient(provider => new HttpClient(new HttpClientHandler { ClientCertificateOptions = ClientCertificateOption.Manual, diff --git a/src/Server/Insight.Server/Services/JobService.cs b/src/Server/Insight.Server/Services/JobService.cs index 3e800a3..d692ed4 100644 --- a/src/Server/Insight.Server/Services/JobService.cs +++ b/src/Server/Insight.Server/Services/JobService.cs @@ -12,11 +12,11 @@ namespace Insight.Server.Services { internal class JobService : BackgroundService { - private readonly ISessionPool _agentPool; + private readonly TcpSessionPool _agentPool; private readonly IMongoDatabase _database; private readonly ILogger _logger; - public JobService(ISessionPool agentPool, IMongoDatabase database, ILogger logger) + public JobService(TcpSessionPool agentPool, IMongoDatabase database, ILogger logger) { _agentPool = agentPool; _database = database; @@ -27,6 +27,8 @@ namespace Insight.Server.Services { _logger.LogTrace("ExecuteAsync"); + await Task.Delay(TimeSpan.FromMinutes(1), cancellationToken); + var jobs = new List { Task.Run(async () => diff --git a/src/Server/Insight.Server/appsettings.Development.json b/src/Server/Insight.Server/appsettings.Development.json index 74223d4..17abbae 100644 --- a/src/Server/Insight.Server/appsettings.Development.json +++ b/src/Server/Insight.Server/appsettings.Development.json @@ -1,5 +1,5 @@ { - "database": "mongodb://db.insight.local:27017", + "database": "mongodb://10.22.70.40:32768", "agent.server.port": 3002, "agent.server.certificate": "localhost.pfx", "agent.server.certificate.password": "Webmatic12", diff --git a/src/Setup/Insight.Setup.Windows/Insight.Setup.Windows.csproj b/src/Setup/Insight.Setup.Windows/Insight.Setup.Windows.csproj index 92fa03c..907d9aa 100644 --- a/src/Setup/Insight.Setup.Windows/Insight.Setup.Windows.csproj +++ b/src/Setup/Insight.Setup.Windows/Insight.Setup.Windows.csproj @@ -8,7 +8,10 @@ setup Insight.Setup Insight - 2023.7.3.0 + 2025.2.24.0 + 2025.2.24.0 + none + true diff --git a/src/Updater/Insight.Updater/Insight.Updater.csproj b/src/Updater/Insight.Updater/Insight.Updater.csproj index 3e39aee..88c3b73 100644 --- a/src/Updater/Insight.Updater/Insight.Updater.csproj +++ b/src/Updater/Insight.Updater/Insight.Updater.csproj @@ -6,9 +6,12 @@ Insight Insight.Updater updater - 2023.7.3.0 + 2025.2.24.0 + 2025.2.24.0 enable enable + none + true diff --git a/src/Web/Insight.Web.Assets/Insight.Web.Assets.csproj b/src/Web/Insight.Web.Assets/Insight.Web.Assets.csproj index 64f79ee..4fecff5 100644 --- a/src/Web/Insight.Web.Assets/Insight.Web.Assets.csproj +++ b/src/Web/Insight.Web.Assets/Insight.Web.Assets.csproj @@ -7,12 +7,15 @@ Insight.Web.Assets Insight.Web Insight - 2023.9.14.0 + 2025.2.24.0 + 2025.2.24.0 + none + true - + diff --git a/src/Web/Insight.Web/Components/Dialogs/ChatDialog.razor.cs b/src/Web/Insight.Web/Components/Dialogs/ChatDialog.razor.cs index 57a2a86..b05c974 100644 --- a/src/Web/Insight.Web/Components/Dialogs/ChatDialog.razor.cs +++ b/src/Web/Insight.Web/Components/Dialogs/ChatDialog.razor.cs @@ -8,14 +8,14 @@ using Microsoft.AspNetCore.SignalR.Client; using Microsoft.JSInterop; using MongoDB.Driver; using MudBlazor; -using Vaitr.Bus; +using Vaitr.MemoryBus; using static Insight.Web.Constants.Events.Chat; namespace Insight.Web.Components.Dialogs; public partial class ChatDialog { - [Inject] private Bus Bus { get; init; } = default!; + [Inject] private IMemoryBus Bus { get; init; } = default!; [Inject] private ChatService ChatService { get; init; } = default!; [Inject] private SessionPool SessionCache { get; init; } = default!; [Inject] private SessionHandler SessionHandler { get; init; } = default!; diff --git a/src/Web/Insight.Web/Components/Layouts/MainLayout.razor b/src/Web/Insight.Web/Components/Layouts/MainLayout.razor index 672f8c4..fa4a84f 100644 --- a/src/Web/Insight.Web/Components/Layouts/MainLayout.razor +++ b/src/Web/Insight.Web/Components/Layouts/MainLayout.razor @@ -1,9 +1,9 @@ -@using Vaitr.Bus; +@using Vaitr.MemoryBus; @inherits LayoutComponentBase @implements IDisposable -@inject Bus Bus +@inject IMemoryBus Bus diff --git a/src/Web/Insight.Web/Components/Navbars/Customer.razor.cs b/src/Web/Insight.Web/Components/Navbars/Customer.razor.cs index 4dee46e..23cf3ec 100644 --- a/src/Web/Insight.Web/Components/Navbars/Customer.razor.cs +++ b/src/Web/Insight.Web/Components/Navbars/Customer.razor.cs @@ -2,7 +2,7 @@ using Insight.Web.Constants; using Microsoft.AspNetCore.Components; using MongoDB.Driver; -using Vaitr.Bus; +using Vaitr.MemoryBus; namespace Insight.Web.Components.Navbars; @@ -11,7 +11,7 @@ public partial class Customer [CascadingParameter] public IReadOnlyDictionary? RouteValues { get; set; } [Inject] private IMongoDatabase Database { get; set; } = default!; - [Inject] private Bus Bus { get; init; } = default!; + [Inject] private IMemoryBus Bus { get; init; } = default!; private string Title { get; set; } = "Customer"; private string? Id { get; set; } diff --git a/src/Web/Insight.Web/Components/Navbars/Host.razor.cs b/src/Web/Insight.Web/Components/Navbars/Host.razor.cs index de85d62..ef0b21e 100644 --- a/src/Web/Insight.Web/Components/Navbars/Host.razor.cs +++ b/src/Web/Insight.Web/Components/Navbars/Host.razor.cs @@ -3,7 +3,7 @@ using Insight.Infrastructure.Entities; using Insight.Web.Constants; using Microsoft.AspNetCore.Components; using MongoDB.Driver; -using Vaitr.Bus; +using Vaitr.MemoryBus; namespace Insight.Web.Components.Navbars; @@ -12,7 +12,7 @@ public partial class Host : IDisposable [CascadingParameter] public IReadOnlyDictionary? RouteValues { get; set; } [Inject] private IMongoDatabase Database { get; init; } = default!; - [Inject] private Bus Bus { get; init; } = default!; + [Inject] private IMemoryBus Bus { get; init; } = default!; private CustomerEntity? CustomerEntity { get; set; } private HostEntity HostEntity { get; set; } diff --git a/src/Web/Insight.Web/Components/Navbars/Main.razor.cs b/src/Web/Insight.Web/Components/Navbars/Main.razor.cs index f7e3af5..74374ff 100644 --- a/src/Web/Insight.Web/Components/Navbars/Main.razor.cs +++ b/src/Web/Insight.Web/Components/Navbars/Main.razor.cs @@ -1,12 +1,12 @@ using Insight.Web.Constants; using Microsoft.AspNetCore.Components; -using Vaitr.Bus; +using Vaitr.MemoryBus; namespace Insight.Web.Components.Navbars; public partial class Main : IDisposable { - [Inject] private Bus Bus { get; init; } = default!; + [Inject] private IMemoryBus Bus { get; init; } = default!; [Inject] private NavigationManager NavigationManager { get; init; } = default!; private string Uri { get; set; } = string.Empty; diff --git a/src/Web/Insight.Web/Components/Navbars/NavSwitch.razor.cs b/src/Web/Insight.Web/Components/Navbars/NavSwitch.razor.cs index 2af5b32..bbcc4ab 100644 --- a/src/Web/Insight.Web/Components/Navbars/NavSwitch.razor.cs +++ b/src/Web/Insight.Web/Components/Navbars/NavSwitch.razor.cs @@ -1,6 +1,6 @@ using Insight.Web.Constants; using Microsoft.AspNetCore.Components; -using Vaitr.Bus; +using Vaitr.MemoryBus; namespace Insight.Web.Components.Navbars; @@ -9,7 +9,7 @@ public partial class NavSwitch : IDisposable [CascadingParameter] public IReadOnlyDictionary? RouteValues { get; set; } [Inject] private NavigationManager NavigationManager { get; init; } = default!; - [Inject] private Bus Bus { get; init; } = default!; + [Inject] private IMemoryBus Bus { get; init; } = default!; public string Url { get; set; } = string.Empty; private IDisposable? Token { get; set; } diff --git a/src/Web/Insight.Web/Components/Providers/ChatProvider.razor b/src/Web/Insight.Web/Components/Providers/ChatProvider.razor index 0ba0c57..b88218b 100644 --- a/src/Web/Insight.Web/Components/Providers/ChatProvider.razor +++ b/src/Web/Insight.Web/Components/Providers/ChatProvider.razor @@ -1,8 +1,8 @@ @using System.Collections.Concurrent; -@using Vaitr.Bus; +@using Vaitr.MemoryBus; @using static Insight.Web.Constants.Events.Chat; -@inject Bus Bus +@inject IMemoryBus Bus @inject SessionHandler SessionHandler @implements IDisposable diff --git a/src/Web/Insight.Web/Components/Providers/SessionProvider.razor b/src/Web/Insight.Web/Components/Providers/SessionProvider.razor index b5910f5..69357d8 100644 --- a/src/Web/Insight.Web/Components/Providers/SessionProvider.razor +++ b/src/Web/Insight.Web/Components/Providers/SessionProvider.razor @@ -1,7 +1,7 @@ -@using Vaitr.Bus; +@using Vaitr.MemoryBus; @inject SessionHandler SessionHandler -@inject Bus Bus +@inject IMemoryBus Bus @code { protected override async Task OnAfterRenderAsync(bool firstRender) diff --git a/src/Web/Insight.Web/Insight.Web.csproj b/src/Web/Insight.Web/Insight.Web.csproj index a8871a1..19ffdd0 100644 --- a/src/Web/Insight.Web/Insight.Web.csproj +++ b/src/Web/Insight.Web/Insight.Web.csproj @@ -2,14 +2,18 @@ net7.0 + latest Insight web - 2023.9.18.0 + 2025.2.24.0 + 2025.2.24.0 Insight.Web enable enable false false + none + true @@ -30,7 +34,6 @@ - @@ -39,6 +42,7 @@ + diff --git a/src/Web/Insight.Web/Network/Handlers/ConsoleHandler.cs b/src/Web/Insight.Web/Network/Handlers/ConsoleHandler.cs index 6e87b6d..26cb7df 100644 --- a/src/Web/Insight.Web/Network/Handlers/ConsoleHandler.cs +++ b/src/Web/Insight.Web/Network/Handlers/ConsoleHandler.cs @@ -1,14 +1,14 @@ using Insight.Web.Interfaces; using Insight.Web.Messages; -using Vaitr.Bus; +using Vaitr.MemoryBus; namespace Insight.Web.Network.Handlers { public class ConsoleHandler : IWebMessageHandler { - private readonly Bus _bus; + private readonly IMemoryBus _bus; - public ConsoleHandler(Bus bus) + public ConsoleHandler(IMemoryBus bus) { _bus = bus; } diff --git a/src/Web/Insight.Web/Network/WebSession.cs b/src/Web/Insight.Web/Network/WebSession.cs index e3e16d4..a5fa400 100644 --- a/src/Web/Insight.Web/Network/WebSession.cs +++ b/src/Web/Insight.Web/Network/WebSession.cs @@ -1,56 +1,29 @@ using Insight.Web.Interfaces; using Insight.Web.Messages; +using System.Net.Sockets; using Vaitr.Network; -namespace Insight.Web.Network +namespace Insight.Web.Network; + +public class WebSession(IEnumerable> handlers, Socket socket, Stream stream, TcpConnectionOptions options, MemPackSerializer serializer, ILogger logger) + : TcpSession(socket, stream, options, serializer, logger) { - public class WebSession : TcpSession + private readonly IEnumerable> _handlers = handlers; + + protected override async ValueTask OnReceivedAsync(PacketContext context, CancellationToken cancellationToken) { - private readonly IEnumerable> _handlers; + await base.OnReceivedAsync(context, cancellationToken); - public WebSession(IEnumerable> handlers, ISerializer serializer, ILogger logger) : base(serializer, logger) + foreach (var handler in _handlers) { - _handlers = handlers; - } - - protected override ValueTask OnConnectedAsync(CancellationToken cancellationToken) - { - _logger.LogInformation("Web ({ep?}) connected", RemoteEndPoint); - return default; - } - - protected override ValueTask OnDisconnectedAsync(CancellationToken cancellationToken) - { - _logger.LogInformation("Web ({ep?}) disconnected", RemoteEndPoint); - return default; - } - - protected override ValueTask OnSentAsync(IPacketContext context, CancellationToken cancellationToken) - { - return base.OnSentAsync(context, cancellationToken); - } - - protected override async ValueTask OnReceivedAsync(IPacketContext context, CancellationToken cancellationToken) - { - await base.OnReceivedAsync(context, cancellationToken); - - foreach (var handler in _handlers) + try { - try - { - await handler.HandleAsync(this, context.Packet, cancellationToken); - } - catch (Exception ex) - { - _logger.LogWarning("Web ({ep?}) {ex}", RemoteEndPoint, ex.ToString()); - } + await handler.HandleAsync(this, context.Data, cancellationToken); + } + catch (Exception ex) + { + _logger.LogWarning("Web ({ep?}) {ex}", RemoteEndPoint, ex.ToString()); } - } - - protected override ValueTask OnHeartbeatAsync(CancellationToken cancellationToken) - { - _logger.LogInformation("Web ({ep?}) Heartbeat", RemoteEndPoint); - return default; } } } \ No newline at end of file diff --git a/src/Web/Insight.Web/Pages/Management/Hosts/Actions/Console/Index.razor.cs b/src/Web/Insight.Web/Pages/Management/Hosts/Actions/Console/Index.razor.cs index fd6b36d..b5aa129 100644 --- a/src/Web/Insight.Web/Pages/Management/Hosts/Actions/Console/Index.razor.cs +++ b/src/Web/Insight.Web/Pages/Management/Hosts/Actions/Console/Index.razor.cs @@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Components; using MongoDB.Bson; using MongoDB.Driver; using MudBlazor; -using Vaitr.Bus; +using Vaitr.MemoryBus; using Vaitr.Network; namespace Insight.Web.Pages.Management.Hosts.Actions.Console; @@ -17,10 +17,10 @@ public partial class Index { [Parameter] public string? HostId { get; set; } - [Inject] private ISessionPool WebPool { get; init; } = default!; + [Inject] private TcpSessionPool WebPool { get; init; } = default!; [Inject] private IMongoDatabase Database { get; init; } = default!; [Inject] private ISnackbar Snackbar { get; init; } = default!; - [Inject] private Bus Bus { get; init; } = default!; + [Inject] private IMemoryBus Bus { get; init; } = default!; [Inject] private NavigationManager NavigationManager { get; init; } = default!; private string Title { get; set; } = Global.Name; diff --git a/src/Web/Insight.Web/Program.cs b/src/Web/Insight.Web/Program.cs index 4ae318e..4c9c879 100644 --- a/src/Web/Insight.Web/Program.cs +++ b/src/Web/Insight.Web/Program.cs @@ -6,9 +6,9 @@ using Insight.Web.Messages; using Insight.Web.Middleware; using Insight.Web.Network; using Insight.Web.Network.Handlers; -using Vaitr.Bus; +using Vaitr.MemoryBus.Hosting; using Vaitr.Network; -using Vaitr.Network.Hosting; +using static Insight.Web.Constants.Navigation.Management.Hosts.Systems; namespace Insight.Web; @@ -45,7 +45,7 @@ public class Program // IDENTITY builder.Services.AddIdentityServices(builder.Configuration); builder.Services.AddCustomAuthentication(builder.Configuration); - builder.Services.AddSingleton(); + builder.Services.AddMemoryBus(); // SECURITY builder.Services.AddAuthorization(); @@ -60,18 +60,23 @@ public class Program }); // NETWORKING - builder.Services.UseHostedClient(options => - { - options.Host = builder.Configuration.GetValue(Appsettings.ServerHost) ?? throw new Exception($"{Appsettings.ServerHost} value not set (appsettings)"); - options.Port = builder.Configuration.GetValue(Appsettings.ServerPort) ?? throw new Exception($"{Appsettings.ServerPort} value not set (appsettings)"); - options.Keepalive = 10000; - options.Timeout = 30000; - options.Encryption = Encryption.Tls12; + //builder.Services.UseHostedTcpClient(options => + //{ + // options.Host = builder.Configuration.GetValue(Appsettings.ServerHost) ?? throw new Exception($"{Appsettings.ServerHost} value not set (appsettings)"); + // options.Port = builder.Configuration.GetValue(Appsettings.ServerPort) ?? throw new Exception($"{Appsettings.ServerPort} value not set (appsettings)"); + // options.KeepAlive = 10000; + // options.Timeout = 30000; + // options.Buffer = 1024 * 1024; + // options.Parallelism = 0; + // options.Compression = Compression.None; + // options.Encryption = Encryption.Tls12; + // options.SslPolicy = SslPolicy.None; - options.UseSerializer, IWebMessage>(); - }); + // //options.InputRateLimit = 1024 * 1024 * 100; + // //options.OutputRateLimit = 1024 * 1024 * 100; + //}); - builder.Services.AddSingleton, ConsoleHandler>(); + //builder.Services.AddSingleton, ConsoleHandler>(); // WEB:APP var app = builder.Build(); diff --git a/src/Web/Insight.Web/Services/ChatService.cs b/src/Web/Insight.Web/Services/ChatService.cs index 0a77232..dfe2883 100644 --- a/src/Web/Insight.Web/Services/ChatService.cs +++ b/src/Web/Insight.Web/Services/ChatService.cs @@ -3,7 +3,7 @@ using Insight.Web.Models; using MongoDB.Bson; using MongoDB.Driver; using System.Collections.Concurrent; -using Vaitr.Bus; +using Vaitr.MemoryBus; using static Insight.Web.Constants.Events.Chat; namespace Insight.Web.Services; @@ -13,11 +13,11 @@ public class ChatService public readonly ConcurrentDictionary> Users = new(); public readonly ConcurrentDictionary Sessions = new(); - private readonly Bus _bus; + private readonly IMemoryBus _bus; private readonly IMongoDatabase _database; private readonly ILogger _logger; - public ChatService(Bus bus, IMongoDatabase database, ILogger logger) + public ChatService(IMemoryBus bus, IMongoDatabase database, ILogger logger) { _bus = bus; _database = database; diff --git a/src/Web/Insight.Web/Services/SessionPool.cs b/src/Web/Insight.Web/Services/SessionPool.cs index bf4799e..a29a85d 100644 --- a/src/Web/Insight.Web/Services/SessionPool.cs +++ b/src/Web/Insight.Web/Services/SessionPool.cs @@ -1,7 +1,7 @@ using Insight.Web.Constants; using Insight.Web.Models; using System.Collections.Concurrent; -using Vaitr.Bus; +using Vaitr.MemoryBus; namespace Insight.Web.Services; @@ -9,10 +9,10 @@ public class SessionPool { public readonly ConcurrentDictionary Sessions = new(); - private readonly Bus _bus; + private readonly IMemoryBus _bus; private readonly ILogger _logger; - public SessionPool(Bus bus, ILogger logger) + public SessionPool(IMemoryBus bus, ILogger logger) { _bus = bus; _logger = logger; diff --git a/src/Web/Insight.Web/appsettings.Development.json b/src/Web/Insight.Web/appsettings.Development.json index e850623..4360864 100644 --- a/src/Web/Insight.Web/appsettings.Development.json +++ b/src/Web/Insight.Web/appsettings.Development.json @@ -1,7 +1,7 @@ { "AllowedHosts": "*", "Urls": "http://127.0.0.1:5001", - "database": "mongodb://db.insight.local:27017", + "database": "mongodb://10.22.70.40:32768", "database0": "mongodb://insight.webmatic.de:27017", "server.host": "insight.local", "server.port": 3001