Skip to content
This repository was archived by the owner on Aug 29, 2023. It is now read-only.

Commit 5009c2c

Browse files
authored
feat: listen to array of multiaddrs (#104)
* feat: support listen on array * chore: fix missing deps * chore: update interface version * docs: update readme for array listen * test: use port 0 * docs: add some more jsdocs * chore: fix travis support for ip6 on linux * refactor: clean up some code
1 parent 1ffd549 commit 5009c2c

File tree

7 files changed

+215
-124
lines changed

7 files changed

+215
-124
lines changed

.travis.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,23 @@ stages:
99
node_js:
1010
- '10'
1111

12-
os:
13-
- linux
14-
- osx
15-
1612
script: npx nyc -s npm run test:node -- --bail
1713
after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov
1814

1915
jobs:
2016
include:
17+
- os: linux
18+
sudo: false
19+
before_script: sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6'
20+
2121
- os: windows
2222
filter_secrets: false
2323
cache: false
2424

25+
- os: osx
26+
2527
- stage: check
28+
os: linux
2629
script:
2730
- npx aegir build --bundlesize
2831
- npx aegir commitlint --travis

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const multiaddr = require('multiaddr')
4444
const pipe = require('it-pipe')
4545
const { collect } = require('streaming-iterables')
4646

47-
const mh = multiaddr('/ip4/127.0.0.1/tcp/9090')
47+
const addr = multiaddr('/ip4/127.0.0.1/tcp/9090')
4848

4949
const tcp = new TCP()
5050

@@ -56,10 +56,10 @@ const listener = tcp.createListener((socket) => {
5656
)
5757
})
5858

59-
await listener.listen(mh)
59+
await listener.listen([addr])
6060
console.log('listening')
6161

62-
const socket = await tcp.dial(mh)
62+
const socket = await tcp.dial(addr)
6363
const values = await pipe(
6464
socket,
6565
collect

package.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,24 @@
4040
"aegir": "^18.1.1",
4141
"chai": "^4.1.2",
4242
"dirty-chai": "^2.0.1",
43-
"interface-transport": "~0.3.6",
4443
"lodash.isfunction": "^3.0.9",
4544
"pull-stream": "^3.6.9",
4645
"sinon": "^7.3.1"
4746
},
4847
"dependencies": {
4948
"abort-controller": "^3.0.0",
5049
"class-is": "^1.1.0",
51-
"debug": "^3.1.0",
50+
"debug": "^4.1.1",
5251
"err-code": "^1.1.2",
5352
"interface-connection": "~0.3.3",
54-
"interface-transport": "libp2p/interface-transport#feat/async-await",
53+
"interface-transport": "~0.4.0",
5554
"ip-address": "^5.8.9",
55+
"it-pipe": "^1.0.0",
5656
"lodash.includes": "^4.3.0",
5757
"lodash.isfunction": "^3.0.9",
58-
"mafmt": "^6.0.2",
59-
"multiaddr": "^5.0.0"
58+
"mafmt": "^6.0.7",
59+
"multiaddr": "^6.0.6",
60+
"streaming-iterables": "^4.1.0"
6061
},
6162
"contributors": [
6263
"Alan Shaw <[email protected]>",

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class TCP {
7878
}
7979

8080
handler = handler || noop
81-
return createListener(handler)
81+
return createListener(options, handler)
8282
}
8383

8484
filter (multiaddrs) {

0 commit comments

Comments
 (0)