Compare commits
2 Commits
9e480f1cfb
...
eedd6e7da5
Author | SHA1 | Date |
---|---|---|
Derrick Hammer | eedd6e7da5 | |
Derrick Hammer | 8ea5a38b83 |
|
@ -127,7 +127,16 @@ const plugin: Plugin = {
|
||||||
api.registerMethod("get_peers", {
|
api.registerMethod("get_peers", {
|
||||||
cacheable: false,
|
cacheable: false,
|
||||||
async handler(): Promise<string[]> {
|
async handler(): Promise<string[]> {
|
||||||
return [...getRpcServer().cache.dhtCache.online];
|
const pubkey = b4a
|
||||||
|
.from(getRpcServer().cache.swarm.keyPair.publicKey)
|
||||||
|
.toString("hex");
|
||||||
|
|
||||||
|
const online = getRpcServer().cache.dhtCache.online;
|
||||||
|
if (online.has(pubkey)) {
|
||||||
|
online.delete(pubkey);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [...online];
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
api.registerMethod("get_direct_peers", {
|
api.registerMethod("get_direct_peers", {
|
||||||
|
|
|
@ -10,10 +10,6 @@ import { get as getSwarm, SecretStream } from "./swarm.js";
|
||||||
import b4a from "b4a";
|
import b4a from "b4a";
|
||||||
|
|
||||||
export async function start() {
|
export async function start() {
|
||||||
if (!config.str("pocket-app-id") || !config.str("pocket-app-key")) {
|
|
||||||
errorExit("Please set pocket-app-id and pocket-app-key config options.");
|
|
||||||
}
|
|
||||||
|
|
||||||
getSwarm().on("connection", (stream: SecretStream) =>
|
getSwarm().on("connection", (stream: SecretStream) =>
|
||||||
getRpcServer().setup(stream)
|
getRpcServer().setup(stream)
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue