mirror of
https://github.com/byt3bl33d3r/MITMf.git
synced 2025-08-19 13:10:03 -07:00
replaced watchdog with pyinotify
This commit is contained in:
parent
d535c8796c
commit
885ecc3a4e
5 changed files with 27 additions and 20 deletions
|
@ -17,24 +17,27 @@
|
|||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
# USA
|
||||
#
|
||||
|
||||
from watchdog.observers import Observer
|
||||
from watchdog.events import FileSystemEventHandler
|
||||
import pyinotify
|
||||
import threading
|
||||
from configobj import ConfigObj
|
||||
|
||||
class ConfigWatcher(FileSystemEventHandler):
|
||||
class ConfigWatcher(pyinotify.ProcessEvent):
|
||||
|
||||
@property
|
||||
def config(self):
|
||||
return ConfigObj("./config/mitmf.conf")
|
||||
|
||||
def on_modified(self, event):
|
||||
def process_IN_MODIFY(self, event):
|
||||
self.on_config_change()
|
||||
|
||||
def start_config_watch(self):
|
||||
observer = Observer()
|
||||
observer.schedule(self, path='./config', recursive=False)
|
||||
observer.start()
|
||||
wm = pyinotify.WatchManager()
|
||||
wm.add_watch('./config/mitmf.conf', pyinotify.IN_MODIFY)
|
||||
notifier = pyinotify.Notifier(wm, self)
|
||||
|
||||
t = threading.Thread(name='ConfigWatcher', target=notifier.loop)
|
||||
t.setDaemon(True)
|
||||
t.start()
|
||||
|
||||
def on_config_change(self):
|
||||
""" We can subclass this function to do stuff after the config file has been modified"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue