Update public source
This commit is contained in:
+13
-3
@@ -1,7 +1,7 @@
|
||||
import subprocess
|
||||
import logging
|
||||
import csv
|
||||
|
||||
import sqlite3
|
||||
from datetime import datetime, timedelta, timezone
|
||||
import pynmea2
|
||||
from scapy.all import PcapNgReader
|
||||
@@ -30,9 +30,17 @@ class CaptureParser:
|
||||
#
|
||||
# Определение производителей
|
||||
#
|
||||
try:
|
||||
self.vendor = VendorResolver(
|
||||
self.config.vendor_database
|
||||
)
|
||||
except sqlite3.Error as exc:
|
||||
self.vendor = None
|
||||
|
||||
logging.getLogger("parser").warning(
|
||||
"OUI database unavailable: %s",
|
||||
exc
|
||||
)
|
||||
|
||||
self.log = logging.getLogger(
|
||||
"parser"
|
||||
@@ -323,8 +331,10 @@ class CaptureParser:
|
||||
timestamp
|
||||
)
|
||||
|
||||
vendor = self.vendor.lookup(
|
||||
row[2]
|
||||
vendor = (
|
||||
self.vendor.lookup(row[2])
|
||||
if self.vendor
|
||||
else "Unknown"
|
||||
)
|
||||
|
||||
|
||||
|
||||
+14
-4
@@ -8,25 +8,35 @@ class VendorResolver:
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
database
|
||||
database,
|
||||
writable=False
|
||||
):
|
||||
|
||||
self.db_path = Path(database)
|
||||
self.writable = writable
|
||||
|
||||
|
||||
if writable:
|
||||
self.db_path.parent.mkdir(
|
||||
parents=True,
|
||||
exist_ok=True
|
||||
)
|
||||
|
||||
|
||||
self.conn = sqlite3.connect(
|
||||
self.db_path
|
||||
)
|
||||
|
||||
|
||||
self.create_tables()
|
||||
|
||||
else:
|
||||
self.conn = sqlite3.connect(
|
||||
f"{self.db_path.resolve().as_uri()}?mode=ro",
|
||||
uri=True
|
||||
)
|
||||
|
||||
self.conn.execute(
|
||||
"SELECT 1 FROM oui LIMIT 0"
|
||||
)
|
||||
|
||||
|
||||
|
||||
# =====================================================
|
||||
|
||||
@@ -208,7 +208,8 @@ class VendorImporter:
|
||||
self.download_csv_files()
|
||||
|
||||
resolver = VendorResolver(
|
||||
OUI_DATABASE
|
||||
OUI_DATABASE,
|
||||
writable=True
|
||||
)
|
||||
|
||||
importer = OUIImporter(
|
||||
|
||||
Reference in New Issue
Block a user