Skip to content

Commit

Permalink
feat!: update to latest spec, added peer name, announces all multiadd…
Browse files Browse the repository at this point in the history
…rs (libp2p#157)

BREAKING CHANGE: service name now defaults to `_p2p._udp.local` and no
longer uses A and AAA records -> replaced by TXT records

Added random peer name option

resolves libp2p#101

---------

Co-authored-by: Alex Potsides <[email protected]>
  • Loading branch information
mpetrunic and achingbrain authored Mar 7, 2023
1 parent 28c668e commit 5edcc16
Show file tree
Hide file tree
Showing 15 changed files with 127 additions and 1,261 deletions.
29 changes: 18 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,34 @@ $ npm i @libp2p/mdns

## Usage

```JavaScript
import { MDNS } from '@libp2p/mdns'
```Typescript
import { mdns } from '@libp2p/mdns'

const mdns = new MDNS(options)
const options = {
peerDiscovery: [
mdns()
]
}

async function start () {
const libp2p = await createLibp2p(options)

mdns.on('peer', (peerData) => {
console.log('Found a peer in the local network', peerData.id.toString(), peerData.multiaddrs)
})
libp2p.on('peer:discovery', function (peerId) {
console.log('found peer: ', peerId.toB58String())
})

await libp2p.start()
}

// Broadcast for 20 seconds
mdns.start()
setTimeout(() => mdns.stop(), 20 * 1000)
```

- options
- `peerId` - PeerId to announce
- `peerName` - Peer name to announce (should not be peeer id), default random string
- `multiaddrs` - multiaddrs to announce
- `broadcast` - (true/false) announce our presence through mDNS, default `false`
- `interval` - query interval, default 10 \* 1000 (10 seconds)
- `serviceTag` - name of the service announce , default 'ipfs.local\`
- `compat` - enable/disable compatibility with go-libp2p-mdns, default `true`


## MDNS messages

Expand Down
24 changes: 11 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,24 +135,22 @@
"docs": "aegir docs"
},
"dependencies": {
"@libp2p/interface-peer-discovery": "^1.0.1",
"@libp2p/interface-peer-id": "^2.0.0",
"@libp2p/interface-peer-info": "^1.0.3",
"@libp2p/interfaces": "^3.0.3",
"@libp2p/logger": "^2.0.1",
"@libp2p/peer-id": "^2.0.0",
"@multiformats/multiaddr": "^11.0.0",
"@libp2p/interface-peer-discovery": "^1.0.5",
"@libp2p/interface-peer-id": "^2.0.1",
"@libp2p/interface-peer-info": "^1.0.8",
"@libp2p/interfaces": "^3.3.1",
"@libp2p/logger": "^2.0.5",
"@libp2p/peer-id": "^2.0.1",
"@multiformats/multiaddr": "^11.0.7",
"@types/multicast-dns": "^7.2.1",
"dns-packet": "^5.4.0",
"multicast-dns": "^7.2.0"
"multicast-dns": "^7.2.5",
"dns-packet": "^5.4.0"
},
"devDependencies": {
"@libp2p/interface-address-manager": "^2.0.0",
"@libp2p/interface-peer-discovery-compliance-tests": "^2.0.0",
"@libp2p/interface-address-manager": "^2.0.1",
"@libp2p/interface-peer-discovery-compliance-tests": "^2.0.1",
"@libp2p/peer-id-factory": "^2.0.0",
"aegir": "^38.1.2",
"delay": "^5.0.0",
"p-defer": "^4.0.0",
"p-wait-for": "^5.0.0",
"ts-sinon": "^2.0.2"
}
Expand Down
4 changes: 0 additions & 4 deletions src/compat/constants.ts

This file was deleted.

71 changes: 0 additions & 71 deletions src/compat/index.ts

This file was deleted.

171 changes: 0 additions & 171 deletions src/compat/querier.ts

This file was deleted.

Loading

0 comments on commit 5edcc16

Please sign in to comment.