Example #1
0
        public void Save()
        {
            var saveJSON = new CJSON();

            saveJSON.PortDef        = PortDef;
            saveJSON.PortPasv       = PortPasv;
            saveJSON.Hostname       = Hostname;
            saveJSON.Token          = Token;
            saveJSON.Banner         = Banner;
            saveJSON.Report         = Report;
            saveJSON.Ban            = Ban;
            saveJSON.PunishScans    = PunishScans;
            saveJSON.AllowAnonymous = AllowAnonymous;
            saveJSON.PerIPLogs      = PerIPLogs;
            saveJSON.AnonStat       = AnonStat;
            saveJSON.ConsoleLogging = ConsoleLogging;
            saveJSON.ActiveMode     = ActiveMode;
            saveJSON.Max_PerSecond  = Max_PerSecond;
            saveJSON.Max_Total      = Max_Total;
            saveJSON.BanLength      = BanLength;
            saveJSON.MaxErrors      = MaxErrors;
            saveJSON.BufferSize     = BufferSize;
            saveJSON.MaxThreads     = MaxThreads;
            saveJSON.Files          = files;
            string saveString = JsonConvert.SerializeObject(saveJSON);

            System.IO.File.WriteAllText(filename, saveString);
        }
Example #2
0
        public Config(string name)
        {
            CJSON  json        = null;
            string Placeholder = Properties.Resources.ConfigFile;

            try
            {
                if (System.IO.File.Exists(name))
                {
                    string config = System.IO.File.ReadAllText(name);
                    json = JsonConvert.DeserializeObject <CJSON>(config);
                }
                else
                {
                    json = JsonConvert.DeserializeObject <CJSON>(Placeholder);
                    System.IO.File.WriteAllText(name, Placeholder);
                }
                PortDef        = json.PortDef;
                PortPasv       = json.PortPasv;
                Hostname       = json.Hostname;
                Token          = json.Token;
                Banner         = json.Banner; //DID YOU KNOW?: Use %host% for it to be replaced with your current hostname!
                Report         = json.Report;
                Ban            = json.Ban;
                PunishScans    = json.PunishScans;
                AllowAnonymous = json.AllowAnonymous;
                Max_PerSecond  = json.Max_PerSecond;
                Max_Total      = json.Max_Total;
                BanLength      = json.BanLength;
                MaxErrors      = json.MaxErrors;
                BufferSize     = json.BufferSize;
                PerIPLogs      = json.PerIPLogs;
                MaxThreads     = json.MaxThreads;
                ActiveMode     = json.ActiveMode;
                ConsoleLogging = json.ConsoleLogging;
                AnonStat       = json.AnonStat;



                //For files handling to go Program.cs
                files = json.Files;


                filename = name;
            } catch (JsonReaderException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("---> CANNOT CONTINUE! Config corrupt.");
                Environment.Exit(1);
            }
        }