internal static bool Compare_Central_Config_To_File(REG_KEY Key, string Local_Config_File_Path) { if (Web_Operation.VERIFY_Central_File_Config_Hash(READ_SWELF_Reg_Key(Key, false), Local_Config_File_Path)) { return(true); } else { return(false); } }
private static List <string> GET_LogCollector_Locations() { string CollectorName = SWELF_AppConfig_Args[0]; for (int x = 0; x < 6; x++) { try { if (x == 0) { CollectorName = SWELF_AppConfig_Args[0]; } else { CollectorName = SWELF_AppConfig_Args[0] + x; } if (AppConfig_File_Args.ContainsKey(CollectorName)) { Log_Forwarders_HostNames.Add(Web_Operation.GET_HostName(AppConfig_File_Args[CollectorName]).Replace("\r", String.Empty).ToLower()); Log_Forwarders_Port.Add(Log_Network_Forwarder.Get_Port_from_Socket(AppConfig_File_Args[CollectorName])); } } catch (Exception e) { Error_Operation.Log_Error("GET_LogCollector_Locations()", "Unable to get a log_collector[" + x + "] location setup done. " + e.Message.ToString(), e.StackTrace.ToString(), Error_Operation.LogSeverity.Critical); } } if (Log_Forwarders_HostNames.Count <= 0) { Log_Forwarders_HostNames.Add("127.0.0.1"); } if (Log_Forwarders_Port.Count <= 0) { Log_Forwarders_Port.Add(Log_Forward_Location_Port); } //Log_Forwarders_Port = Log_Forwarders_Port.Distinct().ToList(); Log_Forwarders_HostNames = Log_Forwarders_HostNames.Distinct().ToList(); return(Log_Forwarders_HostNames); }
private static void RUN_Setup_AppConfig() { if (Reg_Operation.CHECK_SWELF_Reg_Key_Exists(Reg_Operation.REG_KEY.ConsoleAppConfig_Contents))//use reg { READ_and_Parse_Console_App_Config_Contents(Reg_Operation.READ_SWELF_Reg_Key(Reg_Operation.REG_KEY.ConsoleAppConfig_Contents)); } else if (File_Operation.CHECK_if_File_Exists(GET_AppConfigFile_Path))//no reg, look for file { READ_and_Parse_Console_App_Config_Contents(File_Operation.READ_AllText(GET_AppConfigFile_Path)); File_Operation.DELETE_File(GET_AppConfigFile_Path); } else//no file, no reg, Create Default then load it into the reg to use later { File_Operation.VERIFY_AppConfig_Default_Files_Ready(); READ_and_Parse_Console_App_Config_Contents(File_Operation.READ_AllText(GET_AppConfigFile_Path)); Reg_Operation.ADD_or_CHANGE_SWELF_Reg_Key(Reg_Operation.REG_KEY.ConsoleAppConfig_Contents, File_Operation.READ_AllText(GET_AppConfigFile_Path)); } //Check for CENTRAL CONFIG's, if yes check for update, update if needed. //Appconfig if (AppConfig_File_Args.ContainsKey(SWELF_AppConfig_Args[7]))//arg for central app config { if (Reg_Operation.CHECK_SWELF_Reg_Key_Exists(Reg_Operation.REG_KEY.ConsoleAppConfig_Contents) == false) { Reg_Operation.ADD_or_CHANGE_SWELF_Reg_Key(Reg_Operation.REG_KEY.ConsoleAppConfig_Contents, ""); } if (Web_Operation.VERIFY_Central_Reg_Config_Hash(AppConfig_File_Args[SWELF_AppConfig_Args[7]], Reg_Operation.READ_SWELF_Reg_Key(Reg_Operation.REG_KEY.ConsoleAppConfig_Contents)) == false) { if (Web_Operation.Connection_Successful) { Reg_Operation.ADD_or_CHANGE_SWELF_Reg_Key(Reg_Operation.REG_KEY.ConsoleAppConfig_Contents, Web_Operation.UPDATE_Reg_Config_With_Central_Config(AppConfig_File_Args[SWELF_AppConfig_Args[7]].ToString())); Error_Operation.Log_Error("RUN_Setup_AppConfig()", "Reg key for Central Config ConsoleAppConfig_Contents source updated from web source.", "", Error_Operation.LogSeverity.Informataion, Error_Operation.EventID.SWELF_Central_Config_Changed); } } } //Searchterms if (AppConfig_File_Args.ContainsKey(SWELF_AppConfig_Args[6]))//arg for central search config { if (Reg_Operation.CHECK_SWELF_Reg_Key_Exists(Reg_Operation.REG_KEY.SearchTerms_File_Contents) == false) { Reg_Operation.ADD_or_CHANGE_SWELF_Reg_Key(Reg_Operation.REG_KEY.SearchTerms_File_Contents, ""); } if (Web_Operation.VERIFY_Central_Reg_Config_Hash(AppConfig_File_Args[SWELF_AppConfig_Args[6]], Reg_Operation.READ_SWELF_Reg_Key(Reg_Operation.REG_KEY.SearchTerms_File_Contents)) == false) { if (Web_Operation.Connection_Successful) { Reg_Operation.ADD_or_CHANGE_SWELF_Reg_Key(Reg_Operation.REG_KEY.SearchTerms_File_Contents, Web_Operation.UPDATE_Reg_Config_With_Central_Config(AppConfig_File_Args[SWELF_AppConfig_Args[6]].ToString())); Error_Operation.Log_Error("RUN_Setup_AppConfig()", "Reg key for Central Config SearchTerms_File_Contents source updated from web source.", "", Error_Operation.LogSeverity.Informataion, Error_Operation.EventID.SWELF_Central_Config_Changed); } } } //Whitelist if (AppConfig_File_Args.ContainsKey(SWELF_AppConfig_Args[9]))//arg for central search config { if (Reg_Operation.CHECK_SWELF_Reg_Key_Exists(Reg_Operation.REG_KEY.WhiteList_SearchTerms_File_Contents) == false) { Reg_Operation.ADD_or_CHANGE_SWELF_Reg_Key(Reg_Operation.REG_KEY.WhiteList_SearchTerms_File_Contents, ""); } if (Web_Operation.VERIFY_Central_Reg_Config_Hash(AppConfig_File_Args[SWELF_AppConfig_Args[9]], Reg_Operation.READ_SWELF_Reg_Key(Reg_Operation.REG_KEY.WhiteList_SearchTerms_File_Contents)) == false) { if (Web_Operation.Connection_Successful) { Reg_Operation.ADD_or_CHANGE_SWELF_Reg_Key(Reg_Operation.REG_KEY.WhiteList_SearchTerms_File_Contents, Web_Operation.UPDATE_Reg_Config_With_Central_Config(AppConfig_File_Args[SWELF_AppConfig_Args[9]].ToString())); Error_Operation.Log_Error("RUN_Setup_AppConfig()", "Reg key for Central Config WhiteList_SearchTerms_File_Contents source updated from web source.", "", Error_Operation.LogSeverity.Informataion, Error_Operation.EventID.SWELF_Central_Config_Changed); } } } //Powershell plugin if (AppConfig_File_Args.ContainsKey(SWELF_AppConfig_Args[8]))//arg for central search config { if (Reg_Operation.CHECK_SWELF_Reg_Key_Exists(Reg_Operation.REG_KEY.PLUGIN_SearchTerms_File_Contents) == false) { Reg_Operation.ADD_or_CHANGE_SWELF_Reg_Key(Reg_Operation.REG_KEY.PLUGIN_SearchTerms_File_Contents, ""); } if (Web_Operation.VERIFY_Central_Reg_Config_Hash(AppConfig_File_Args[SWELF_AppConfig_Args[8]], Reg_Operation.READ_SWELF_Reg_Key(Reg_Operation.REG_KEY.PLUGIN_SearchTerms_File_Contents)) == false) { if (Web_Operation.Connection_Successful) { Reg_Operation.ADD_or_CHANGE_SWELF_Reg_Key(Reg_Operation.REG_KEY.PLUGIN_SearchTerms_File_Contents, Web_Operation.UPDATE_Reg_Config_With_Central_Config(AppConfig_File_Args[SWELF_AppConfig_Args[8]].ToString())); Error_Operation.Log_Error("RUN_Setup_AppConfig()", "Reg key for Central Config PLUGIN_SearchTerms_File_Contents source updated from web source.", "", Error_Operation.LogSeverity.Informataion, Error_Operation.EventID.SWELF_Central_Config_Changed); } } } Log_Forwarders_HostNames = GET_LogCollector_Locations();//GatherLog Collector Locations ++ThreadsDone_Setup; if (AppConfig_File_Args.ContainsKey(SWELF_AppConfig_Args[16])) { Logging_Level_To_Report = "verbose"; } }