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

Commit f7eaa43

Browse files
dryajovdaviddias
authored andcommitted
feat: Circuit Relay (#1063)
1 parent 9694925 commit f7eaa43

File tree

19 files changed

+1018
-6
lines changed

19 files changed

+1018
-6
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,13 @@ const node = new IPFS({
205205
EXPERIMENTAL: { // enable experimental features
206206
pubsub: true,
207207
sharding: true, // enable dir sharding
208-
dht: true // enable KadDHT, currently not interopable with go-ipfs
208+
dht: true, // enable KadDHT, currently not interopable with go-ipfs
209+
relay: {
210+
enabled: true, // enable circuit relay dialer and listener
211+
hop: {
212+
enabled: true // enable circuit relay HOP (make this node a relay)
213+
}
214+
}
209215
},
210216
config: { // overload the default IPFS node config, find defaults at https://github.com/ipfs/js-ipfs/tree/master/src/core/runtime
211217
Addresses: {

examples/circuit-relaying/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
.vscode/

examples/circuit-relaying/README.md

Lines changed: 349 additions & 0 deletions
Large diffs are not rendered by default.
294 KB
Loading
467 KB
Loading
426 KB
Loading
454 KB
Loading
513 KB
Loading
567 KB
Loading
591 KB
Loading

examples/circuit-relaying/index.html

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<meta charset="utf-8">
4+
<meta http-equiv="x-ua-compatible" content="ie=edge">
5+
<title>IPFS simple messaging</title>
6+
<meta name="description" content="Simple chat app on ipfs">
7+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
8+
<link rel="stylesheet" href="./main.css">
9+
10+
<body>
11+
<header>
12+
<h1>IPFS Simple Messaging</h1>
13+
</header>
14+
<main>
15+
<div class="columns box">
16+
<div class="row">
17+
<div class="box">
18+
<label>Room (double click to change):</label>
19+
<span id="room"></span>
20+
<input type="text" id="room-id" style="display: none">
21+
</div>
22+
<div class="box msgs-box">
23+
<ul id="msgs"></ul>
24+
</div>
25+
<div>
26+
<label>message:</label>
27+
<input type="text" id="message"></input>
28+
<button id="send">Send</button>
29+
</div>
30+
</div>
31+
<div class="row">
32+
<div class="box peers-box">
33+
<label>Peers Joined Room:</label>
34+
<ul id="peers"></ul>
35+
</div>
36+
<div class="box peers-box">
37+
<label>Peers Connected:</label>
38+
<ul id="peers-addrs"></ul>
39+
</div>
40+
<div>
41+
<label>Connect to Peer:</label>
42+
<input type="text" id="peer"></input>
43+
<button id="connect">Connect</button>
44+
</div>
45+
</div>
46+
<div class="row">
47+
<div class="box row">
48+
<label>Peer id:</label>
49+
<ul id="peer-id"></ul>
50+
</div>
51+
<div class="box addrs-box">
52+
<label>Addresses:</label>
53+
<ul id="addrs"></ul>
54+
</div>
55+
</div>
56+
</div>
57+
</main>
58+
<script src="src/app.js"></script>
59+
</body>
60+
61+
</html>

examples/circuit-relaying/main.css

Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
* {
2+
box-sizing: border-box;
3+
}
4+
5+
body {
6+
height: 100%;
7+
}
8+
9+
body {
10+
font-family: sans-serif;
11+
color: white;
12+
background: linear-gradient(to bottom, #041727 0%, #062b3f 100%);
13+
pointer-events: auto;
14+
}
15+
16+
h1,
17+
h2,
18+
h3 {
19+
margin: 0;
20+
}
21+
22+
h1 {
23+
font-size: 2em;
24+
font-weight: 300;
25+
}
26+
27+
h2 {
28+
font-size: 1.25em;
29+
font-weight: 700;
30+
}
31+
32+
h3 {
33+
font-size: 1.0em;
34+
font-weight: 700;
35+
}
36+
37+
main,
38+
header {
39+
filter: none;
40+
}
41+
42+
.dragover-popup {
43+
position: fixed;
44+
top: 0.5em;
45+
left: 0.5em;
46+
width: calc(100% - 1em);
47+
height: calc(100% - 1em);
48+
background-color: rgba(0, 0, 0, 0.5);
49+
display: none;
50+
pointer-events: none;
51+
}
52+
53+
.dragover-popup h1 {
54+
position: fixed;
55+
top: 50%;
56+
left: 50%;
57+
transform: translate(-50%, -50%)
58+
}
59+
60+
body.dragging main,
61+
body.dragging header {
62+
filter: blur(5px);
63+
}
64+
65+
body.dragging .dragover-popup {
66+
display: block;
67+
}
68+
69+
header {
70+
text-align: center;
71+
display: flex;
72+
justify-content: center;
73+
align-items: center;
74+
padding: 3em 0;
75+
}
76+
77+
ul {
78+
margin: 0;
79+
padding: 0;
80+
list-style: none;
81+
}
82+
83+
ul li {
84+
margin: 1em 0;
85+
font-size: 1em;
86+
font-family: monospace;
87+
word-wrap: break-word;
88+
}
89+
90+
button {
91+
background-color: rgba(0, 0, 0, 0.2);
92+
color: #6acad1;
93+
border: 2px solid #6acad1;
94+
font-size: 1em;
95+
padding: 0.625em 1.5em;
96+
border-radius: 0.125em;
97+
margin: .5em 0;
98+
}
99+
100+
button.full {
101+
margin-right: 0;
102+
margin-left: 0;
103+
width: 100%;
104+
}
105+
106+
button:hover {
107+
color: white;
108+
border: 2px solid white;
109+
cursor: pointer;
110+
}
111+
112+
.address {
113+
font-family: monospace
114+
}
115+
116+
.disabled *,
117+
input:disabled,
118+
button:disabled {
119+
opacity: 0.2;
120+
}
121+
122+
input {
123+
width: 100%;
124+
border: 2px solid rgba(0, 0, 0, 0.2);
125+
color: black;
126+
padding: 0.7em;
127+
border-radius: 2px;
128+
}
129+
130+
input:hover,
131+
input:focus,
132+
input:active {
133+
border-color: #6acad1;
134+
}
135+
136+
input,
137+
button {
138+
outline: none;
139+
}
140+
141+
main {
142+
width: 90%;
143+
margin: 0 auto;
144+
}
145+
146+
.buttons,
147+
.columns {
148+
display: flex;
149+
flex-direction: row;
150+
justify-content: space-between;
151+
height: 100%;
152+
}
153+
154+
.msgs-box {
155+
flex: 1 1 0px;
156+
overflow-y: scroll;
157+
min-height: 250px;
158+
}
159+
160+
.peers-box {
161+
flex: 1 1 0px;
162+
overflow-y: scroll;
163+
min-height: 182px;
164+
}
165+
166+
.addrs-box {
167+
flex: 1;
168+
overflow-y: scroll;
169+
max-height: 273px;
170+
}
171+
172+
.row {
173+
display: flex;
174+
flex-direction: column;
175+
}
176+
177+
.buttons>button,
178+
.columns>div {
179+
width: calc(33% - 0.5em);
180+
}
181+
182+
.buttons>button {
183+
margin: 0 0 1em;
184+
}
185+
186+
.box {
187+
background-color: rgba(255, 255, 255, 0.05);
188+
padding: 1em;
189+
margin-bottom: 1em;
190+
}
191+
192+
.box>h2 {
193+
display: block;
194+
border-bottom: 2px solid rgba(255, 255, 255, 0.1);
195+
border-right: 0;
196+
border-left: 0;
197+
text-align: center;
198+
padding-bottom: 0.5em;
199+
margin-bottom: 1em;
200+
}
201+
202+
.errors {
203+
grid-area: errors;
204+
color: red;
205+
font-style: italic;
206+
font-size: 1.125em;
207+
display: block;
208+
margin: 0 0 1em;
209+
}
210+
211+
.errors.hidden {
212+
display: none;
213+
}
214+
215+
table {
216+
width: 100%;
217+
margin: 1em 0;
218+
word-break: break-all;
219+
border-collapse: collapse;
220+
}
221+
222+
table thead {
223+
background-color: rgba(255, 255, 255, 0.1);
224+
font-weight: normal
225+
}
226+
227+
table th,
228+
table td {
229+
padding: 0.5em 0;
230+
}
231+
232+
table td:last-child,
233+
table th:last-child {
234+
width: 20%;
235+
text-align: center;
236+
}
237+
238+
table td:first-child {
239+
width: 45%;
240+
}
241+
242+
table td:nth-child(2) {
243+
width: 35%;
244+
font-family: monospace;
245+
}
246+
247+
table tr:hover {
248+
background-color: rgba(0, 0, 0, 0.2)
249+
}
250+
251+
table a {
252+
color: inherit;
253+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "ipfs-quick-msg",
3+
"version": "0.0.1",
4+
"description": "IPFS quick msg",
5+
"main": "index.js",
6+
"scripts": {
7+
"clean": "rm -rf dist/*",
8+
"build": "parcel build index.html --public-url '.'",
9+
"start": "parcel index.html",
10+
"test": "echo \"Error: no test specified\" && exit 1",
11+
"deploy": "ipfs add -r --quieter dist",
12+
"lint": "aegir lint"
13+
},
14+
"author": "Dmitriy Ryajov <[email protected]>",
15+
"license": "MIT",
16+
"dependencies": {
17+
"ipfs": "file:../../",
18+
"ipfs-pubsub-room": "~0.3.0"
19+
},
20+
"devDependencies": {
21+
"aegir": "^13.0.5",
22+
"http-server": "^0.10.0",
23+
"ipfs-css": "^0.2.0",
24+
"parcel-bundler": "^1.6.2",
25+
"tachyons": "^4.9.1"
26+
}
27+
}

0 commit comments

Comments
 (0)