Update public source
This commit is contained in:
@@ -208,3 +208,103 @@ class HandshakesRepository:
|
||||
method_version,
|
||||
),
|
||||
).fetchone()
|
||||
|
||||
def get_search_context_statistics(
|
||||
self,
|
||||
handshake_ids: list[int] | tuple[int, ...],
|
||||
method_id: str,
|
||||
method_version: int,
|
||||
) -> sqlite3.Row | None:
|
||||
if not handshake_ids:
|
||||
return None
|
||||
|
||||
placeholders = ", ".join("?" for _ in handshake_ids)
|
||||
|
||||
return self._conn.execute(
|
||||
f"""
|
||||
SELECT
|
||||
COUNT(*) AS matched_count,
|
||||
SUM(
|
||||
CASE
|
||||
WHEN h.hash22000 IS NOT NULL
|
||||
AND TRIM(h.hash22000) <> ''
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END
|
||||
) AS valid_hash_count,
|
||||
SUM(
|
||||
CASE
|
||||
WHEN h.hash22000 IS NOT NULL
|
||||
AND TRIM(h.hash22000) <> ''
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM credentials AS c
|
||||
WHERE c.handshake_id = h.id
|
||||
)
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END
|
||||
) AS found_count,
|
||||
SUM(
|
||||
CASE
|
||||
WHEN h.hash22000 IS NOT NULL
|
||||
AND TRIM(h.hash22000) <> ''
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM credentials AS c
|
||||
WHERE c.handshake_id = h.id
|
||||
)
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM crack_attempts AS a
|
||||
WHERE a.handshake_id = h.id
|
||||
AND a.method_id = ?
|
||||
AND a.method_version = ?
|
||||
AND a.status = 'COMPLETED'
|
||||
)
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END
|
||||
) AS covered_count,
|
||||
SUM(
|
||||
CASE
|
||||
WHEN h.hash22000 IS NOT NULL
|
||||
AND TRIM(h.hash22000) <> ''
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM credentials AS c
|
||||
WHERE c.handshake_id = h.id
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM crack_attempts AS a
|
||||
WHERE a.handshake_id = h.id
|
||||
AND a.method_id = ?
|
||||
AND a.method_version = ?
|
||||
AND a.status = 'COMPLETED'
|
||||
)
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM crack_reservations AS r
|
||||
WHERE r.handshake_id = h.id
|
||||
AND r.method_id = ?
|
||||
AND r.method_version = ?
|
||||
AND r.status = 'ACTIVE'
|
||||
)
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END
|
||||
) AS reserved_count
|
||||
FROM handshakes AS h
|
||||
WHERE h.id IN ({placeholders})
|
||||
""",
|
||||
(
|
||||
method_id,
|
||||
method_version,
|
||||
method_id,
|
||||
method_version,
|
||||
method_id,
|
||||
method_version,
|
||||
*handshake_ids,
|
||||
),
|
||||
).fetchone()
|
||||
|
||||
@@ -76,6 +76,50 @@ class JobIssuanceService:
|
||||
),
|
||||
}
|
||||
|
||||
def get_search_context_statistics(
|
||||
self,
|
||||
handshake_ids: list[int] | tuple[int, ...],
|
||||
method_id: str,
|
||||
method_version: int,
|
||||
) -> dict[str, int]:
|
||||
row = self._handshakes.get_search_context_statistics(
|
||||
handshake_ids,
|
||||
method_id,
|
||||
method_version,
|
||||
)
|
||||
|
||||
if row is None:
|
||||
return {
|
||||
"matched_count": 0,
|
||||
"valid_hash_count": 0,
|
||||
"found_count": 0,
|
||||
"covered_count": 0,
|
||||
"reserved_count": 0,
|
||||
"available_count": 0,
|
||||
"unsupported_count": 0,
|
||||
}
|
||||
|
||||
matched_count = int(row["matched_count"] or 0)
|
||||
valid_hash_count = int(row["valid_hash_count"] or 0)
|
||||
found_count = int(row["found_count"] or 0)
|
||||
covered_count = int(row["covered_count"] or 0)
|
||||
reserved_count = int(row["reserved_count"] or 0)
|
||||
|
||||
return {
|
||||
"matched_count": matched_count,
|
||||
"valid_hash_count": valid_hash_count,
|
||||
"found_count": found_count,
|
||||
"covered_count": covered_count,
|
||||
"reserved_count": reserved_count,
|
||||
"available_count": (
|
||||
valid_hash_count
|
||||
- found_count
|
||||
- covered_count
|
||||
- reserved_count
|
||||
),
|
||||
"unsupported_count": matched_count - valid_hash_count,
|
||||
}
|
||||
|
||||
def issue_job(
|
||||
self,
|
||||
method_id: str,
|
||||
|
||||
Reference in New Issue
Block a user