Exemplo n.º 1
0
 static void Main(string[] args)
 {
     try
     {
         Console.ForegroundColor = ConsoleColor.Cyan;
         Console.WriteLine(" SYNX SERVER (c) craftersmine 2018");
         Console.ResetColor();
         StaticData.ServerRoot     = Environment.CurrentDirectory;
         StaticData.LogsPath       = Path.Combine(StaticData.ServerRoot, "logs");
         StaticData.LoggerInstance = new Utils.Logger("synx-server");
         Log("info", "Initiating Synx server...");
         ServerEnvironment.InitiateEnvironment(StaticData.ServerRoot);
         ServerConfig.LoadConfig();
         StaticData.UserStorage   = new UserStorage();
         StaticData.CommandParser = new CommandParser();
         CommandRegister.RegisterCommands();
         string serverIp = ServerConfig.GetString("bind-ip");
         if (serverIp != string.Empty && serverIp != null && serverIp != "")
         {
             if (IPAddress.TryParse(serverIp, out IPAddress address))
             {
                 ServerController.CreateServerInstance(address, ServerConfig.GetInt("port"));
             }
             else
             {
                 throw new ArgumentException("The IP address for the binding has an invalid format! Check the server configuration!");
             }
         }
         else
         {
             ServerController.CreateServerInstance(IPAddress.Any, ServerConfig.GetInt("port"));
         }
         ServerController.StartServer();
         while (StaticData.IsServerRunning)
         {
             string inp = Console.ReadLine();
             StaticData.CommandParser.ParseInput(inp);
         }
         Log("info", "Synx server was stopped!");
     }
     catch (Exception ex)
     {
         CrashHandler.HandleException(ex);
     }
 }