Compare commits
1 commit
| Author | SHA1 | Date | |
|---|---|---|---|
| f2a6a67165 |
39 changed files with 244 additions and 281 deletions
|
|
@ -7,7 +7,10 @@
|
|||
<AssemblyName>Insight.Agent.Assets</AssemblyName>
|
||||
<RootNamespace>Insight.Agent</RootNamespace>
|
||||
<Product>Insight</Product>
|
||||
<AssemblyVersion>2023.9.14.0</AssemblyVersion>
|
||||
<AssemblyVersion>2025.2.24.0</AssemblyVersion>
|
||||
<FileVersion>2025.2.24.0</FileVersion>
|
||||
<SatelliteResourceLanguages>none</SatelliteResourceLanguages>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
|
@ -19,8 +22,8 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Vaitr.Network" Version="2023.9.13" />
|
||||
<PackageReference Include="Vaitr.Snmp" Version="2023.3.3" />
|
||||
<PackageReference Include="Vaitr.Network.MemoryPack" Version="2025.2.24" />
|
||||
<PackageReference Include="Vaitr.Snmp" Version="2024.5.15" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -3,12 +3,16 @@
|
|||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<RootNamespace>Insight.Agent</RootNamespace>
|
||||
<Product>Insight</Product>
|
||||
<AssemblyName>agent</AssemblyName>
|
||||
<AssemblyVersion>2023.9.14.0</AssemblyVersion>
|
||||
<AssemblyVersion>2025.2.24.0</AssemblyVersion>
|
||||
<FileVersion>2025.2.24.0</FileVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<SatelliteResourceLanguages>none</SatelliteResourceLanguages>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
|
|
|||
|
|
@ -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<IAgentMessageHandler<AgentSession>> handlers, Socket socket, Stream stream, TcpConnectionOptions options, MemPackSerializer serializer, ILogger<AgentSession> logger)
|
||||
: TcpSession<MemPackSerializer, IAgentMessage>(socket, stream, options, serializer, logger)
|
||||
{
|
||||
public class AgentSession : TcpSession<IAgentMessage>
|
||||
private readonly IEnumerable<IAgentMessageHandler<AgentSession>> _handlers = handlers;
|
||||
|
||||
protected override async ValueTask OnReceivedAsync(PacketContext<IAgentMessage> context, CancellationToken cancellationToken)
|
||||
{
|
||||
private readonly IEnumerable<IAgentMessageHandler<AgentSession>> _handlers;
|
||||
await base.OnReceivedAsync(context, cancellationToken);
|
||||
|
||||
public AgentSession(IEnumerable<IAgentMessageHandler<AgentSession>> handlers, ISerializer<IAgentMessage> serializer, ILogger<AgentSession> 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<IAgentMessage> context, CancellationToken cancellationToken)
|
||||
{
|
||||
return base.OnSentAsync(context, cancellationToken);
|
||||
}
|
||||
|
||||
protected override async ValueTask OnReceivedAsync(IPacketContext<IAgentMessage> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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<EventService>();
|
||||
|
||||
// AGENT NETWORKING
|
||||
services.UseHostedClient<AgentSession, IAgentMessage>(options =>
|
||||
services.UseHostedTcpClient<AgentSession, MemPackSerializer, IAgentMessage>(options =>
|
||||
{
|
||||
options.Host = host.Configuration.GetValue<string?>(Appsettings.ServerHost) ?? throw new Exception($"{Appsettings.ServerHost} value not set (appsettings)");
|
||||
options.Port = host.Configuration.GetValue<int?>(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<MemPackSerializer<IAgentMessage>, IAgentMessage>();
|
||||
//options.InputRateLimit = 1024 * 1024 * 100;
|
||||
//options.OutputRateLimit = 1024 * 1024 * 100;
|
||||
});
|
||||
|
||||
services.AddSingleton<IAgentMessageHandler<AgentSession>, AuthenticationHandler>();
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@ namespace Insight.Agent.Services
|
|||
internal class EventService : BackgroundService
|
||||
{
|
||||
private readonly Channel<Event> _queue;
|
||||
private readonly ISessionPool<AgentSession, IAgentMessage> _pool;
|
||||
private readonly TcpSessionPool<AgentSession, MemPackSerializer, IAgentMessage> _pool;
|
||||
private readonly ILogger<EventService> _logger;
|
||||
|
||||
public EventService(ISessionPool<AgentSession, IAgentMessage> pool, ILogger<EventService> logger)
|
||||
public EventService(TcpSessionPool<AgentSession, MemPackSerializer, IAgentMessage> pool, ILogger<EventService> logger)
|
||||
{
|
||||
_pool = pool;
|
||||
_logger = logger;
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@ namespace Insight.Agent.Services
|
|||
|
||||
|
||||
private readonly int _port;
|
||||
private readonly ISessionPool<AgentSession, IAgentMessage> _pool;
|
||||
private readonly TcpSessionPool<AgentSession, MemPackSerializer, IAgentMessage> _pool;
|
||||
private readonly ILogger<TrapService> _logger;
|
||||
|
||||
public TrapService(ISessionPool<AgentSession, IAgentMessage> pool, IConfiguration configuration, ILogger<TrapService> logger)
|
||||
public TrapService(TcpSessionPool<AgentSession, MemPackSerializer, IAgentMessage> pool, IConfiguration configuration, ILogger<TrapService> logger)
|
||||
{
|
||||
_port = configuration.GetValue<int?>(Appsettings.TrapPort) ?? throw new Exception($"{Appsettings.TrapPort} value not set (appsettings)");
|
||||
_pool = pool;
|
||||
|
|
|
|||
|
|
@ -4,10 +4,13 @@
|
|||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Product>Insight</Product>
|
||||
<AssemblyName>api</AssemblyName>
|
||||
<AssemblyVersion>2023.8.23.1</AssemblyVersion>
|
||||
<AssemblyVersion>2025.2.24.0</AssemblyVersion>
|
||||
<FileVersion>2025.2.24.0</FileVersion>
|
||||
<RootNamespace>Insight.Api</RootNamespace>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<SatelliteResourceLanguages>none</SatelliteResourceLanguages>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
<UserSecretsId>4ae1d3bf-869e-4963-8a19-35634507d3b3</UserSecretsId>
|
||||
|
||||
<PublishAot>false</PublishAot>
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -6,7 +6,10 @@
|
|||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>Insight.Domain</RootNamespace>
|
||||
<Product>Insight</Product>
|
||||
<AssemblyVersion>2023.7.3.0</AssemblyVersion>
|
||||
<AssemblyVersion>2025.2.24.0</AssemblyVersion>
|
||||
<FileVersion>2025.2.24.0</FileVersion>
|
||||
<SatelliteResourceLanguages>none</SatelliteResourceLanguages>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
@ -4,9 +4,12 @@
|
|||
<TargetFramework>net7.0</TargetFramework>
|
||||
<RootNamespace>Insight.Infrastructure</RootNamespace>
|
||||
<Product>Insight</Product>
|
||||
<AssemblyVersion>2023.7.12.0</AssemblyVersion>
|
||||
<AssemblyVersion>2025.2.24.0</AssemblyVersion>
|
||||
<FileVersion>2025.2.24.0</FileVersion>
|
||||
<ImplicitUsings>true</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<SatelliteResourceLanguages>none</SatelliteResourceLanguages>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
|
|
|||
|
|
@ -3,12 +3,16 @@
|
|||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Product>Insight</Product>
|
||||
<AssemblyName>server</AssemblyName>
|
||||
<AssemblyVersion>2023.9.14.0</AssemblyVersion>
|
||||
<AssemblyVersion>2025.2.24.0</AssemblyVersion>
|
||||
<FileVersion>2025.2.24.0</FileVersion>
|
||||
<RootNamespace>Insight.Server</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<SatelliteResourceLanguages>none</SatelliteResourceLanguages>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
|
@ -49,7 +53,7 @@
|
|||
<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" />
|
||||
<PackageReference Include="Vaitr.Bus" Version="0.1.3" />
|
||||
<PackageReference Include="Vaitr.MemoryBus" Version="2024.5.15" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -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<IAgentMessageHandler<AgentSession>> handlers, Socket socket, Stream stream, TcpConnectionOptions options, MemPackSerializer serializer, ILogger<AgentSession> logger)
|
||||
: TcpSession<MemPackSerializer, IAgentMessage>(socket, stream, options, serializer, logger)
|
||||
{
|
||||
public class AgentSession : TcpSession<IAgentMessage>
|
||||
public string? Id { get; set; }
|
||||
|
||||
private readonly AgentHandler _agentHandler = agentHandler;
|
||||
private readonly IEnumerable<IAgentMessageHandler<AgentSession>> _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<IAgentMessageHandler<AgentSession>> _handlers;
|
||||
var request = new AuthenticationRequest();
|
||||
|
||||
public AgentSession(AgentHandler agentHandler, IEnumerable<IAgentMessageHandler<AgentSession>> handlers, ISerializer<IAgentMessage> serializer, ILogger<AgentSession> 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<IAgentMessage> context, CancellationToken cancellationToken)
|
||||
{
|
||||
await _agentHandler.StatisticUpdateAsync(this, cancellationToken);
|
||||
}
|
||||
|
||||
protected override async ValueTask OnReceivedAsync(PacketContext<IAgentMessage> 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<IAgentMessage> context, CancellationToken cancellationToken)
|
||||
{
|
||||
await base.OnSentAsync(context, cancellationToken);
|
||||
|
||||
await _agentHandler.StatisticUpdateAsync(this, cancellationToken);
|
||||
}
|
||||
|
||||
protected override async ValueTask OnReceivedAsync(IPacketContext<IAgentMessage> 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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ namespace Insight.Server.Network.Handlers.Agent
|
|||
{
|
||||
public class ConsoleHandler : IAgentMessageHandler<AgentSession>
|
||||
{
|
||||
private readonly ISessionPool<WebSession, IWebMessage> _webPool;
|
||||
private readonly TcpSessionPool<WebSession, MemPackSerializer, IWebMessage> _webPool;
|
||||
private readonly IMongoDatabase _database;
|
||||
private readonly ILogger<ConsoleHandler> _logger;
|
||||
|
||||
public ConsoleHandler(
|
||||
ISessionPool<WebSession, IWebMessage> webPool,
|
||||
TcpSessionPool<WebSession, MemPackSerializer, IWebMessage> webPool,
|
||||
IMongoDatabase database,
|
||||
ILogger<ConsoleHandler> logger)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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<IDisposable> _subscriptions = new();
|
||||
|
||||
private readonly ISessionPool<AgentSession, IAgentMessage> _agentPool;
|
||||
private readonly ISessionPool<WebSession, IWebMessage> _webPool;
|
||||
private readonly TcpSessionPool<AgentSession, MemPackSerializer, IAgentMessage> _agentPool;
|
||||
private readonly TcpSessionPool<WebSession, MemPackSerializer, IWebMessage> _webPool;
|
||||
private readonly IMongoDatabase _database;
|
||||
private readonly Bus _bus;
|
||||
private readonly IMemoryBus _bus;
|
||||
private readonly ILogger<ConsoleProxyHandler> _logger;
|
||||
|
||||
public ConsoleProxyHandler(
|
||||
ISessionPool<AgentSession, IAgentMessage> agentPool,
|
||||
ISessionPool<WebSession, IWebMessage> webPool,
|
||||
TcpSessionPool<AgentSession, MemPackSerializer, IAgentMessage> agentPool,
|
||||
TcpSessionPool<WebSession, MemPackSerializer, IWebMessage> webPool,
|
||||
IMongoDatabase database,
|
||||
Bus bus,
|
||||
IMemoryBus bus,
|
||||
ILogger<ConsoleProxyHandler> logger)
|
||||
{
|
||||
_agentPool = agentPool;
|
||||
|
|
|
|||
|
|
@ -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<IWebMessage>
|
||||
public class WebSession(IEnumerable<IWebMessageHandler<WebSession>> handlers, Socket socket, Stream stream, TcpConnectionOptions options, MemPackSerializer serializer, ILogger<WebSession> logger)
|
||||
: TcpSession<MemPackSerializer, IWebMessage>(socket, stream, options, serializer, logger)
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
|
||||
private readonly IEnumerable<IWebMessageHandler<WebSession>> _handlers;
|
||||
private readonly IEnumerable<IWebMessageHandler<WebSession>> _handlers = handlers;
|
||||
|
||||
public WebSession(IEnumerable<IWebMessageHandler<WebSession>> handlers, ISerializer<IWebMessage> serializer, ILogger<WebSession> logger) : base(serializer, logger)
|
||||
protected override async ValueTask OnReceivedAsync(PacketContext<IWebMessage> 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<IWebMessage> context, CancellationToken cancellationToken)
|
||||
{
|
||||
await base.OnSentAsync(context, cancellationToken);
|
||||
}
|
||||
|
||||
protected override async ValueTask OnReceivedAsync(IPacketContext<IWebMessage> 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<IWebMessage>
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override async ValueTask OnHeartbeatAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
_logger.LogInformation("Web ({ep?}) Heartbeat", RemoteEndPoint);
|
||||
}
|
||||
}
|
||||
|
|
@ -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<AgentSession, IAgentMessage>(options =>
|
||||
services.UseHostedTcpServer<AgentSession, MemPackSerializer, IAgentMessage>(options =>
|
||||
{
|
||||
options.Address = IPAddress.Any;
|
||||
options.Port = host.Configuration.GetValue<int?>(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<string?>(Appsettings.AgentServerCertificate) ?? throw new Exception($"{Appsettings.AgentServerCertificate} value not set (appsettings)");
|
||||
options.CertificatePassword = host.Configuration.GetValue<string?>(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<MemPackSerializer<IAgentMessage>, IAgentMessage>();
|
||||
//options.InputRateLimit = 1024 * 1024;
|
||||
//options.OutputRateLimit = 1024 * 1024;
|
||||
});
|
||||
|
||||
services.AddSingleton<AgentHandler>();
|
||||
|
|
@ -98,19 +101,23 @@ namespace Insight.Server
|
|||
services.AddSingleton<IAgentMessageHandler<AgentSession>, ConsoleHandler>();
|
||||
|
||||
// WEB (FRONTEND-PROXY) SERVER
|
||||
services.UseHostedServer<WebSession, IWebMessage>(options =>
|
||||
services.UseHostedTcpServer<WebSession, MemPackSerializer, IWebMessage>(options =>
|
||||
{
|
||||
options.Address = IPAddress.Any;
|
||||
options.Port = host.Configuration.GetValue<int?>(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<string?>(Appsettings.WebServerCertificate) ?? throw new Exception($"{Appsettings.WebServerCertificate} value not set (appsettings)");
|
||||
options.CertificatePassword = host.Configuration.GetValue<string?>(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<MemPackSerializer<IWebMessage>, IWebMessage>();
|
||||
//options.InputRateLimit = 1024 * 1024;
|
||||
//options.OutputRateLimit = 1024 * 1024;
|
||||
});
|
||||
|
||||
services.AddSingleton<IWebMessageHandler<WebSession>, ConsoleProxyHandler>();
|
||||
|
|
@ -120,7 +127,7 @@ namespace Insight.Server
|
|||
services.AddHostedService<DispatchService>();
|
||||
|
||||
// GLOBAL DEPENDENCIES
|
||||
services.AddSingleton<Bus>();
|
||||
services.AddMemoryBus();
|
||||
services.AddTransient(provider => new HttpClient(new HttpClientHandler
|
||||
{
|
||||
ClientCertificateOptions = ClientCertificateOption.Manual,
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@ namespace Insight.Server.Services
|
|||
{
|
||||
internal class JobService : BackgroundService
|
||||
{
|
||||
private readonly ISessionPool<AgentSession, IAgentMessage> _agentPool;
|
||||
private readonly TcpSessionPool<AgentSession, MemPackSerializer, IAgentMessage> _agentPool;
|
||||
private readonly IMongoDatabase _database;
|
||||
private readonly ILogger<JobService> _logger;
|
||||
|
||||
public JobService(ISessionPool<AgentSession, IAgentMessage> agentPool, IMongoDatabase database, ILogger<JobService> logger)
|
||||
public JobService(TcpSessionPool<AgentSession, MemPackSerializer, IAgentMessage> agentPool, IMongoDatabase database, ILogger<JobService> 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>
|
||||
{
|
||||
Task.Run(async () =>
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -8,7 +8,10 @@
|
|||
<AssemblyName>setup</AssemblyName>
|
||||
<RootNamespace>Insight.Setup</RootNamespace>
|
||||
<Product>Insight</Product>
|
||||
<AssemblyVersion>2023.7.3.0</AssemblyVersion>
|
||||
<AssemblyVersion>2025.2.24.0</AssemblyVersion>
|
||||
<FileVersion>2025.2.24.0</FileVersion>
|
||||
<SatelliteResourceLanguages>none</SatelliteResourceLanguages>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
|
|
|||
|
|
@ -6,9 +6,12 @@
|
|||
<Product>Insight</Product>
|
||||
<RootNamespace>Insight.Updater</RootNamespace>
|
||||
<AssemblyName>updater</AssemblyName>
|
||||
<AssemblyVersion>2023.7.3.0</AssemblyVersion>
|
||||
<AssemblyVersion>2025.2.24.0</AssemblyVersion>
|
||||
<FileVersion>2025.2.24.0</FileVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<SatelliteResourceLanguages>none</SatelliteResourceLanguages>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
|
|
|||
|
|
@ -7,12 +7,15 @@
|
|||
<AssemblyName>Insight.Web.Assets</AssemblyName>
|
||||
<RootNamespace>Insight.Web</RootNamespace>
|
||||
<Product>Insight</Product>
|
||||
<AssemblyVersion>2023.9.14.0</AssemblyVersion>
|
||||
<AssemblyVersion>2025.2.24.0</AssemblyVersion>
|
||||
<FileVersion>2025.2.24.0</FileVersion>
|
||||
<SatelliteResourceLanguages>none</SatelliteResourceLanguages>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MongoDB.Bson" Version="2.21.0" />
|
||||
<PackageReference Include="Vaitr.Network" Version="2023.9.13" />
|
||||
<PackageReference Include="Vaitr.Network.MemoryPack" Version="2025.2.24" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -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!;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
@using Vaitr.Bus;
|
||||
@using Vaitr.MemoryBus;
|
||||
|
||||
@inherits LayoutComponentBase
|
||||
@implements IDisposable
|
||||
|
||||
@inject Bus Bus
|
||||
@inject IMemoryBus Bus
|
||||
|
||||
<MudSnackbarProvider />
|
||||
<MudDialogProvider />
|
||||
|
|
|
|||
|
|
@ -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<string, object>? 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; }
|
||||
|
|
|
|||
|
|
@ -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<string, object>? 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; }
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<string, object>? 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; }
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -2,14 +2,18 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Product>Insight</Product>
|
||||
<AssemblyName>web</AssemblyName>
|
||||
<AssemblyVersion>2023.9.18.0</AssemblyVersion>
|
||||
<AssemblyVersion>2025.2.24.0</AssemblyVersion>
|
||||
<FileVersion>2025.2.24.0</FileVersion>
|
||||
<RootNamespace>Insight.Web</RootNamespace>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<PublishAot>false</PublishAot>
|
||||
<PublishTrimmed>false</PublishTrimmed>
|
||||
<SatelliteResourceLanguages>none</SatelliteResourceLanguages>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
<!--<ServerGarbageCollection>false</ServerGarbageCollection>
|
||||
<ConcurrentGarbageCollection>false</ConcurrentGarbageCollection>-->
|
||||
</PropertyGroup>
|
||||
|
|
@ -30,7 +34,6 @@
|
|||
<PackageReference Include="Blazored.SessionStorage" Version="2.4.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="7.0.11" />
|
||||
<PackageReference Include="MudBlazor" Version="6.10.0" />
|
||||
<PackageReference Include="Vaitr.Bus" Version="0.1.3" />
|
||||
<!--Unix Serilog stuff-->
|
||||
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
|
||||
<PackageReference Include="System.Text.Encoding.Extensions" Version="4.3.0" />
|
||||
|
|
@ -39,6 +42,7 @@
|
|||
<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" />
|
||||
<PackageReference Include="Vaitr.MemoryBus" Version="2024.5.15" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -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<WebSession>
|
||||
{
|
||||
private readonly Bus _bus;
|
||||
private readonly IMemoryBus _bus;
|
||||
|
||||
public ConsoleHandler(Bus bus)
|
||||
public ConsoleHandler(IMemoryBus bus)
|
||||
{
|
||||
_bus = bus;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<IWebMessageHandler<WebSession>> handlers, Socket socket, Stream stream, TcpConnectionOptions options, MemPackSerializer serializer, ILogger<WebSession> logger)
|
||||
: TcpSession<MemPackSerializer, IWebMessage>(socket, stream, options, serializer, logger)
|
||||
{
|
||||
public class WebSession : TcpSession<IWebMessage>
|
||||
private readonly IEnumerable<IWebMessageHandler<WebSession>> _handlers = handlers;
|
||||
|
||||
protected override async ValueTask OnReceivedAsync(PacketContext<IWebMessage> context, CancellationToken cancellationToken)
|
||||
{
|
||||
private readonly IEnumerable<IWebMessageHandler<WebSession>> _handlers;
|
||||
await base.OnReceivedAsync(context, cancellationToken);
|
||||
|
||||
public WebSession(IEnumerable<IWebMessageHandler<WebSession>> handlers, ISerializer<IWebMessage> serializer, ILogger<WebSession> 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<IWebMessage> context, CancellationToken cancellationToken)
|
||||
{
|
||||
return base.OnSentAsync(context, cancellationToken);
|
||||
}
|
||||
|
||||
protected override async ValueTask OnReceivedAsync(IPacketContext<IWebMessage> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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<WebSession, IWebMessage> WebPool { get; init; } = default!;
|
||||
[Inject] private TcpSessionPool<WebSession, MemPackSerializer, IWebMessage> 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;
|
||||
|
|
|
|||
|
|
@ -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<Bus>();
|
||||
builder.Services.AddMemoryBus();
|
||||
|
||||
// SECURITY
|
||||
builder.Services.AddAuthorization();
|
||||
|
|
@ -60,18 +60,23 @@ public class Program
|
|||
});
|
||||
|
||||
// NETWORKING
|
||||
builder.Services.UseHostedClient<WebSession, IWebMessage>(options =>
|
||||
{
|
||||
options.Host = builder.Configuration.GetValue<string?>(Appsettings.ServerHost) ?? throw new Exception($"{Appsettings.ServerHost} value not set (appsettings)");
|
||||
options.Port = builder.Configuration.GetValue<int?>(Appsettings.ServerPort) ?? throw new Exception($"{Appsettings.ServerPort} value not set (appsettings)");
|
||||
options.Keepalive = 10000;
|
||||
options.Timeout = 30000;
|
||||
options.Encryption = Encryption.Tls12;
|
||||
//builder.Services.UseHostedTcpClient<WebSession, MemPackSerializer, IWebMessage>(options =>
|
||||
//{
|
||||
// options.Host = builder.Configuration.GetValue<string?>(Appsettings.ServerHost) ?? throw new Exception($"{Appsettings.ServerHost} value not set (appsettings)");
|
||||
// options.Port = builder.Configuration.GetValue<int?>(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<MemPackSerializer<IWebMessage>, IWebMessage>();
|
||||
});
|
||||
// //options.InputRateLimit = 1024 * 1024 * 100;
|
||||
// //options.OutputRateLimit = 1024 * 1024 * 100;
|
||||
//});
|
||||
|
||||
builder.Services.AddSingleton<IWebMessageHandler<WebSession>, ConsoleHandler>();
|
||||
//builder.Services.AddSingleton<IWebMessageHandler<WebSession>, ConsoleHandler>();
|
||||
|
||||
// WEB:APP
|
||||
var app = builder.Build();
|
||||
|
|
|
|||
|
|
@ -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<ChatUser, List<string>> Users = new();
|
||||
public readonly ConcurrentDictionary<ObjectId, ChatSession> Sessions = new();
|
||||
|
||||
private readonly Bus _bus;
|
||||
private readonly IMemoryBus _bus;
|
||||
private readonly IMongoDatabase _database;
|
||||
private readonly ILogger<ChatService> _logger;
|
||||
|
||||
public ChatService(Bus bus, IMongoDatabase database, ILogger<ChatService> logger)
|
||||
public ChatService(IMemoryBus bus, IMongoDatabase database, ILogger<ChatService> logger)
|
||||
{
|
||||
_bus = bus;
|
||||
_database = database;
|
||||
|
|
|
|||
|
|
@ -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<string, SessionState> Sessions = new();
|
||||
|
||||
private readonly Bus _bus;
|
||||
private readonly IMemoryBus _bus;
|
||||
private readonly ILogger<SessionPool> _logger;
|
||||
|
||||
public SessionPool(Bus bus, ILogger<SessionPool> logger)
|
||||
public SessionPool(IMemoryBus bus, ILogger<SessionPool> logger)
|
||||
{
|
||||
_bus = bus;
|
||||
_logger = logger;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue