*Add method to get current relays in a DHT instance

This commit is contained in:
Derrick Hammer 2022-08-14 06:49:24 -04:00
parent f8229abf66
commit 5652eccd1b
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 11 additions and 0 deletions

View File

@ -32,6 +32,7 @@ addHandler("write", handleWriteSocketEvent);
addHandler("addRelay", handleAddRelay); addHandler("addRelay", handleAddRelay);
addHandler("removeRelay", handleRemoveRelay); addHandler("removeRelay", handleRemoveRelay);
addHandler("clearRelays", handleClearRelays); addHandler("clearRelays", handleClearRelays);
addHandler("getRelays", handleGetRelays);
addHandler("ready", handleReady); addHandler("ready", handleReady);
async function handlePresentSeed(aq: ActiveQuery) { async function handlePresentSeed(aq: ActiveQuery) {
@ -258,6 +259,16 @@ function handleClearRelays(aq: ActiveQuery) {
aq.respond(); aq.respond();
} }
function handleGetRelays(aq: ActiveQuery) {
const dht = validateDht(aq);
if (!dht) {
return;
}
aq.respond(dht.relays);
}
async function handleReady(aq: ActiveQuery) { async function handleReady(aq: ActiveQuery) {
const dht = validateDht(aq); const dht = validateDht(aq);