Ver Fonte

Renamed good_users to whitelist and more

  Since good_users is actually incorrect, since it will be IP's not to
block. (hence whitelist)

  I also now will only block names in the bad_users if that username is
in there.
david há 3 anos atrás
pai
commit
79d2ffe9b1
2 ficheiros alterados com 13 adições e 11 exclusões
  1. 1 1
      config.py
  2. 12 10
      failUser.py

+ 1 - 1
config.py

@@ -55,7 +55,7 @@ def load_config():
                 "nginx",
                 "admin"
             ],
-            "good_users": []
+            "whitelist": []
         }
         save_config(defaults)
         return defaults

+ 12 - 10
failUser.py

@@ -94,12 +94,13 @@ class EventHandler(ProcessEvent):
             for line in target.readlines():
                 luser = is_bad(line.rstrip())
                 if(luser):
-                    if luser["ip"] in myConfig["good_users"]:
+                    if luser["ip"] in myConfig["whitelist"]:
                         return # Don't block ourselves
-                    blocker(luser["ip"])
-                    now = pendulum.now().to_atom_string()
-                    log.info("Blocked {0} at {1}".format(luser["ip"], now))
-                    add_block(luser["ip"], now)
+                    if luser["user"] in myConfig["bad_users"]:
+                        blocker(luser["ip"])
+                        now = pendulum.now().to_atom_string()
+                        log.info("Blocked {0} at {1}".format(luser["ip"], now))
+                        add_block(luser["ip"], now)
 
 
     def process_IN_MOVE_SELF(self, event):
@@ -114,12 +115,13 @@ class EventHandler(ProcessEvent):
             for line in target.readlines():
                 luser = is_bad(line.rstrip())
                 if(luser):
-                    if luser["ip"] in myConfig["good_users"]:
+                    if luser["ip"] in myConfig["whitelist"]:
                         return # Don't block ourselves
-                    blocker(luser["ip"])
-                    now = pendulum.now().to_atom_string()
-                    log.info("Blocked {0} at {1}".format(luser["ip"], now))
-                    add_block(luser["ip"], now)
+                    if luser["user"] in myConfig["bad_users"]:
+                        blocker(luser["ip"])
+                        now = pendulum.now().to_atom_string()
+                        log.info("Blocked {0} at {1}".format(luser["ip"], now))
+                        add_block(luser["ip"], now)
             target.seek(0,2)
         return