@libp2p/mdns 10.0.15-e1c01370b → 10.0.15-f0d2b52d0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ # @libp2p/mdns
2
+
1
3
  [![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
2
4
  [![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
3
5
  [![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p)
@@ -7,77 +9,92 @@
7
9
 
8
10
  # About
9
11
 
12
+ <!--
13
+
14
+ !IMPORTANT!
15
+
16
+ Everything in this README between "# About" and "# Install" is automatically
17
+ generated and will be overwritten the next time the doc generator is run.
18
+
19
+ To make changes to this section, please update the @packageDocumentation section
20
+ of src/index.js or src/index.ts
21
+
22
+ To experiment with formatting, please run "npm run docs" from the root of this
23
+ repo and examine the changes made.
24
+
25
+ -->
26
+
10
27
  A peer discover mechanism that uses [mDNS](https://datatracker.ietf.org/doc/html/rfc6762) to discover peers on the local network.
11
28
 
12
- ## Example
29
+ ## Example - Use with libp2p
13
30
 
14
31
  ```TypeScript
32
+ import { createLibp2p } from 'libp2p'
15
33
  import { mdns } from '@libp2p/mdns'
16
34
 
17
- const options = {
35
+ const libp2p = await createLibp2p({
18
36
  peerDiscovery: [
19
37
  mdns()
20
38
  ]
21
- }
22
-
23
- const libp2p = await createLibp2p(options)
24
-
25
- libp2p.on('peer:discovery', function (peerId) {
26
- console.log('found peer: ', peerId.toB58String())
27
39
  })
28
40
 
29
- await libp2p.start()
41
+ libp2p.addEventListener('peer:discovery', (evt) => {
42
+ console.log('found peer: ', evt.detail.toString())
43
+ })
30
44
  ```
31
45
 
32
46
  ## MDNS messages
33
47
 
34
48
  A query is sent to discover the libp2p nodes on the local network
35
49
 
36
- ```js
50
+ ```JSON
37
51
  {
38
- type: 'query',
39
- questions: [ { name: '_p2p._udp.local', type: 'PTR' } ]
52
+ "type": "query",
53
+ "questions": [{
54
+ "name": "_p2p._udp.local",
55
+ "type": "PTR"
56
+ }]
40
57
  }
41
58
  ```
42
59
 
43
60
  When a query is detected, each libp2p node sends an answer about itself
44
61
 
45
- ```js
62
+ ```JSON
46
63
  [{
47
- name: '_p2p._udp.local',
48
- type: 'PTR',
49
- class: 'IN',
50
- ttl: 120,
51
- data: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local'
64
+ "name": "_p2p._udp.local",
65
+ "type": "PTR",
66
+ "class": "IN",
67
+ "ttl": 120,
68
+ "data": "QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local"
52
69
  }, {
53
- name: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local',
54
- type: 'SRV',
55
- class: 'IN',
56
- ttl: 120,
57
- data: {
58
- priority: 10,
59
- weight: 1,
60
- port: '20002',
61
- target: 'LAPTOP-G5LJ7VN9'
70
+ "name": "QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local",
71
+ "type": "SRV",
72
+ "class": "IN",
73
+ "ttl": 120,
74
+ "data": {
75
+ "priority": 10,
76
+ "weight": 1,
77
+ "port": "20002",
78
+ "target": "LAPTOP-G5LJ7VN9"
62
79
  }
63
80
  }, {
64
- name: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local',
65
- type: 'TXT',
66
- class: 'IN',
67
- ttl: 120,
68
- data: ['QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK']
81
+ "name": "QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local",
82
+ "type": "TXT",
83
+ "class": "IN",
84
+ "ttl": 120,
85
+ "data": ["QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK"]
69
86
  }, {
70
- name: 'LAPTOP-G5LJ7VN9',
71
- type: 'A',
72
- class: 'IN',
73
- ttl: 120,
74
- data: '127.0.0.1'
87
+ "name": "LAPTOP-G5LJ7VN9",
88
+ "type": "A",
89
+ "class": "IN",
90
+ "ttl": 120,
91
+ "data": "127.0.0.1"
75
92
  }, {
76
- name: 'LAPTOP-G5LJ7VN9',
77
- type: 'AAAA',
78
- class: 'IN',
79
- ttl: 120,
80
- data: '::1'
93
+ "name": "LAPTOP-G5LJ7VN9",
94
+ "type": "AAAA",
95
+ "class": "IN",
96
+ "ttl": 120,
97
+ "data": "::1"
81
98
  }]
82
99
  ```
83
100
 
@@ -3,75 +3,75 @@
3
3
  *
4
4
  * A peer discover mechanism that uses [mDNS](https://datatracker.ietf.org/doc/html/rfc6762) to discover peers on the local network.
5
5
  *
6
- * @example
6
+ * @example Use with libp2p
7
7
  *
8
8
  * ```TypeScript
9
+ * import { createLibp2p } from 'libp2p'
9
10
  * import { mdns } from '@libp2p/mdns'
10
11
  *
11
- * const options = {
12
+ * const libp2p = await createLibp2p({
12
13
  * peerDiscovery: [
13
14
  * mdns()
14
15
  * ]
15
- * }
16
- *
17
- * const libp2p = await createLibp2p(options)
18
- *
19
- * libp2p.on('peer:discovery', function (peerId) {
20
- * console.log('found peer: ', peerId.toB58String())
21
16
  * })
22
17
  *
23
- * await libp2p.start()
18
+ * libp2p.addEventListener('peer:discovery', (evt) => {
19
+ * console.log('found peer: ', evt.detail.toString())
20
+ * })
24
21
  * ```
25
22
  *
26
23
  * ## MDNS messages
27
24
  *
28
25
  * A query is sent to discover the libp2p nodes on the local network
29
26
  *
30
- * ```js
27
+ * ```JSON
31
28
  * {
32
- * type: 'query',
33
- * questions: [ { name: '_p2p._udp.local', type: 'PTR' } ]
29
+ * "type": "query",
30
+ * "questions": [{
31
+ * "name": "_p2p._udp.local",
32
+ * "type": "PTR"
33
+ * }]
34
34
  * }
35
35
  * ```
36
36
  *
37
37
  * When a query is detected, each libp2p node sends an answer about itself
38
38
  *
39
- * ```js
39
+ * ```JSON
40
40
  * [{
41
- * name: '_p2p._udp.local',
42
- * type: 'PTR',
43
- * class: 'IN',
44
- * ttl: 120,
45
- * data: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local'
41
+ * "name": "_p2p._udp.local",
42
+ * "type": "PTR",
43
+ * "class": "IN",
44
+ * "ttl": 120,
45
+ * "data": "QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local"
46
46
  * }, {
47
- * name: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local',
48
- * type: 'SRV',
49
- * class: 'IN',
50
- * ttl: 120,
51
- * data: {
52
- * priority: 10,
53
- * weight: 1,
54
- * port: '20002',
55
- * target: 'LAPTOP-G5LJ7VN9'
47
+ * "name": "QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local",
48
+ * "type": "SRV",
49
+ * "class": "IN",
50
+ * "ttl": 120,
51
+ * "data": {
52
+ * "priority": 10,
53
+ * "weight": 1,
54
+ * "port": "20002",
55
+ * "target": "LAPTOP-G5LJ7VN9"
56
56
  * }
57
57
  * }, {
58
- * name: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local',
59
- * type: 'TXT',
60
- * class: 'IN',
61
- * ttl: 120,
62
- * data: ['QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK']
58
+ * "name": "QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local",
59
+ * "type": "TXT",
60
+ * "class": "IN",
61
+ * "ttl": 120,
62
+ * "data": ["QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK"]
63
63
  * }, {
64
- * name: 'LAPTOP-G5LJ7VN9',
65
- * type: 'A',
66
- * class: 'IN',
67
- * ttl: 120,
68
- * data: '127.0.0.1'
64
+ * "name": "LAPTOP-G5LJ7VN9",
65
+ * "type": "A",
66
+ * "class": "IN",
67
+ * "ttl": 120,
68
+ * "data": "127.0.0.1"
69
69
  * }, {
70
- * name: 'LAPTOP-G5LJ7VN9',
71
- * type: 'AAAA',
72
- * class: 'IN',
73
- * ttl: 120,
74
- * data: '::1'
70
+ * "name": "LAPTOP-G5LJ7VN9",
71
+ * "type": "AAAA",
72
+ * "class": "IN",
73
+ * "ttl": 120,
74
+ * "data": "::1"
75
75
  * }]
76
76
  * ```
77
77
  */
package/dist/src/index.js CHANGED
@@ -3,75 +3,75 @@
3
3
  *
4
4
  * A peer discover mechanism that uses [mDNS](https://datatracker.ietf.org/doc/html/rfc6762) to discover peers on the local network.
5
5
  *
6
- * @example
6
+ * @example Use with libp2p
7
7
  *
8
8
  * ```TypeScript
9
+ * import { createLibp2p } from 'libp2p'
9
10
  * import { mdns } from '@libp2p/mdns'
10
11
  *
11
- * const options = {
12
+ * const libp2p = await createLibp2p({
12
13
  * peerDiscovery: [
13
14
  * mdns()
14
15
  * ]
15
- * }
16
- *
17
- * const libp2p = await createLibp2p(options)
18
- *
19
- * libp2p.on('peer:discovery', function (peerId) {
20
- * console.log('found peer: ', peerId.toB58String())
21
16
  * })
22
17
  *
23
- * await libp2p.start()
18
+ * libp2p.addEventListener('peer:discovery', (evt) => {
19
+ * console.log('found peer: ', evt.detail.toString())
20
+ * })
24
21
  * ```
25
22
  *
26
23
  * ## MDNS messages
27
24
  *
28
25
  * A query is sent to discover the libp2p nodes on the local network
29
26
  *
30
- * ```js
27
+ * ```JSON
31
28
  * {
32
- * type: 'query',
33
- * questions: [ { name: '_p2p._udp.local', type: 'PTR' } ]
29
+ * "type": "query",
30
+ * "questions": [{
31
+ * "name": "_p2p._udp.local",
32
+ * "type": "PTR"
33
+ * }]
34
34
  * }
35
35
  * ```
36
36
  *
37
37
  * When a query is detected, each libp2p node sends an answer about itself
38
38
  *
39
- * ```js
39
+ * ```JSON
40
40
  * [{
41
- * name: '_p2p._udp.local',
42
- * type: 'PTR',
43
- * class: 'IN',
44
- * ttl: 120,
45
- * data: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local'
41
+ * "name": "_p2p._udp.local",
42
+ * "type": "PTR",
43
+ * "class": "IN",
44
+ * "ttl": 120,
45
+ * "data": "QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local"
46
46
  * }, {
47
- * name: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local',
48
- * type: 'SRV',
49
- * class: 'IN',
50
- * ttl: 120,
51
- * data: {
52
- * priority: 10,
53
- * weight: 1,
54
- * port: '20002',
55
- * target: 'LAPTOP-G5LJ7VN9'
47
+ * "name": "QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local",
48
+ * "type": "SRV",
49
+ * "class": "IN",
50
+ * "ttl": 120,
51
+ * "data": {
52
+ * "priority": 10,
53
+ * "weight": 1,
54
+ * "port": "20002",
55
+ * "target": "LAPTOP-G5LJ7VN9"
56
56
  * }
57
57
  * }, {
58
- * name: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local',
59
- * type: 'TXT',
60
- * class: 'IN',
61
- * ttl: 120,
62
- * data: ['QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK']
58
+ * "name": "QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local",
59
+ * "type": "TXT",
60
+ * "class": "IN",
61
+ * "ttl": 120,
62
+ * "data": ["QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK"]
63
63
  * }, {
64
- * name: 'LAPTOP-G5LJ7VN9',
65
- * type: 'A',
66
- * class: 'IN',
67
- * ttl: 120,
68
- * data: '127.0.0.1'
64
+ * "name": "LAPTOP-G5LJ7VN9",
65
+ * "type": "A",
66
+ * "class": "IN",
67
+ * "ttl": 120,
68
+ * "data": "127.0.0.1"
69
69
  * }, {
70
- * name: 'LAPTOP-G5LJ7VN9',
71
- * type: 'AAAA',
72
- * class: 'IN',
73
- * ttl: 120,
74
- * data: '::1'
70
+ * "name": "LAPTOP-G5LJ7VN9",
71
+ * "type": "AAAA",
72
+ * "class": "IN",
73
+ * "ttl": 120,
74
+ * "data": "::1"
75
75
  * }]
76
76
  * ```
77
77
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/mdns",
3
- "version": "10.0.15-e1c01370b",
3
+ "version": "10.0.15-f0d2b52d0",
4
4
  "description": "Node.js libp2p mDNS discovery implementation for peer discovery",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-mdns#readme",
@@ -43,26 +43,27 @@
43
43
  "clean": "aegir clean",
44
44
  "lint": "aegir lint",
45
45
  "dep-check": "aegir dep-check",
46
+ "doc-check": "aegir doc-check",
46
47
  "build": "aegir build",
47
48
  "test": "aegir test -t node",
48
49
  "test:node": "aegir test -t node --cov",
49
50
  "test:electron-main": "aegir test -t electron-main"
50
51
  },
51
52
  "dependencies": {
52
- "@libp2p/interface": "1.1.3-e1c01370b",
53
- "@libp2p/interface-internal": "1.0.8-e1c01370b",
54
- "@libp2p/peer-id": "4.0.6-e1c01370b",
55
- "@libp2p/utils": "5.2.5-e1c01370b",
53
+ "@libp2p/interface": "1.1.3-f0d2b52d0",
54
+ "@libp2p/interface-internal": "1.0.8-f0d2b52d0",
55
+ "@libp2p/peer-id": "4.0.6-f0d2b52d0",
56
+ "@libp2p/utils": "5.2.5-f0d2b52d0",
56
57
  "@multiformats/multiaddr": "^12.1.14",
57
58
  "@types/multicast-dns": "^7.2.4",
58
59
  "dns-packet": "^5.6.1",
59
60
  "multicast-dns": "^7.2.5"
60
61
  },
61
62
  "devDependencies": {
62
- "@libp2p/interface-compliance-tests": "5.3.1-e1c01370b",
63
- "@libp2p/logger": "4.0.6-e1c01370b",
64
- "@libp2p/peer-id-factory": "4.0.6-e1c01370b",
65
- "aegir": "^42.2.3",
63
+ "@libp2p/interface-compliance-tests": "5.3.1-f0d2b52d0",
64
+ "@libp2p/logger": "4.0.6-f0d2b52d0",
65
+ "@libp2p/peer-id-factory": "4.0.6-f0d2b52d0",
66
+ "aegir": "^42.2.4",
66
67
  "p-wait-for": "^5.0.2",
67
68
  "sinon-ts": "^2.0.0"
68
69
  },
package/src/index.ts CHANGED
@@ -3,75 +3,75 @@
3
3
  *
4
4
  * A peer discover mechanism that uses [mDNS](https://datatracker.ietf.org/doc/html/rfc6762) to discover peers on the local network.
5
5
  *
6
- * @example
6
+ * @example Use with libp2p
7
7
  *
8
8
  * ```TypeScript
9
+ * import { createLibp2p } from 'libp2p'
9
10
  * import { mdns } from '@libp2p/mdns'
10
11
  *
11
- * const options = {
12
+ * const libp2p = await createLibp2p({
12
13
  * peerDiscovery: [
13
14
  * mdns()
14
15
  * ]
15
- * }
16
- *
17
- * const libp2p = await createLibp2p(options)
18
- *
19
- * libp2p.on('peer:discovery', function (peerId) {
20
- * console.log('found peer: ', peerId.toB58String())
21
16
  * })
22
17
  *
23
- * await libp2p.start()
18
+ * libp2p.addEventListener('peer:discovery', (evt) => {
19
+ * console.log('found peer: ', evt.detail.toString())
20
+ * })
24
21
  * ```
25
22
  *
26
23
  * ## MDNS messages
27
24
  *
28
25
  * A query is sent to discover the libp2p nodes on the local network
29
26
  *
30
- * ```js
27
+ * ```JSON
31
28
  * {
32
- * type: 'query',
33
- * questions: [ { name: '_p2p._udp.local', type: 'PTR' } ]
29
+ * "type": "query",
30
+ * "questions": [{
31
+ * "name": "_p2p._udp.local",
32
+ * "type": "PTR"
33
+ * }]
34
34
  * }
35
35
  * ```
36
36
  *
37
37
  * When a query is detected, each libp2p node sends an answer about itself
38
38
  *
39
- * ```js
39
+ * ```JSON
40
40
  * [{
41
- * name: '_p2p._udp.local',
42
- * type: 'PTR',
43
- * class: 'IN',
44
- * ttl: 120,
45
- * data: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local'
41
+ * "name": "_p2p._udp.local",
42
+ * "type": "PTR",
43
+ * "class": "IN",
44
+ * "ttl": 120,
45
+ * "data": "QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local"
46
46
  * }, {
47
- * name: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local',
48
- * type: 'SRV',
49
- * class: 'IN',
50
- * ttl: 120,
51
- * data: {
52
- * priority: 10,
53
- * weight: 1,
54
- * port: '20002',
55
- * target: 'LAPTOP-G5LJ7VN9'
47
+ * "name": "QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local",
48
+ * "type": "SRV",
49
+ * "class": "IN",
50
+ * "ttl": 120,
51
+ * "data": {
52
+ * "priority": 10,
53
+ * "weight": 1,
54
+ * "port": "20002",
55
+ * "target": "LAPTOP-G5LJ7VN9"
56
56
  * }
57
57
  * }, {
58
- * name: 'QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local',
59
- * type: 'TXT',
60
- * class: 'IN',
61
- * ttl: 120,
62
- * data: ['QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK']
58
+ * "name": "QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK._p2p._udp.local",
59
+ * "type": "TXT",
60
+ * "class": "IN",
61
+ * "ttl": 120,
62
+ * "data": ["QmNPubsDWATVngE3d5WDSNe7eVrFLuk38qb9t6vdLnu2aK"]
63
63
  * }, {
64
- * name: 'LAPTOP-G5LJ7VN9',
65
- * type: 'A',
66
- * class: 'IN',
67
- * ttl: 120,
68
- * data: '127.0.0.1'
64
+ * "name": "LAPTOP-G5LJ7VN9",
65
+ * "type": "A",
66
+ * "class": "IN",
67
+ * "ttl": 120,
68
+ * "data": "127.0.0.1"
69
69
  * }, {
70
- * name: 'LAPTOP-G5LJ7VN9',
71
- * type: 'AAAA',
72
- * class: 'IN',
73
- * ttl: 120,
74
- * data: '::1'
70
+ * "name": "LAPTOP-G5LJ7VN9",
71
+ * "type": "AAAA",
72
+ * "class": "IN",
73
+ * "ttl": 120,
74
+ * "data": "::1"
75
75
  * }]
76
76
  * ```
77
77
  */