This repository has been archived by the owner on Jun 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Use better codestyle and new ws-star
- Loading branch information
Showing
9 changed files
with
246 additions
and
15,367 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,39 @@ | ||
# File is synced from zeronet-js repo | ||
|
||
# Configs, etc. | ||
*.pem | ||
config.json | ||
|
||
# NodeJS | ||
node_modules | ||
coverage | ||
.nyc_output | ||
package-lock.json | ||
|
||
# aegir | ||
dist | ||
docs | ||
|
||
# pkg | ||
zeronet-linux* | ||
zeronet-macos* | ||
zeronet-win* | ||
.pkg | ||
|
||
# Other garbage | ||
*.bak | ||
*.log | ||
tmp | ||
/data | ||
.zeronet | ||
|
||
# Python | ||
*.pyc | ||
|
||
# snap | ||
parts | ||
prime | ||
stage | ||
*.tar.bz2 | ||
*.snap | ||
snap/.snapcraft |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,31 @@ | ||
language: node_js | ||
node_js: | ||
- "8" | ||
- "6" | ||
dist: trusty | ||
after_success: | ||
- npm run coverage-publish | ||
sudo: false | ||
language: node_js | ||
|
||
matrix: | ||
include: | ||
- node_js: 6 | ||
env: CXX=g++-4.8 | ||
- node_js: 8 | ||
env: CXX=g++-4.8 | ||
# - node_js: stable | ||
# env: CXX=g++-4.8 | ||
|
||
script: | ||
- npm run lint | ||
- npm run test | ||
- npm run coverage | ||
|
||
before_script: | ||
- export DISPLAY=:99.0 | ||
- sh -e /etc/init.d/xvfb start | ||
|
||
after_success: | ||
- npm run coverage-publish | ||
|
||
addons: | ||
firefox: 'latest' | ||
apt: | ||
sources: | ||
- ubuntu-toolchain-r-test | ||
packages: | ||
- g++-4.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
version: "{build}" | ||
|
||
environment: | ||
matrix: | ||
- nodejs_version: "6" | ||
- nodejs_version: "8" | ||
|
||
matrix: | ||
fast_finish: true | ||
|
||
install: | ||
# Install Node.js | ||
- ps: Install-Product node $env:nodejs_version | ||
|
||
# Upgrade npm | ||
- npm install -g npm | ||
|
||
# Output our current versions for debugging | ||
- node --version | ||
- npm --version | ||
|
||
# Install our package dependencies | ||
- npm install | ||
|
||
test_script: | ||
- npm run test:node | ||
|
||
build: off |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
'use strict' | ||
|
||
const Libp2p = require('libp2p') | ||
const Id = require('peer-id') | ||
const Info = require('peer-info') | ||
const multiaddr = require('multiaddr') | ||
const pull = require('pull-stream') | ||
|
||
const WSStarMulti = require('libp2p-websocket-star-multi') | ||
|
||
Id.create((err, id) => { | ||
if (err) throw err | ||
|
||
const peerInfo = new Info(id) | ||
peerInfo.multiaddrs.add(multiaddr('/p2p-websocket-star')) // will get replaced to the multiaddr of the individual servers | ||
const ws = new WSStarMulti({ | ||
servers: [ // servers are Multiaddr[] | ||
'/dns/ws-star-signal-1.servep2p.com/tcp/443/wss/p2p-websocket-star', | ||
'/dns/ws-star-signal-2.servep2p.com/tcp/443/wss/p2p-websocket-star', | ||
'/dns/ws-star-signal-3.servep2p.com/tcp/443/wss/p2p-websocket-star', | ||
'/dns/ws-star-signal-4.servep2p.com/tcp/443/wss/p2p-websocket-star', | ||
'/dns/ws-star.discovery.libp2p.io/tcp/443/wss/p2p-websocket-star', | ||
'/dns4/localhost/tcp/80/ws/p2p-websocket-star' | ||
], | ||
// ignore_no_online: true, // enable this to prevent wstar-multi from returning a listen error if no servers are online | ||
id // the id is required for the crypto challenge | ||
}) | ||
|
||
const modules = { | ||
transport: [ | ||
ws | ||
], | ||
discovery: [ | ||
ws.discovery | ||
] | ||
} | ||
|
||
const node = new Libp2p(modules, peerInfo) | ||
|
||
node.handle('/test/1.0.0', (protocol, conn) => { | ||
pull( | ||
pull.values(['hello']), | ||
conn, | ||
pull.map((s) => s.toString()), | ||
pull.log() | ||
) | ||
}) | ||
|
||
node.start((err) => { | ||
if (err) { | ||
throw err | ||
} | ||
|
||
node.dial(peerInfo, '/test/1.0.0', (err, conn) => { | ||
if (err) { | ||
throw err | ||
} | ||
|
||
pull( | ||
pull.values(['hello from the other side']), | ||
conn, | ||
pull.map((s) => s.toString()), | ||
pull.log() | ||
) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.