Update public source

This commit is contained in:
2026-10-14 06:07:43 +03:00
parent 60b14e1213
commit b33d51f24f
+62 -22
View File
@@ -75,6 +75,7 @@ def load_access_points(conn):
WITH ranked_observations AS ( WITH ranked_observations AS (
SELECT SELECT
obs.access_point_id, obs.access_point_id,
obs.session_id,
obs.latitude, obs.latitude,
obs.longitude, obs.longitude,
obs.observed_at, obs.observed_at,
@@ -106,6 +107,7 @@ def load_access_points(conn):
ap.is_cracked, ap.is_cracked,
obs.latitude, obs.latitude,
obs.longitude, obs.longitude,
obs.session_id,
obs.observed_at, obs.observed_at,
obs.rssi, obs.rssi,
obs.channel obs.channel
@@ -119,37 +121,36 @@ def load_access_points(conn):
""", """,
) )
if not rows:
return []
access_point_ids = [
row["id"]
for row in rows
]
placeholders = ",".join(
"?" for _ in access_point_ids
)
credentials = query_all( credentials = query_all(
conn, conn,
""" f"""
SELECT SELECT
access_point_id, access_point_id,
password, password,
source, source,
verified verified
FROM credentials FROM credentials
WHERE access_point_id IN ({placeholders})
ORDER BY ORDER BY
created_at DESC, created_at DESC,
id DESC id DESC
""", """,
) access_point_ids,
handshakes = query_all(
conn,
"""
SELECT
access_point_id,
type,
captured_at
FROM handshakes
ORDER BY
captured_at DESC,
id DESC
""",
) )
credentials_by_ap = {} credentials_by_ap = {}
handshakes_by_ap = {}
for credential in credentials: for credential in credentials:
@@ -164,12 +165,48 @@ def load_access_points(conn):
"verified": credential["verified"], "verified": credential["verified"],
}) })
session_conditions = []
session_parameters = []
for row in rows:
session_conditions.append(
"(access_point_id = ? AND session_id = ?)"
)
session_parameters.extend([
row["id"],
row["session_id"],
])
handshakes = query_all(
conn,
f"""
SELECT
access_point_id,
session_id,
type,
captured_at
FROM handshakes
WHERE {" OR ".join(session_conditions)}
ORDER BY
captured_at DESC,
id DESC
""",
session_parameters,
)
handshakes_by_ap_session = {}
for handshake in handshakes: for handshake in handshakes:
access_point_id = handshake["access_point_id"] key = (
handshake["access_point_id"],
handshake["session_id"],
)
handshakes_by_ap.setdefault( handshakes_by_ap_session.setdefault(
access_point_id, key,
[], [],
).append({ ).append({
"type": handshake["type"], "type": handshake["type"],
@@ -183,15 +220,18 @@ def load_access_points(conn):
observation = dict(row) observation = dict(row)
access_point_id = observation["id"] access_point_id = observation["id"]
session_id = observation["session_id"]
observation["passwords"] = credentials_by_ap.get( observation["passwords"] = credentials_by_ap.get(
access_point_id, access_point_id,
[], [],
) )
observation["handshakes"] = handshakes_by_ap.get( observation["handshakes"] = (
access_point_id, handshakes_by_ap_session.get(
[], (access_point_id, session_id),
[],
)
) )
observations.append(observation) observations.append(observation)