Add automatic usage of known rooms

This commit is contained in:
Jack Kingsman
2026-01-07 21:54:57 -08:00
parent 2463c14c9b
commit f14c512777
4 changed files with 561 additions and 535 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>RemoteTerm for MeshCore</title>
<script type="module" crossorigin src="/assets/index-BDNiwXbx.js"></script>
<script type="module" crossorigin src="/assets/index-Bl6mT-Tv.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-RWG6EjFU.css">
</head>
<body>
+28 -2
View File
@@ -2,6 +2,7 @@ import { useState, useEffect, useRef, useCallback } from 'react';
import { GroupTextCracker, type ProgressReport } from 'meshcore-hashtag-cracker';
import NoSleep from 'nosleep.js';
import type { RawPacket, Channel } from '../types';
import { api } from '../api';
import { cn } from '@/lib/utils';
interface CrackedRoom {
@@ -44,6 +45,7 @@ export function CrackerPanel({ packets, channels, onChannelCreate, onRunningChan
const queueRef = useRef<Map<number, QueueItem>>(new Map());
const retryFailedRef = useRef(false);
const maxLengthRef = useRef(6);
const undecryptedIdsRef = useRef<Set<number>>(new Set());
// Initialize cracker and NoSleep
useEffect(() => {
@@ -114,6 +116,11 @@ export function CrackerPanel({ packets, channels, onChannelCreate, onRunningChan
maxLengthRef.current = maxLength;
}, [maxLength]);
// Keep undecrypted IDs ref in sync - used to skip packets already decrypted by other means
useEffect(() => {
undecryptedIdsRef.current = new Set(undecryptedGroupText.map(p => p.id));
}, [undecryptedGroupText]);
// Notify parent of running state changes
useEffect(() => {
onRunningChange?.(isRunning);
@@ -164,6 +171,21 @@ export function CrackerPanel({ packets, channels, onChannelCreate, onRunningChan
return;
}
// Check if this packet is still undecrypted - it may have been decrypted
// by historical decrypt when we cracked another packet from the same channel
if (!undecryptedIdsRef.current.has(nextId)) {
// Already decrypted by other means, remove from queue and continue
setQueue(prev => {
const updated = new Map(prev);
updated.delete(nextId);
return updated;
});
if (isRunningRef.current) {
setTimeout(() => processNext(), 10);
}
return;
}
// Lock processing
isProcessingRef.current = true;
@@ -221,9 +243,13 @@ export function CrackerPanel({ packets, channels, onChannelCreate, onRunningChan
const keyUpper = result.key.toUpperCase();
if (!existingChannelKeys.has(keyUpper)) {
try {
await onChannelCreate('#' + result.roomName, result.key);
const channelName = '#' + result.roomName;
await onChannelCreate(channelName, result.key);
// Decrypt any other historical packets with this newly discovered key
// This prevents wasting cracking cycles on packets from the same channel
await api.decryptHistoricalPackets({ key_type: 'channel', channel_name: channelName });
} catch (err) {
console.error('Failed to create channel:', err);
console.error('Failed to create channel or decrypt historical:', err);
}
}
} else {