Example #1
0
        public static void Main(string[] args)
        {
            Config = new Config();

            ConsoleSystem = new ConsoleSystem { Thread = new Thread(ConsoleSystem.StartThread) };
            ConsoleSystem.Thread.Start();

            // Setup function exit handlers to guarentee Exit() is run before closing
            Console.CancelKeyPress += Exit;
            AppDomain.CurrentDomain.ProcessExit += Exit;

            try
            {
                for (var i = 0; i < args.Length; i++)
                {
                    switch (args[i].ToLower())
                    {
                        case "-b":
                        case "--bind-address":
                            if (++i < args.Length)
                                BindAddress = IPAddress.Parse(args[i]);
                            break;

                        case "-s":
                        case "--size":
                            var splitArgs = args[++i].Split(',');
                            var width = int.Parse(splitArgs[0]);
                            var height = int.Parse(splitArgs[1]);
                            if (width < ConsoleSystem.Width)
                            {
                                Logger.WriteWarning("[ARG] Capping console width to {0} columns", ConsoleSystem.Width);
                                width = ConsoleSystem.Width;
                            }
                            if (height < ConsoleSystem.Height)
                            {
                                Logger.WriteWarning("[ARG] Capping console height to {0} rows", ConsoleSystem.Height);
                                height = ConsoleSystem.Height;
                            }
                            ConsoleSystem.SetSize(width, height);
                            break;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteException("An error has occurred while parsing command line parameters", ex);
            }

            // Check for settings.txt [AIDA]
            if (!File.Exists("Resources/settings.txt"))
            {
                // If it doesn't exist, throw an error and quit [AIDA]
                Logger.WriteError("[ERR] Failed to load settings.txt. Press any key to quit.");
                Console.ReadKey();
                Environment.Exit(0);
            }

            // Check for Private Key BLOB [AIDA]
            if (!File.Exists("privateKey.blob"))
            {
                // If it doesn't exist, generate a fresh keypair [CK]
                Logger.WriteWarning("[WRN] No privatekey.blob installed, generating new keypair...");
                RSACryptoServiceProvider rcsp = new RSACryptoServiceProvider();
                byte[] cspBlob = rcsp.ExportCspBlob(true);
                byte[] cspBlobPub = rcsp.ExportCspBlob(false);
                FileStream outFile = File.Create("privateKey.blob");
                FileStream outFilePub = File.Create("publicKey.blob");
                outFile.Write(cspBlob, 0, cspBlob.Length);
                outFile.Close();
                outFilePub.Write(cspBlobPub, 0, cspBlobPub.Length);
                outFilePub.Close();
            }

            // Fix up startup message [KeyPhact]
            Logger.WriteHeader();
            Logger.Write(PolarisName + " - " + PolarisVersion + " (" + PolarisVersionName + ")");
            Logger.Write("By " + PolarisAuthor);
            Logger.Write(PolarisLicense);

            Thread.Sleep(1000);
            //System.Data.Entity.Database.SetInitializer(new DropCreateDatabaseIfModelChanges<PolarisEF>());
            Instance = new PolarisApp();
            Instance.Start();
        }
Example #2
0
        public static void Main(string[] args)
        {
            Config = new Config();

            ConsoleSystem        = new ConsoleSystem();
            ConsoleSystem.thread = new Thread(new ThreadStart(ConsoleSystem.StartThread));
            ConsoleSystem.thread.Start();

            // Setup function exit handlers to guarentee Exit() is run before closing
            Console.CancelKeyPress += Exit;
            AppDomain.CurrentDomain.ProcessExit += Exit;

            try
            {
                for (int i = 0; i < args.Length; i++)
                {
                    switch (args[i].ToLower())
                    {
                    default:
                        break;

                    case "-b":
                    case "--bind-address":
                        if (++i < args.Length)
                        {
                            BindAddress = IPAddress.Parse(args[i]);
                        }
                        break;

                    case "-s":
                    case "--size":
                        string[] splitArgs = args[++i].Split(',');
                        int      width     = int.Parse(splitArgs[0]);
                        int      height    = int.Parse(splitArgs[1]);
                        if (width < ConsoleSystem.width)
                        {
                            Logger.WriteWarning("[ARG] Capping console width to {0} columns", ConsoleSystem.width);
                            width = ConsoleSystem.width;
                        }
                        if (height < ConsoleSystem.height)
                        {
                            Logger.WriteWarning("[ARG] Capping console height to {0} rows", ConsoleSystem.height);
                            height = ConsoleSystem.height;
                        }
                        ConsoleSystem.width  = width;
                        ConsoleSystem.height = height;
                        Console.SetWindowSize(ConsoleSystem.width, ConsoleSystem.height);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteException("An error has occurred while parsing command line parameters", ex);
            }

            // Check for settings.txt [AIDA]
            if (!File.Exists("Resources/settings.txt"))
            {
                // If it doesn't exist, throw an error and quit [AIDA]
                Logger.WriteError("[ERR] Failed to load settings.txt. Press any key to quit.");
                Console.ReadKey();
                Environment.Exit(0);
            }

            // Check for Private Key BLOB [AIDA]
            if (!File.Exists("privateKey.blob"))
            {
                // If it doesn't exist, throw an error and quit [AIDA]
                Logger.WriteError("[ERR] Failed to load privateKey.blob. Press any key to quit.");
                Console.ReadKey();
                Environment.Exit(0);
            }

            // Fix up startup message [KeyPhact]
            Logger.Write(POLARIS_NAME + " - " + POLARIS_VERSION + " (" + POLARIS_VERSION_NAME + ")");
            Logger.Write("By " + POLARIS_AUTHOR);
            Logger.Write(POLARIS_LICENSE);

            Thread.Sleep(1000);
            //System.Data.Entity.Database.SetInitializer(new DropCreateDatabaseIfModelChanges<PolarisEF>());
            instance = new PolarisApp();
            instance.Start();
        }
Example #3
0
        public static void Main(string[] args)
        {
            Config = new Config();

            ConsoleSystem = new ConsoleSystem {
                Thread = new Thread(ConsoleSystem.StartThread)
            };
            ConsoleSystem.Thread.Start();

            // Setup function exit handlers to guarentee Exit() is run before closing
            Console.CancelKeyPress += Exit;
            AppDomain.CurrentDomain.ProcessExit += Exit;

            try
            {
                for (var i = 0; i < args.Length; i++)
                {
                    switch (args[i].ToLower())
                    {
                    case "-b":
                    case "--bind-address":
                        if (++i < args.Length)
                        {
                            BindAddress = IPAddress.Parse(args[i]);
                        }
                        break;

                    case "-s":
                    case "--size":
                        var splitArgs = args[++i].Split(',');
                        var width     = int.Parse(splitArgs[0]);
                        var height    = int.Parse(splitArgs[1]);
                        if (width < ConsoleSystem.Width)
                        {
                            Logger.WriteWarning("[ARG] Capping console width to {0} columns", ConsoleSystem.Width);
                            width = ConsoleSystem.Width;
                        }
                        if (height < ConsoleSystem.Height)
                        {
                            Logger.WriteWarning("[ARG] Capping console height to {0} rows", ConsoleSystem.Height);
                            height = ConsoleSystem.Height;
                        }
                        ConsoleSystem.SetSize(width, height);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteException("An error has occurred while parsing command line parameters", ex);
            }

            // Check for settings.txt [AIDA]
            if (!File.Exists("Resources/settings.txt"))
            {
                // If it doesn't exist, throw an error and quit [AIDA]
                Logger.WriteError("[ERR] Failed to load settings.txt. Press any key to quit.");
                Console.ReadKey();
                Environment.Exit(0);
            }

            // Check for Private Key BLOB [AIDA]
            if (!File.Exists("privateKey.blob"))
            {
                // If it doesn't exist, generate a fresh keypair [CK]
                Logger.WriteWarning("[WRN] No privatekey.blob installed, generating new keypair...");

                RSACryptoServiceProvider rcsp = new RSACryptoServiceProvider();
                byte[] cspBlob    = rcsp.ExportCspBlob(true);
                byte[] cspBlobPub = rcsp.ExportCspBlob(false);

                FileStream outFile = File.Create("privateKey.blob");
                outFile.Write(cspBlob, 0, cspBlob.Length);
                outFile.Close();

                FileStream outFilePub = File.Create("publicKey.blob");
                outFilePub.Write(cspBlobPub, 0, cspBlobPub.Length);
                outFilePub.Close();
            }

            // Fix up startup message [KeyPhact]
            Logger.WriteHeader();
            Logger.Write(PolarisName + " - " + PolarisVersion + " (" + PolarisVersionName + ")");
            Logger.Write("By " + PolarisAuthor);
            Logger.Write(PolarisLicense);

            Thread.Sleep(1000);
            //System.Data.Entity.Database.SetInitializer(new DropCreateDatabaseIfModelChanges<PolarisEF>());
            Instance = new PolarisApp();
            Instance.Start();
        }