static void Main(string[] args)
{
Log = Logger.GetInstance();
Log.Info("Starting up");
TcpServer server = null;
if(UsingTls(args))
{
Log.Info("Using TLS");
X509Certificate2 cert = null;
var foundCert = TryGetX509Certificate(args, out cert);
// We have a certificate, so create the server
if (foundCert)
{
server = new TlsServer(IPAddress.Any, DEFAULT_PORT, cert);
}
}
else
{
Log.Warning("Not using TLS");
//insecure version
server = new TcpServer(IPAddress.Any, DEFAULT_PORT);
}
// If we can't start the server, we can't run anything
if(server == null)
{
Log.Error("Could not start the server");
Environment.Exit(1);
}
// All systems go, start the server
var registry = new Registry();
var MessageArchive = new MessageArchive();
var dispatcher = new Dispatcher(server, registry, MessageArchive);
dispatcher.Run();
}