Meum/Meum.Server/Program.cs
2025-05-08 21:48:57 +05:00

56 lines
1.6 KiB
C#

global using System;
global using System.Collections.Generic;
global using System.Threading;
global using System.Threading.Tasks;
global using Meum.Core;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Quic;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using DTLib.Console;
using DTLib.Demystifier;
using DTLib.Extensions;
using DTLib.Filesystem;
using DTLib.Logging;
namespace Meum.Server;
static class Program
{
static readonly IOPath config_path = "Meum.Server.config.json";
static async Task Main(string[] args)
{
try
{
if (!QuicConnection.IsSupported)
throw new Exception("Quic is not supported, check for presence of libmsquic and openssl");
var config = ServerConfig.LoadOrCreate(config_path);
var logger = new ConsoleLogger();
var server = new Server(config, logger);
await server.ListenAsync();
while (true)
{
try
{
var conn = await server.AcceptConnectionAsync();
}
catch (Exception ex)
{
logger.LogError("Main", ex.ToStringDemystified());
}
}
}
catch (Exception ex)
{
ColoredConsole.WriteLine(ex.ToStringDemystified(), ConsoleColor.Red);
}
finally
{
Console.ResetColor();
}
}
}