Confirm reconnect pairings and add connection discovery settings
Setup now waits for both IndexedDB writes: the acceptor acknowledges its write, a failure on either side is reported to both people, and the proposer removes its copy if the acceptor could not save. Every session that authenticates the paired device compares a check value derived from the stored pairing, so a one-sided pairing (interrupted setup, or Turn off reconnect on one device) is turned off on the other side too. The tracker is chosen under Network settings > Connection discovery (manual, default from VITE_TRACKER_URL, or custom), stored per browser and editable during a session. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3659956967
commit
acba97a7e1
10 files changed
+309
-55
No files matched your search
+24
-1
@@ -3,6 +3,7 @@ import { computed, nextTick, onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
import ConnectionWorkspace from './components/ConnectionWorkspace.vue';
|
||||
import AppDialog from './components/AppDialog.vue';
|
||||
import { addConnection, CONNECTION_LIMIT, emptyConnection, loadConnections, removeConnection, saveConnection, updateConnection, type ConnectionUpdate, type SavedConnection } from './lib/connections.ts';
|
||||
import type { ReconnectPairing } from './lib/reconnect.ts';
|
||||
import { asError } from './lib/validation.ts';
|
||||
|
||||
const logoUrl = `${import.meta.env.BASE_URL}HellNet_alt.png`;
|
||||
@@ -104,6 +105,28 @@ function update(id: string, change: ConnectionUpdate) {
|
||||
} finally { pending--; if (!pending && refreshRequested) void refresh(); }
|
||||
});
|
||||
}
|
||||
// Pairing setup needs the committed write, rather than the optimistic update
|
||||
// used by ordinary settings, before either browser reports success. null
|
||||
// removes a pairing the peer could not store or does not share.
|
||||
function saveReconnect(id: string, reconnect: ReconnectPairing | null): Promise<void> {
|
||||
if (!persistent) {
|
||||
if (reconnect) return Promise.reject(new Error('Reconnect needs saved connection storage in this browser.'));
|
||||
update(id, { reconnect }); return Promise.resolve();
|
||||
}
|
||||
pending++;
|
||||
const operation = writes.then(async () => {
|
||||
try {
|
||||
const records = await saveConnection(id, { reconnect });
|
||||
if (pending === 1) applyRecords(records);
|
||||
updates?.postMessage('changed');
|
||||
} catch (err) {
|
||||
refreshRequested = true;
|
||||
throw err;
|
||||
} finally { pending--; if (!pending && refreshRequested) void refresh(); }
|
||||
});
|
||||
writes = operation.catch(() => {});
|
||||
return operation;
|
||||
}
|
||||
// Connection setup re-reads the record so trust forgotten in another tab is
|
||||
// never reused from this tab's copy. A failed read stops setup.
|
||||
async function trust(id: string) {
|
||||
@@ -190,7 +213,7 @@ async function remove() {
|
||||
<p v-if="error" class="storage-error" role="alert">{{ error }}</p>
|
||||
<template v-for="item in connections" :key="item.id">
|
||||
<KeepAlive>
|
||||
<ConnectionWorkspace v-if="selected === item.id" :connection="item" :load-trust="trust"
|
||||
<ConnectionWorkspace v-if="selected === item.id" :connection="item" :load-trust="trust" :save-reconnect="saveReconnect"
|
||||
@status="setStatus" @update="update" />
|
||||
</KeepAlive>
|
||||
</template>
|
||||
|
||||
Reference in new issue
Block a user