From ba68150cc535a4c4b4b117c7474536a54c0d2580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sat, 26 May 2018 16:15:39 +0200 Subject: [PATCH] p2p: update docs after refactor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Ɓukasz Magiera --- docs/experimental-features.md | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/docs/experimental-features.md b/docs/experimental-features.md index 08cd68108c9..ca1403469bf 100644 --- a/docs/experimental-features.md +++ b/docs/experimental-features.md @@ -243,7 +243,7 @@ The `p2p` command needs to be enabled in config: First, pick a protocol name for your application. Think of the protocol name as a port number, just significantly more user-friendly. In this example, we're -going to use `/p2p/kickass/1.0`. +going to use `/kickass/1.0`. **Setup:** @@ -257,7 +257,7 @@ First, start your application and have it listen on `$APP_PORT`. Then, configure the p2p listener by running: ```sh -> ipfs p2p listener open /p2p/kickass/1.0 /ip4/127.0.0.1/tcp/$APP_PORT +> ipfs p2p forward /kickass/1.0 /ipfs /ip4/127.0.0.1/tcp/$APP_PORT ``` This will configure IPFS to forward all incoming `/p2p/kickass/1.0` streams to @@ -271,10 +271,28 @@ First, configure the p2p dialer to forward all inbound connections on node. ```sh -> ipfs p2p stream dial $SERVER_ID /p2p/kickass/1.0 /ip4/127.0.0.1/tcp/$SOME_PORT +> ipfs p2p forward /kickass/1.0 /ip4/127.0.0.1/tcp/$SOME_PORT /ipfs/$SERVER_ID ``` -Next, have your application open a connection to `127.0.0.1:$SOME_PORT`. This connection will be forwarded to the service running on `127.0.0.1:$APP_PORT` on the remote machine. +Next, have your application open a connection to `127.0.0.1:$SOME_PORT`. This +connection will be forwarded to the service running on `127.0.0.1:$APP_PORT` on +the remote machine. You can test it with netcat: + +**On "server" node:** +```sh +> nc -v -l -p $APP_PORT +``` + +**On "client" node:** +```sh +> nc -v 127.0.0.1 $SOME_PORT +``` + +You should now see that a connection has been established and be able to +exchange messages between netcat instances. + +(note that depending on your netcat version you may need to drop the `-v` flag) + ### Road to being a real feature - [ ] Needs more people to use and report on how well it works / fits use cases