Search for a key across multiple discovery networks and find peers who answer.
Currently searches across and advertises on the Bittorrent DHT, centralized DNS servers and Multicast DNS simultaneously.
Uses the bittorrent-dht and dns-discovery modules.
Also check out discovery-swarm which adds connection management on top of this module.
Returns a constructor
Returns a new instance. opts
is optional and can have the following properties:
dns
- defaultundefined
, iffalse
will disabledns
discovery, any other value type will be passed to thedns-discovery
constructordht
- defaultundefined
, iffalse
will disabledht
discovery, any other value type will be passed to thebittorrent-dht
constructor
By default hashes are re-announced around every 10 min on the dht and 1 min using dns. Set dht.interval
or dns.interval
to change these.
Perform a lookup across all networks for id
. id
can be a buffer or a string.
Specify port
if you want to announce that you share id
as well.
Stop looking for id
. id
can be a buffer or a string.
Specify port
to stop announcing that you share id
as well.
Force announce / lookup all joined hashes
List all the channels you have joined. The returned array items look like this
{
id: <Buffer>,
port: <port you are announcing>
}
Emitted when a peer answers your query.
id
is the id (as a buffer) this peer was discovered forpeer
is the peer that was discovered{port: port, host: host}
type
is the network type (one of['dht', 'dns']
)
Stops all lookups and advertisements and call cb
when done.
Emitted when the channel is destroyed