Skip to content
This repository was archived by the owner on Feb 26, 2021. It is now read-only.

Commit 0cdd57d

Browse files
committed
misc: merge js-libp2p-websocket-star-rendezvous into server/ (fix #73)
2 parents c843e9d + f72cfb1 commit 0cdd57d

16 files changed

+1148
-0
lines changed

server/.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package-lock.json
2+
yarn.lock
3+
4+
**/node_modules
5+
**/*.log
6+
test/setup/tmp-disposable-nodes-addrs.json
7+
dist
8+
coverage
9+
.nyc_output
10+
**/*.swp
11+
**/*.bak
12+
examples/sub-module/**/bundle.js
13+
examples/sub-module/**/*-minified.js
14+
examples/sub-module/*-bundle.js
15+
docs

server/.travis.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
language: node_js
2+
cache: npm
3+
stages:
4+
- check
5+
- test
6+
- cov
7+
8+
node_js:
9+
- '10'
10+
11+
os:
12+
- linux
13+
- osx
14+
- windows
15+
16+
script: npx nyc -s npm run test:node -- --bail
17+
after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov
18+
19+
jobs:
20+
include:
21+
- stage: check
22+
script:
23+
- npx aegir commitlint --travis
24+
- npx aegir dep-check -- -i wrtc -i electron-webrtc
25+
- npm run lint
26+
27+
notifications:
28+
email: false

server/CHANGELOG.md

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<a name="0.4.0"></a>
2+
# [0.4.0](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/compare/v0.3.0...v0.4.0) (2019-07-19)
3+
4+
5+
### Features
6+
7+
* switches to async/await and upgrade hapi to v18 ([946e8a1](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/946e8a1))
8+
9+
10+
### BREAKING CHANGES
11+
12+
* All functions that took callbacks now return promises
13+
14+
15+
16+
<a name="0.3.0"></a>
17+
# [0.3.0](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/compare/v0.2.4...v0.3.0) (2018-11-29)
18+
19+
20+
### Bug Fixes
21+
22+
* dont use 'this' in root anon function ([c6a833e](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/c6a833e))
23+
* logo was broken on main page ([#25](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/issues/25)) ([41eed04](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/41eed04))
24+
* regex bug for ipv4 test ([#24](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/issues/24)) ([696ed92](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/696ed92))
25+
* remove warning for too many listeners on socket.io sockets ([#28](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/issues/28)) ([3d9b96e](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/3d9b96e))
26+
27+
28+
### Features
29+
30+
* include existing peers in response to ss-join ([f12aea3](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/f12aea3))
31+
* use node 10 in docker image ([#26](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/issues/26)) ([91db9cf](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/91db9cf))
32+
33+
34+
35+
<a name="0.2.4"></a>
36+
## [0.2.4](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/compare/v0.2.3...v0.2.4) (2018-10-16)
37+
38+
39+
### Bug Fixes
40+
41+
* give crypto.verify a buffer ([#23](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/issues/23)) ([0c8c290](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/0c8c290))
42+
* make it executable available through websocket-star ([d18087c](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/d18087c))
43+
44+
45+
46+
<a name="0.2.3"></a>
47+
## [0.2.3](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/compare/v0.2.2...v0.2.3) (2018-02-12)
48+
49+
50+
51+
<a name="0.2.2"></a>
52+
## [0.2.2](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/compare/v0.2.1...v0.2.2) (2017-12-07)
53+
54+
55+
### Features
56+
57+
* Add libp2p logo to about page ([66be194](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/66be194))
58+
* cryptoChallenge can be enabled by default after all! https://github.com/ipfs/js-ipfs/pull/1090/files\#r153143252 ([143a0a4](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/143a0a4))
59+
60+
61+
62+
<a name="0.2.1"></a>
63+
## [0.2.1](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/compare/v0.2.0...v0.2.1) (2017-11-19)
64+
65+
66+
### Bug Fixes
67+
68+
* Docker cmd - feat: Disable metrics option ([21f95d2](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/21f95d2))
69+
* release command ([37e5b1f](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/37e5b1f))
70+
71+
72+
73+
<a name="0.2.0"></a>
74+
# [0.2.0](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/compare/v0.1.2...v0.2.0) (2017-10-28)
75+
76+
77+
### Bug Fixes
78+
79+
* {webrtc => websocket} ([df53c25](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/df53c25))
80+
* discovery fix - fix: debug log name ([1f163b8](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/1f163b8))
81+
* lint ([585525e](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/585525e))
82+
* package.json ([f5e91fe](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/f5e91fe))
83+
* small name fix ([de84807](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/de84807))
84+
85+
86+
### Features
87+
88+
* Joins metric - fix: config ([81c8eb7](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/81c8eb7))
89+
* Link directly to readme in about page ([d7fba03](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/d7fba03))
90+
* metrics (WIP) - feat: Dockerfile - fix/feat: various other things ([fa518b1](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/fa518b1))
91+
* Update README - feat: Use dumb-init in docker-image ([4fbed33](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/4fbed33))
92+
93+
94+
95+
<a name="0.1.2"></a>
96+
## [0.1.2](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/compare/v0.1.1...v0.1.2) (2017-09-08)
97+
98+
99+
### Bug Fixes
100+
101+
* point to right location of bin ([3049ca8](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/3049ca8))
102+
103+
104+
105+
<a name="0.1.1"></a>
106+
## [0.1.1](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/compare/v0.1.0...v0.1.1) (2017-09-08)
107+
108+
109+
### Bug Fixes
110+
111+
* add main to package.json ([7ff704c](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/7ff704c))
112+
113+
114+
115+
<a name="0.1.0"></a>
116+
# 0.1.0 (2017-09-08)
117+
118+
119+

server/DEPLOYMENT.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Deployment
2+
3+
## IPFS Infra
4+
5+
We have a [dokku](https://github.com/ipfs/ops-requests/issues/31) setup ready for this to be deployed, to deploy simple do (you have to have permission first):
6+
7+
```sh
8+
# if you already have added the remote, you don't need to do it again
9+
> git remote add dokku [email protected]:ws-star
10+
> git push dokku master
11+
```
12+
13+
More info: https://github.com/libp2p/js-libp2p-webrtc-star/pull/48
14+
15+
## Other
16+
17+
# mkg20001
18+
The nodes `ws-star-signal-{2,4,h}.servep2p.com` run on `host0.zion.host`
19+
20+
Upgrades are done by running `bash /home/maciej/upgrade-rendezvous.sh` which runs docker pull and re-creates the containers

server/Dockerfile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM node:10
2+
RUN wget -O /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 && chmod +x /usr/local/bin/dumb-init
3+
WORKDIR /usr/src/app
4+
COPY package.json .
5+
RUN npm i --production
6+
COPY . .
7+
ENTRYPOINT ["/usr/local/bin/dumb-init", "node", "--max-old-space-size=8192", "src/bin.js"]

server/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 libp2p
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

server/Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: npm run start

server/README.md

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# libp2p-websocket-star-rendezvous
2+
3+
[![](https://img.shields.io/badge/made%20by-mkg20001-blue.svg?style=flat-square)](http://ipn.io)
4+
[![](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
5+
[![](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p)
6+
[![Discourse posts](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg)](https://discuss.libp2p.io)
7+
[![](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-websocket-star-rendezvous.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-websocket-star-rendezvous)
8+
[![](https://img.shields.io/travis/libp2p/js-libp2p-websocket-star-rendezvous.svg?style=flat-square)](https://travis-ci.com/libp2p/js-libp2p-websocket-star-rendezvous)
9+
[![Dependency Status](https://david-dm.org/libp2p/js-libp2p-websocket-star-rendezvous.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-websocket-star-rendezvous)
10+
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
11+
12+
> The rendezvous service for [libp2p-websocket-star](https://github.com/libp2p/js-libp2p-websocket-star).
13+
14+
## Lead Maintainer
15+
16+
[Jacob Heun](https://github.com/jacobheun)
17+
18+
## Descriptions
19+
20+
Nodes using `libp2p-websocket-star` will connect to a known point in the network, a rendezvous point where they can learn about other nodes (Discovery) and route their messages to other nodes (2 hop message routing, also known as relay).
21+
22+
## Usage
23+
24+
`libp2p-websocket-star-rendezvous` is the rendezvous server required for `libp2p-websocket-star` and can be used to start a rendezvous server for development. To do that, first install the module globally in your machine with:
25+
26+
```bash
27+
> npm install --global libp2p-websocket-star-rendezvous
28+
```
29+
30+
This will install a `rendezvous` CLI tool. Now you can spawn the server with:
31+
32+
```bash
33+
> rendezvous --port=9090 --host=127.0.0.1
34+
```
35+
36+
Defaults:
37+
38+
- `port` - 9090
39+
- `host` - '0.0.0.0'
40+
41+
## Docker
42+
43+
A docker image is offered for running this service in production
44+
45+
```
46+
docker pull libp2p/websocket-star-rendezvous:release
47+
docker run -d -p 9090:9090 --name rendezvous libp2p/websocket-star-rendezvous:release
48+
```
49+
50+
To disable prometheus metrics run the server with `-e DISABLE_METRICS=1`
51+
52+
```
53+
docker run -d -p 9090:9090 --name rendezvous -e DISABLE_METRICS=1 libp2p/websocket-star-rendezvous:release
54+
```
55+
56+
## Hosted Rendezvous server
57+
58+
We host a rendezvous server at `ws-star.discovery.libp2p.io` that can be used for practical demos and experimentation, it **should not be used for apps in production**.
59+
60+
A libp2p-websocket-star address, using the signalling server we provide, looks like:
61+
62+
`/dns4/ws-star.discovery.libp2p.io/wss/p2p-websocket-star/ipfs/<your-peer-id>`
63+
64+
Note: The address above indicates WebSockets Secure, which can be accessed from both http and https.
65+
66+
67+
### Using WSS
68+
69+
To be able to interact with a rendezvous server from an HTTPS site, you will need to use websocket secure. To host a secure websocket server, you must provide a keypair to the server.
70+
71+
#### Using key and certificate
72+
73+
```bash
74+
> rendezvous --key="path/to/key.key" --cert="path/to/cert.cert"
75+
```
76+
77+
#### Using PFX with passphrase
78+
79+
```bash
80+
> rendezvous --pfx="path/to/pair.pfx" --passphrase="passphrase"
81+
```
82+
83+
84+
### This module uses `pull-streams`
85+
86+
We expose a streaming interface based on `pull-streams`, rather then on the Node.js core streams implementation (aka Node.js streams). `pull-streams` offers us a better mechanism for error handling and flow control guarantees. If you would like to know more about why we did this, see the discussion at this [issue](https://github.com/ipfs/js-ipfs/issues/362).
87+
88+
You can learn more about pull-streams at:
89+
90+
- [The history of Node.js streams, nodebp April 2014](https://www.youtube.com/watch?v=g5ewQEuXjsQ)
91+
- [The history of streams, 2016](http://dominictarr.com/post/145135293917/history-of-streams)
92+
- [pull-streams, the simple streaming primitive](http://dominictarr.com/post/149248845122/pull-streams-pull-streams-are-a-very-simple)
93+
- [pull-streams documentation](https://pull-stream.github.io/)
94+
95+
#### Converting `pull-streams` to Node.js Streams
96+
97+
If you are a Node.js streams user, you can convert a pull-stream to a Node.js stream using the module [`pull-stream-to-stream`](https://github.com/pull-stream/pull-stream-to-stream), giving you an instance of a Node.js stream that is linked to the pull-stream. For example:
98+
99+
```js
100+
const pullToStream = require('pull-stream-to-stream')
101+
102+
const nodeStreamInstance = pullToStream(pullStreamInstance)
103+
// nodeStreamInstance is an instance of a Node.js Stream
104+
```
105+
106+
To learn more about this utility, visit https://pull-stream.github.io/#pull-stream-to-stream.
107+
108+
LICENSE MIT

0 commit comments

Comments
 (0)