GithubHelp home page GithubHelp logo

Comments (2)

hsanjuan avatar hsanjuan commented on July 23, 2024

That example shows how to tunnel something like http using a libp2p stream.

If every IOT device is going to connect to a server using libp2p, then great, that connection can be used to talk http to each IOT device transported on a libp2p stream.

For that each IOT device should run a webserver that, just as it listens on a normal network address (with a Go tcp listener), should listen on the libp2p stream. The example implements the own server, and it may not be clear for real usage.

Instead, I suggest you look into https://github.com/libp2p/go-libp2p-http and https://godoc.org/github.com/libp2p/go-libp2p-http which shows how the Go webserver can "listen on libp2p", and how a Go http client than use libp2p as transport.

Now, in order to access those websites from your browser at the "Server", you will need to additionally run an actual proxy, that takes your browser client requests and tunnels them (the example covers this part I think):

<webserver><libp2p-gostream-listener>-----libp2p-stream-on-libp2p-connection----<libp2p-reverse-proxy-with-go-libp2p-http><browser>

If your webserver is not written in Go, you will need an additional libp2p-reverse-proxy in front of it.

As a side note, go-ipfs has "stream mounting" (ipfs p2p --help) which does exactly the reverse proxy part for the client. i.e. ipfs p2p forward --allow-custom-protocol /libp2p-http :3000 <peerID> will tunnel anything talking to localhost:3000 as a libp2p stream to a given peerID.

from go-libp2p-examples.

StefanGies99 avatar StefanGies99 commented on July 23, 2024

@hsanjuan Thanks for your explanation! In the next days, I'll continue working on the mentioned solution above.

from go-libp2p-examples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.