forked from Willtl/ids-ldpi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·52 lines (38 loc) · 1.45 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import time
from typing import NoReturn
from ldpi.inference import LightDeepPacketInspection
from options import SnifferOptions
from sniffer.sniffer import Sniffer
def main() -> NoReturn:
"""
Main function to initialize and run the packet sniffer and light deep packet inspection.
This function initializes the `Sniffer` and `LightDeepPacketInspection` classes, starts the packet sniffer,
and runs a decision engine loop that keeps the program running until interrupted.
Raises:
Exception: If 'pypcap' library is not available in the HardenedOS environment.
TODO:
- Replace the while True loop with a decision engine loop.
"""
# Raise exception meanwhile libraries are not available
# raise Exception("Execution is blocked due to missing dependencies.")
# Initialize command line arguments
args = SnifferOptions()
args.parse_options()
# Initialize Sniffer and LightDeepPacketInspection instances
snf = Sniffer(args)
# Initialize LightDeepPacketInspection
ldpi = LightDeepPacketInspection()
# Register LDPI as a subscriber to the Sniffer
snf.add_subscriber(ldpi)
# Start the sniffer
snf.run()
# Decision engine loop (placeholder) - Keeps running until interrupted
try:
while True:
time.sleep(1.0)
except (KeyboardInterrupt, SystemExit):
print("Shutting down...")
snf.stop()
ldpi.stop()
if __name__ == '__main__':
main()