Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
feat: Circuit Relay (#1063)
Browse files Browse the repository at this point in the history
  • Loading branch information
dryajov authored and daviddias committed Mar 16, 2018
1 parent 9694925 commit f7eaa43
Show file tree
Hide file tree
Showing 19 changed files with 1,018 additions and 6 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,13 @@ const node = new IPFS({
EXPERIMENTAL: { // enable experimental features
pubsub: true,
sharding: true, // enable dir sharding
dht: true // enable KadDHT, currently not interopable with go-ipfs
dht: true, // enable KadDHT, currently not interopable with go-ipfs
relay: {
enabled: true, // enable circuit relay dialer and listener
hop: {
enabled: true // enable circuit relay HOP (make this node a relay)
}
}
},
config: { // overload the default IPFS node config, find defaults at https://github.com/ipfs/js-ipfs/tree/master/src/core/runtime
Addresses: {
Expand Down
2 changes: 2 additions & 0 deletions examples/circuit-relaying/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
.vscode/
349 changes: 349 additions & 0 deletions examples/circuit-relaying/README.md

Large diffs are not rendered by default.

Binary file added examples/circuit-relaying/img/img1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/circuit-relaying/img/img2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/circuit-relaying/img/img3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/circuit-relaying/img/img4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/circuit-relaying/img/img5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/circuit-relaying/img/img6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/circuit-relaying/img/img7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 61 additions & 0 deletions examples/circuit-relaying/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>IPFS simple messaging</title>
<meta name="description" content="Simple chat app on ipfs">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="./main.css">

<body>
<header>
<h1>IPFS Simple Messaging</h1>
</header>
<main>
<div class="columns box">
<div class="row">
<div class="box">
<label>Room (double click to change):</label>
<span id="room"></span>
<input type="text" id="room-id" style="display: none">
</div>
<div class="box msgs-box">
<ul id="msgs"></ul>
</div>
<div>
<label>message:</label>
<input type="text" id="message"></input>
<button id="send">Send</button>
</div>
</div>
<div class="row">
<div class="box peers-box">
<label>Peers Joined Room:</label>
<ul id="peers"></ul>
</div>
<div class="box peers-box">
<label>Peers Connected:</label>
<ul id="peers-addrs"></ul>
</div>
<div>
<label>Connect to Peer:</label>
<input type="text" id="peer"></input>
<button id="connect">Connect</button>
</div>
</div>
<div class="row">
<div class="box row">
<label>Peer id:</label>
<ul id="peer-id"></ul>
</div>
<div class="box addrs-box">
<label>Addresses:</label>
<ul id="addrs"></ul>
</div>
</div>
</div>
</main>
<script src="src/app.js"></script>
</body>

</html>
253 changes: 253 additions & 0 deletions examples/circuit-relaying/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
* {
box-sizing: border-box;
}

body {
height: 100%;
}

body {
font-family: sans-serif;
color: white;
background: linear-gradient(to bottom, #041727 0%, #062b3f 100%);
pointer-events: auto;
}

h1,
h2,
h3 {
margin: 0;
}

h1 {
font-size: 2em;
font-weight: 300;
}

h2 {
font-size: 1.25em;
font-weight: 700;
}

h3 {
font-size: 1.0em;
font-weight: 700;
}

main,
header {
filter: none;
}

.dragover-popup {
position: fixed;
top: 0.5em;
left: 0.5em;
width: calc(100% - 1em);
height: calc(100% - 1em);
background-color: rgba(0, 0, 0, 0.5);
display: none;
pointer-events: none;
}

.dragover-popup h1 {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%)
}

body.dragging main,
body.dragging header {
filter: blur(5px);
}

body.dragging .dragover-popup {
display: block;
}

header {
text-align: center;
display: flex;
justify-content: center;
align-items: center;
padding: 3em 0;
}

ul {
margin: 0;
padding: 0;
list-style: none;
}

ul li {
margin: 1em 0;
font-size: 1em;
font-family: monospace;
word-wrap: break-word;
}

button {
background-color: rgba(0, 0, 0, 0.2);
color: #6acad1;
border: 2px solid #6acad1;
font-size: 1em;
padding: 0.625em 1.5em;
border-radius: 0.125em;
margin: .5em 0;
}

button.full {
margin-right: 0;
margin-left: 0;
width: 100%;
}

button:hover {
color: white;
border: 2px solid white;
cursor: pointer;
}

.address {
font-family: monospace
}

.disabled *,
input:disabled,
button:disabled {
opacity: 0.2;
}

input {
width: 100%;
border: 2px solid rgba(0, 0, 0, 0.2);
color: black;
padding: 0.7em;
border-radius: 2px;
}

input:hover,
input:focus,
input:active {
border-color: #6acad1;
}

input,
button {
outline: none;
}

main {
width: 90%;
margin: 0 auto;
}

.buttons,
.columns {
display: flex;
flex-direction: row;
justify-content: space-between;
height: 100%;
}

.msgs-box {
flex: 1 1 0px;
overflow-y: scroll;
min-height: 250px;
}

.peers-box {
flex: 1 1 0px;
overflow-y: scroll;
min-height: 182px;
}

.addrs-box {
flex: 1;
overflow-y: scroll;
max-height: 273px;
}

.row {
display: flex;
flex-direction: column;
}

.buttons>button,
.columns>div {
width: calc(33% - 0.5em);
}

.buttons>button {
margin: 0 0 1em;
}

.box {
background-color: rgba(255, 255, 255, 0.05);
padding: 1em;
margin-bottom: 1em;
}

.box>h2 {
display: block;
border-bottom: 2px solid rgba(255, 255, 255, 0.1);
border-right: 0;
border-left: 0;
text-align: center;
padding-bottom: 0.5em;
margin-bottom: 1em;
}

.errors {
grid-area: errors;
color: red;
font-style: italic;
font-size: 1.125em;
display: block;
margin: 0 0 1em;
}

.errors.hidden {
display: none;
}

table {
width: 100%;
margin: 1em 0;
word-break: break-all;
border-collapse: collapse;
}

table thead {
background-color: rgba(255, 255, 255, 0.1);
font-weight: normal
}

table th,
table td {
padding: 0.5em 0;
}

table td:last-child,
table th:last-child {
width: 20%;
text-align: center;
}

table td:first-child {
width: 45%;
}

table td:nth-child(2) {
width: 35%;
font-family: monospace;
}

table tr:hover {
background-color: rgba(0, 0, 0, 0.2)
}

table a {
color: inherit;
}
27 changes: 27 additions & 0 deletions examples/circuit-relaying/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "ipfs-quick-msg",
"version": "0.0.1",
"description": "IPFS quick msg",
"main": "index.js",
"scripts": {
"clean": "rm -rf dist/*",
"build": "parcel build index.html --public-url '.'",
"start": "parcel index.html",
"test": "echo \"Error: no test specified\" && exit 1",
"deploy": "ipfs add -r --quieter dist",
"lint": "aegir lint"
},
"author": "Dmitriy Ryajov <dryajov@gmail.com>",
"license": "MIT",
"dependencies": {
"ipfs": "file:../../",
"ipfs-pubsub-room": "~0.3.0"
},
"devDependencies": {
"aegir": "^13.0.5",
"http-server": "^0.10.0",
"ipfs-css": "^0.2.0",
"parcel-bundler": "^1.6.2",
"tachyons": "^4.9.1"
}
}
Loading

0 comments on commit f7eaa43

Please sign in to comment.