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

Commit 01f58e1

Browse files
dmitriy ryajovdryajov
dmitriy ryajov
authored andcommitted
feat: initial implementation of circuit relaying
chore: adding default readme feat: reworking as a transport feat: getting peers communicating over relay (wip) feat: address in swarm [wip] feat: adding onion dial feat: adding onion dialing and tests feat: make circuit a full fledged transport refactor: split transport dialer and circuit logic test: adding dial tests feat: adding passive/active dialing test test: adding relay tests fix: several isues feat: consolidate and cleanup dialing feat: handle listenning circuit addresses correctly feat: make utils a factory feat: adding StreamHandler to aid with pull-stream read/write refactor: clean up and refactor relay and listener tests: adding more relay and listener tests tests: moving long multiaddr to a fixture
1 parent b2bd6c9 commit 01f58e1

24 files changed

+2067
-2
lines changed

.gitignore

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Runtime data
7+
pids
8+
*.pid
9+
*.seed
10+
11+
# Directory for instrumented libs generated by jscoverage/JSCover
12+
lib-cov
13+
14+
# Coverage directory used by tools like istanbul
15+
coverage
16+
17+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
18+
.grunt
19+
20+
# node-waf configuration
21+
.lock-wscript
22+
23+
# Compiled binary addons (http://nodejs.org/api/addons.html)
24+
build/Release
25+
26+
# Dependency directory
27+
node_modules
28+
29+
# Optional npm cache directory
30+
.npm
31+
32+
# Optional REPL history
33+
.node_repl_history
34+
35+
# Vim editor swap files
36+
*.swp
37+
38+
dist
39+
40+
.history
41+
.vscode

.npmignore

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
test
2+
3+
# Logs
4+
logs
5+
*.log
6+
npm-debug.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
13+
# Directory for instrumented libs generated by jscoverage/JSCover
14+
lib-cov
15+
16+
# Coverage directory used by tools like istanbul
17+
coverage
18+
19+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
20+
.grunt
21+
22+
# node-waf configuration
23+
.lock-wscript
24+
25+
# Compiled binary addons (http://nodejs.org/api/addons.html)
26+
build/Release
27+
28+
# Dependency directory
29+
node_modules
30+
31+
# Optional npm cache directory
32+
.npm
33+
34+
# Optional REPL history
35+
.node_repl_history

.travis.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
sudo: false
2+
language: node_js
3+
4+
matrix:
5+
include:
6+
- node_js: 4
7+
env: CXX=g++-4.8
8+
- node_js: 6
9+
env:
10+
- SAUCE=true
11+
- CXX=g++-4.8
12+
- node_js: "stable"
13+
env:
14+
- CXX=g++-4.8
15+
16+
# Make sure we have new NPM.
17+
before_install:
18+
- npm install -g npm
19+
20+
script:
21+
- npm run lint
22+
- npm test
23+
- npm run coverage
24+
25+
before_script:
26+
- export DISPLAY=:99.0
27+
- sh -e /etc/init.d/xvfb start
28+
29+
after_success:
30+
- npm run coverage-publish
31+
32+
addons:
33+
firefox: latest
34+
apt:
35+
sources:
36+
- ubuntu-toolchain-r-test
37+
packages:
38+
- g++-4.8

README.md

+38-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,38 @@
1-
# js-libp2p-circuit
2-
Circuit Switching for libp2p
1+
# <topic>
2+
3+
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)
4+
[![](https://img.shields.io/badge/project-libp2p-blue.svg?style=flat-square)](http://github.com/libp2p/libp2p)
5+
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
6+
[![](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
7+
8+
> <description>
9+
10+
<long description>
11+
12+
## Table of Contents
13+
14+
<ToC>
15+
16+
## Install
17+
18+
<install>
19+
20+
## Usage
21+
22+
<usage>
23+
24+
## Lead
25+
26+
- [<lead>](https://github.com/<lead>)
27+
28+
## Contribute
29+
30+
Please contribute! [Look at the issues](https://github.com/libp2p/<repoName>/issues)!
31+
32+
Check out our [contributing document](https://github.com/libp2p/community/blob/master/CONTRIBUTE.md) for more information on how we work, and about contributing in general. Please be aware that all interactions related to libp2p are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
33+
34+
Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
35+
36+
## License
37+
38+
[MIT](LICENSE) © 2016 Protocol Labs Inc.

circle.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
machine:
2+
node:
3+
version: stable
4+
5+
dependencies:
6+
pre:
7+
- google-chrome --version
8+
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
9+
- sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
10+
- sudo apt-get update
11+
- sudo apt-get --only-upgrade install google-chrome-stable
12+
- google-chrome --version

package.json

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"name": "libp2p-circuit",
3+
"version": "0.0.2",
4+
"description": "JavaScript implementation of circuit/switch relaying",
5+
"main": "src/index.js",
6+
"scripts": {
7+
"lint": "aegir-lint",
8+
"build": "aegir-build",
9+
"test": "aegir-test --env node",
10+
"release": "aegir-release",
11+
"release-minor": "aegir-release --type minor",
12+
"release-major": "aegir-release --type major",
13+
"coverage": "aegir-coverage",
14+
"coverage-publish": "aegir-coverage publish"
15+
},
16+
"pre-commit": [
17+
"lint",
18+
"test"
19+
],
20+
"repository": {
21+
"type": "git",
22+
"url": "git+https://github.com/libp2p/js-libp2p-circuit.git"
23+
},
24+
"keywords": [
25+
"IPFS"
26+
],
27+
"author": "Dmitriy Ryajov <[email protected]>",
28+
"license": "MIT",
29+
"bugs": {
30+
"url": "https://github.com/libp2p/js-libp2p-circuit/issues"
31+
},
32+
"homepage": "https://github.com/libp2p/js-libp2p-circuit#readme",
33+
"eslintConfig": {
34+
"extends": [
35+
"./node_modules/aegir/config/eslintrc.yml"
36+
],
37+
"rules": {
38+
"strict": "off"
39+
}
40+
},
41+
"devDependencies": {
42+
"aegir": "^10.0.0",
43+
"chai": "^3.5.0",
44+
"multihashes": "^0.4.5",
45+
"pre-commit": "^1.2.2",
46+
"proxyquire": "^1.7.11",
47+
"pull-pushable": "^2.0.1",
48+
"sinon": "^2.1.0"
49+
},
50+
"contributors": [],
51+
"dependencies": {
52+
"async": "^2.1.5",
53+
"debug": "^2.6.1",
54+
"interface-connection": "^0.3.1",
55+
"lodash": "^4.17.4",
56+
"multiaddr": "^2.2.1",
57+
"multistream-select": "^0.13.4",
58+
"peer-id": "^0.8.2",
59+
"peer-info": "^0.8.3",
60+
"pull-abortable": "^4.1.0",
61+
"pull-handshake": "^1.1.4",
62+
"pull-stream": "^3.5.0",
63+
"safe-buffer": "^5.0.1",
64+
"setimmediate": "^1.0.5"
65+
}
66+
}

src/circuit/constants.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
'use strict'
2+
3+
module.exports = {
4+
PRIOIRY: 100,
5+
DIALER: {
6+
ONION: 'onion',
7+
TELESCOPE: 'telescope'
8+
},
9+
RESPONSE: {
10+
SUCCESS: 100,
11+
FAILURE: 500,
12+
HOP: {
13+
SRC_ADDR_TOO_LONG: 220,
14+
DST_ADDR_TOO_LONG: 221,
15+
SRC_MULTIADDR_INVALID: 250,
16+
DST_MULTIADDR_INVALID: 251,
17+
NO_CONN_TO_DST: 260,
18+
CANT_DIAL_DST: 261,
19+
CANT_OPEN_DST_STREAM: 262,
20+
CANT_SPEAK_RELAY: 270,
21+
CANT_CONNECT_TO_SELF: 280
22+
},
23+
STOP: {
24+
SRC_ADDR_TOO_LONG: 320,
25+
DST_ADDR_TOO_LONG: 321,
26+
SRC_MULTIADDR_INVALID: 350,
27+
DST_MULTIADDR_INVALID: 351
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)