Skip to content

Commit 1d1fb5c

Browse files
committed
Remvoed need for threads var in the backend config, now just pulls the number of available cpu cores dynamically.
1 parent 7bf8ee6 commit 1d1fb5c

1 file changed

Lines changed: 11 additions & 21 deletions

File tree

src/backend/snitch.py

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@
3232
# Author: oxagast
3333
# Import standard and third-party libraries for argument parsing, file handling, networking, compression, and data processing
3434
import warnings
35-
36-
warnings.simplefilter("module")
37-
os.environ["PYTHONWARNINGS"] = "module"
38-
warnings.formatwarning = lambda msg, cat, fname, ln, file=None, line=None: (
39-
f"[Main] {cat.__name__} {msg}\n"
40-
)
4135
import argparse
4236
import base64
4337
import csv
@@ -52,26 +46,29 @@
5246
import threading
5347
import time
5448
import zlib
55-
from urllib.parse import unquote_plus
56-
from datetime import datetime
57-
from decimal import Decimal
58-
from functools import lru_cache
5949
import chardet
6050
import geoip2.database
6151
import magic
6252
import numpy as np
6353
import ollama
6454
import requests
6555
import yaml
66-
67-
68-
# from tqdm import tqdm
6956
import ipaddress
7057
from bs4 import BeautifulSoup
7158
from ollama import ResponseError
7259
from scipy.stats import entropy
7360
from concurrent.futures import ThreadPoolExecutor, as_completed
61+
from urllib.parse import unquote_plus
62+
from datetime import datetime
63+
from decimal import Decimal
64+
from functools import lru_cache
7465

66+
67+
warnings.simplefilter("module")
68+
os.environ["PYTHONWARNINGS"] = "module"
69+
warnings.formatwarning = lambda msg, cat, fname, ln, file=None, line=None: (
70+
f"[Main] {cat.__name__} {msg}\n"
71+
)
7572
stopEvent = threading.Event()
7673

7774
try:
@@ -3301,10 +3298,6 @@ def startThreading():
33013298
amounts of time (e.g. when active-recon network calls vary in latency).
33023299
"""
33033300
if __name__ == "__main__":
3304-
print(
3305-
f"[Main] Spooling up {numWorkerThreads} worker threads to process {totalPackets} packets...",
3306-
file=sys.stderr,
3307-
)
33083301
# Build the list of packet indices that belong to TCP, UDP, or ICMP packets
33093302
packetIndices = [
33103303
i
@@ -3436,7 +3429,6 @@ def processChunk(chunk):
34363429
"server_call_threads": 5,
34373430
"batch_size": 65,
34383431
},
3439-
"threads": 16,
34403432
"final_summary": True,
34413433
}
34423434
pcapFilePath = args.pcap_file
@@ -3493,8 +3485,7 @@ def processChunk(chunk):
34933485
if totalPackets == 0:
34943486
print("[Main] No TCP, UDP, or ICMP packets found in the capture.", file=sys.stderr)
34953487
sys.exit(1)
3496-
if "threads" in config and config["threads"]:
3497-
numWorkerThreads = config["threads"]
3488+
numWorkerThreads = os.cpu_count() or 4
34983489
outputDir = currentDir + "/" + "testcases"
34993490
if args.output and args.output != "testcases":
35003491
outputDir = args.output
@@ -3537,7 +3528,6 @@ def processChunk(chunk):
35373528
"use_llm": False,
35383529
"llm_brief": False,
35393530
},
3540-
"threads": 16,
35413531
"final_summary": False,
35423532
}
35433533

0 commit comments

Comments
 (0)