|
|
|
@ -1,6 +1,10 @@
|
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
|
import selectors
|
|
|
|
|
import signal
|
|
|
|
|
import socket
|
|
|
|
|
|
|
|
|
|
from . import fieldpoc
|
|
|
|
|
|
|
|
|
|
ap = argparse.ArgumentParser(prog="fieldpoc")
|
|
|
|
@ -8,9 +12,28 @@ ap.add_argument("-c", "--config", dest="config_file_path", default="fieldpoc_con
|
|
|
|
|
ap.add_argument("-e", "--extensions", dest="extensions_file_path", default="fieldpoc_extensions.json", help="Path to the fieldpoc extensions file")
|
|
|
|
|
|
|
|
|
|
def run():
|
|
|
|
|
sel = selectors.DefaultSelector()
|
|
|
|
|
|
|
|
|
|
interrupt_stop_read, interrupt_stop_write = socket.socketpair()
|
|
|
|
|
signal.signal(signal.SIGINT, lambda signum, frame: interrupt_stop_write.send(b'\0')) # Keyboard Interrupt
|
|
|
|
|
sel.register(interrupt_stop_read, selectors.EVENT_READ)
|
|
|
|
|
|
|
|
|
|
interrupt_reload_read, interrupt_reload_write = socket.socketpair()
|
|
|
|
|
signal.signal(signal.SIGHUP, lambda signum, frame: interrupt_reload_write.send(b'\0'))
|
|
|
|
|
sel.register(interrupt_reload_read, selectors.EVENT_READ)
|
|
|
|
|
|
|
|
|
|
args = ap.parse_args()
|
|
|
|
|
fp = fieldpoc.FieldPOC(**args.__dict__)
|
|
|
|
|
fp.run()
|
|
|
|
|
|
|
|
|
|
while True:
|
|
|
|
|
for key, mask in sel.select():
|
|
|
|
|
key.fileobj.recv(1)
|
|
|
|
|
if key.fileobj == interrupt_stop_read:
|
|
|
|
|
fp.queue_all({"type": "stop"})
|
|
|
|
|
exit()
|
|
|
|
|
elif key.fileobj == interrupt_reload_read:
|
|
|
|
|
fp.queue_all({"type": "reload"})
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
run()
|
|
|
|
|