Giter Site home page Giter Site logo

libp2ppoc's Introduction

p2p chat app with libp2p

This program demonstrates a simple p2p chat application. It can work between two peers if

  1. Both have a private IP address (same network).
  2. At least one of them has a public IP address.

Assume if 'A' and 'B' are on different networks host 'A' may or may not have a public IP address but host 'B' has one.

Usage: Run ./chat -sp <SOURCE_PORT> on host 'B' where <SOURCE_PORT> can be any port number. Now run ./chat -d <MULTIADDR_B> on node 'A' [<MULTIADDR_B> is multiaddress of host 'B' which can be obtained from host 'B' console].

Build

From the go-libp2p-examples directory run the following:

> make deps
> cd chat
> go build

Usage

On node 'B'

> ./chat -sp 3001
Run ./chat -d /ip4/127.0.0.1/tcp/3001/p2p/QmdXGaeGiVA745XorV1jr11RHxB9z4fqykm6xCUPX1aTJo

2018/02/27 01:21:32 Got a new stream!
> hi (received messages in green colour)
> hello (sent messages in white colour)
> no

On node 'A'. Replace 127.0.0.1 with <PUBLIC_IP> if node 'B' has one.

> ./chat -d /ip4/127.0.0.1/tcp/3001/p2p/QmdXGaeGiVA745XorV1jr11RHxB9z4fqykm6xCUPX1aTJo
Run ./chat -d /ip4/127.0.0.1/tcp/3001/p2p/QmdXGaeGiVA745XorV1jr11RHxB9z4fqykm6xCUPX1aTJo

This node's multiaddress:
/ip4/0.0.0.0/tcp/0/p2p/QmWVx9NwsgaVWMRHNCpesq1WQAw2T3JurjGDNeVNWifPS7
> hi
> hello

NOTE: debug mode is enabled by default, debug mode will always generate the same node id (on each node) on every execution. Disable debug using --debug false flag while running your executable.

Note: If you are looking for an implementation with peer discovery, chat-with-rendezvous, supports peer discovery using a rendezvous point.

Authors

  1. Abhishek Upperwal

libp2ppoc's People

Contributors

notrapha avatar

Watchers

James Cloos avatar Raphaël avatar

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.