The Poor Man's (or Woman's) Intrusion Detection System
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

63 lines
1.7 KiB

  1. //////////////////////////////////////////////////////////////////////
  2. // IP traffic analyzer - configuration file
  3. // Written by Jonathan A. Foster <jon@jfpossibilities.com>
  4. // Started May 14th, 2021
  5. // Copyright JF Possibilities, Inc. All rights reserved.
  6. //////////////////////////////////////////////////////////////////////
  7. #include <fstream>
  8. #include <iostream>
  9. #include <stdexcept>
  10. #include "config.h"
  11. #include "strutil.h"
  12. //////////////////////////////////////////////////////////////////////
  13. // INIusList
  14. //////////////////////////////////////////////////////////////////////
  15. void INIusList::add(const std::string &in) {
  16. std::string s=trim(in);
  17. if(s!="" && s[0]!='#') MiniINIlines::add(s);
  18. }
  19. //////////////////////////////////////////////////////////////////////
  20. // INIconnList
  21. //////////////////////////////////////////////////////////////////////
  22. void INIconnList::add(const std::string &in) {
  23. int i;
  24. if(in=="" || in[0]=='#') return; // remarks
  25. // TODO: we don't want to keep create+destroy-ing these?
  26. TSV tsv(in);
  27. if(tsv.count!=7) throw
  28. // TODO: really need a line number!
  29. std::runtime_error("INIconnList::add: Incorrect column count in config file line");
  30. if(tsv.count>6) {
  31. i = vals.size();
  32. vals.resize(i+1);
  33. tsv >> vals[i];
  34. }
  35. }
  36. // NOP right now, since I don't intend to be writing the config file.
  37. std::ostream &INIconnList::save(std::ostream &out) const {
  38. throw std::runtime_error("INIconnList::save: not implented.");
  39. }
  40. //////////////////////////////////////////////////////////////////////
  41. // Config
  42. //////////////////////////////////////////////////////////////////////
  43. Config::Config() {
  44. groups["us" ] = &us;
  45. groups["ignores"] = &ignores;
  46. }