
Research
/Security News
Miasma Mini Shai-Hulud Hits ImmobiliareLabs npm Packages
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.
replicator-discovery
Advanced tools
DHT discovery session for replicator
const DHT = require('hyperdht')
const Discovery = require('@holepunchto/replicator-discovery')
const dht = new DHT({ bootstrap })
await dht.ready()
const server = dht.createServer()
await server.listen()
const discovery = new Discovery(dht, topic, {
announce: true,
seed,
relayAddresses: () => server.relayAddresses,
onpeer(peer) {
console.log(peer.publicKey)
}
})
await discovery.refresh()
await discovery.suspend()
await discovery.resume()
await discovery.destroy()
await server.close()
await dht.destroy()
new Discovery(dht, topic, opts)Options:
announce (false) see setAnnounceonpeer(peer, data) peer info callback during lookupseed seed keyPairkeyPair announced keyPairrelayAddresses() getter for relay addresses during announceonerror(err) error-handler for internal timersonbump(number) invoked when higher number is seenlimit (Infinity) max peers emitted per refreshsuspended (false) initialize as suspendedwait (null) promise awaited before refresh startsAttributes:
topickeyPairdestroyedsuspendedannounceactive refresh cycle is alivelastRefreshed timestampbump.local local valuebump.announced announced valuebump.seen max seen remote valuediscovery.setAnnounce(bool, bump = -1)Switch mode:
true => announcefalse => lookupFor bump see update()
discovery.update(bump)Updates the local bump value. The local value will be published on next refresh when announcing.
await discovery.refresh()Performs announce/lookup and starts background discovery cycle.
await discovery.flushed()Wait for the current in-flight refresh.
await discovery.abort()Abort the active query and stop discovery cycle.
Use refresh() to restart.
await discovery.suspend()Abort the active query and unannounce if needed.
await discovery.resume()Resume and refresh.
await discovery.destroy()Destroy permanently.
After destroy, refresh() throws Error('PeerDiscovery is destroyed').
Apache-2.0
FAQs
peer discovery for replicator
We found that replicator-discovery demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.

Security News
Rolldown paused Rust React Compiler integration after a 5MB binary size increase raised concerns about shipping React-specific code to all Vite users.

Security News
/Research
Mini Shai-Hulud expands into the Go ecosystem after hitting LeoPlatform npm packages and targeting GitHub Actions workflows.