|  | @@ -2,7 +2,7 @@
 | 
	
		
			
				|  |  |  from json import loads, dumps
 | 
	
		
			
				|  |  |  from json.decoder import JSONDecodeError
 | 
	
		
			
				|  |  |  import pendulum
 | 
	
		
			
				|  |  | -from subprocess import run, PIPE
 | 
	
		
			
				|  |  | +from subprocess import run, PIPE, CalledProcessError
 | 
	
		
			
				|  |  |  from os.path import exists, join
 | 
	
		
			
				|  |  |  from pyinotify import WatchManager, Notifier, ProcessEvent
 | 
	
		
			
				|  |  |  from pyinotify import IN_MODIFY, IN_DELETE, IN_MOVE_SELF, IN_CREATE
 | 
	
	
		
			
				|  | @@ -27,13 +27,16 @@ dirmask = IN_MODIFY | IN_DELETE | IN_MOVE_SELF | IN_CREATE
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  def blocker(ip):
 | 
	
		
			
				|  |  |      # Utility function to block given ip as string
 | 
	
		
			
				|  |  | -    #run(["iptables", "-I", "DOCKER-USER", "-i", "eth0", "-s", ip, "-j", "DROP"], stdout=PIPE, check=True)
 | 
	
		
			
				|  |  | -    print("iptables -I DOCKER-USER -i eth0 -s {0} -j DROP".format(ip))
 | 
	
		
			
				|  |  | +    run(["iptables", "-I", "DOCKER-USER", "-i", "eth0", "-s", ip, "-j", "DROP"], stdout=PIPE, check=True)
 | 
	
		
			
				|  |  | +    #print("iptables -I DOCKER-USER -i eth0 -s {0} -j DROP".format(ip))
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  def unblocker(ip):
 | 
	
		
			
				|  |  |      # Utility function to unblock given ip as string
 | 
	
		
			
				|  |  | -    #run(["iptables", "-D", "DOCKER-USER", "-i", "eth0", "-s", ip, "-j", "DROP"], stdout=PIPE, check=True)
 | 
	
		
			
				|  |  | -    print("iptables -D DOCKER-USER -i eth0 -s {0} -j DROP".format(ip))
 | 
	
		
			
				|  |  | +    try:
 | 
	
		
			
				|  |  | +        run(["iptables", "-D", "DOCKER-USER", "-i", "eth0", "-s", ip, "-j", "DROP"], stdout=PIPE, check=True)
 | 
	
		
			
				|  |  | +    except CalledProcessError:
 | 
	
		
			
				|  |  | +        pass
 | 
	
		
			
				|  |  | +    #print("iptables -D DOCKER-USER -i eth0 -s {0} -j DROP".format(ip))
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  # def is_bad(line):
 | 
	
		
			
				|  |  |  #     # Given line, attempt to parse... then is there a issue with it
 | 
	
	
		
			
				|  | @@ -134,6 +137,7 @@ target.close()
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  # Update config
 | 
	
		
			
				|  |  |  myConfig["last_unblock"] = last.to_atom_string()
 | 
	
		
			
				|  |  | +myConfig["bad_users"] = bad_users
 | 
	
		
			
				|  |  |  save_config(myConfig)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  exit(0)
 |