From 16d904e84b2ca711644c400ca6463b4e7c141f61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alen=20=C5=A0iljak?= Date: Fri, 19 Mar 2021 12:13:45 +0100 Subject: [PATCH 1/3] updating the example --- examples/browser-ipns-publish/index.html | 10 ++++++++++ examples/browser-ipns-publish/index.js | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/examples/browser-ipns-publish/index.html b/examples/browser-ipns-publish/index.html index ce7c5c9187..40d5b4fbd2 100644 --- a/examples/browser-ipns-publish/index.html +++ b/examples/browser-ipns-publish/index.html @@ -137,6 +137,16 @@

> Connect + +
+ For connecting to a local go-ipfs node, you may need to use +
/ip4/127.0.0.1/tcp/4003/ws/p2p/QmTheirServerPeerId
+
diff --git a/examples/browser-ipns-publish/index.js b/examples/browser-ipns-publish/index.js index e0e5ef72d2..6d5c850cf7 100644 --- a/examples/browser-ipns-publish/index.js +++ b/examples/browser-ipns-publish/index.js @@ -9,6 +9,10 @@ const cryptoKeys = require("human-crypto-keys"); // { getKeyPairFromSeed } const uint8ArrayToString = require('uint8arrays/to-string') const uint8ArrayFromString = require('uint8arrays/from-string') +const WS = require('libp2p-websockets') +const transportKey = WS.prototype[Symbol.toStringTag] +const filters = require('libp2p-websockets/src/filters') + const { sleep, Logger, onEnterPress, catchAndLog } = require("./util"); async function main() { @@ -39,6 +43,17 @@ async function main() { ipfsBrowser = await IPFS.create({ pass: "01234567890123456789", EXPERIMENTAL: { ipnsPubsub: true }, + libp2p: { + config: { + transport: { + // This is added for local demo! + // In a production environment the default filter should be used + // where only DNS + WSS addresses will be dialed by websockets in the browser. + [transportKey]: { + filter: filters.all + } + } + }} }); const { id } = await ipfsBrowser.id(); log(`Browser IPFS ready! Node id: ${id}`); From 605f6a8afe13b9d84b1422b8edd30ed656226293 Mon Sep 17 00:00:00 2001 From: Alen Siljak Date: Tue, 22 Jun 2021 11:07:46 +0200 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Vasco Santos --- examples/browser-ipns-publish/index.html | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/browser-ipns-publish/index.html b/examples/browser-ipns-publish/index.html index 40d5b4fbd2..1acc05d83e 100644 --- a/examples/browser-ipns-publish/index.html +++ b/examples/browser-ipns-publish/index.html @@ -137,9 +137,6 @@

> Connect -
Date: Tue, 22 Jun 2021 11:08:02 +0200 Subject: [PATCH 3/3] Comments from code review Co-authored-by: Vasco Santos --- examples/browser-ipns-publish/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/browser-ipns-publish/index.html b/examples/browser-ipns-publish/index.html index 1acc05d83e..3f6c8f387b 100644 --- a/examples/browser-ipns-publish/index.html +++ b/examples/browser-ipns-publish/index.html @@ -141,7 +141,7 @@

class="custom-block callout" style="font-size: 0.75em; width: 75%; margin: 1em;" > - For connecting to a local go-ipfs node, you may need to use + For connecting to a local go-ipfs node, you can check its listening address similar to:
/ip4/127.0.0.1/tcp/4003/ws/p2p/QmTheirServerPeerId