All Projects → v-braun → Go2p

v-braun / Go2p

Licence: mit
Simple to use but full configurable p2p framework

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Go2p

Diztl
Share, discover & download files in your network 💥
Stars: ✭ 162 (+102.5%)
Mutual labels:  p2p, peer-to-peer, distributed-systems
Dat React Native
Browse through the web with the Dat protocol in your device!
Stars: ✭ 25 (-68.75%)
Mutual labels:  network, p2p, peer-to-peer
Layr
A decentralized (p2p) file storage system built atop Kademlia DHT that enforces data integrity, privacy, and availability through sharding, proofs of retrievability, redundancy, and encryption, with smart-contract powered incentive scheme
Stars: ✭ 90 (+12.5%)
Mutual labels:  distributed-systems, peer-to-peer, p2p
Spruce Network
Decentralized peer-to-peer mesh network.
Stars: ✭ 61 (-23.75%)
Mutual labels:  network, p2p, peer-to-peer
Nkn
Official Go implementation of NKN full node.
Stars: ✭ 287 (+258.75%)
Mutual labels:  network, p2p, distributed-systems
Peergos
A p2p, secure file storage, social network and application protocol
Stars: ✭ 895 (+1018.75%)
Mutual labels:  p2p, peer-to-peer
Vmesh
VMesh is a decentralized Layer 3 mesh router and protocol designed for open network interconnection.
Stars: ✭ 25 (-68.75%)
Mutual labels:  network, p2p
Peer Calls
Group peer to peer video calls for everyone written in Go and TypeScript
Stars: ✭ 837 (+946.25%)
Mutual labels:  p2p, peer-to-peer
Nkn Client Js
[Deprecated, use nkn-sdk-js instead] JavaScript implementation of NKN client
Stars: ✭ 53 (-33.75%)
Mutual labels:  p2p, distributed-systems
Xingo
高性能golang网络库,游戏开发脚手架
Stars: ✭ 727 (+808.75%)
Mutual labels:  network, distributed-systems
Dawn
global hosting, financial automation, server-less web components
Stars: ✭ 40 (-50%)
Mutual labels:  network, p2p
Distributedsystem Series
📚 深入浅出分布式基础架构,Linux 与操作系统篇 | 分布式系统篇 | 分布式计算篇 | 数据库篇 | 网络篇 | 虚拟化与编排篇 | 大数据与云计算篇
Stars: ✭ 1,092 (+1265%)
Mutual labels:  network, distributed-systems
P2p
Practice project to demonstrate p2p file sharing.
Stars: ✭ 16 (-80%)
Mutual labels:  network, peer-to-peer
Rust Ipfs
The InterPlanetary File System (IPFS), implemented in Rust.
Stars: ✭ 739 (+823.75%)
Mutual labels:  p2p, peer-to-peer
Manyverse
A social network off the grid (real repo at https://gitlab.com/staltz/manyverse)
Stars: ✭ 736 (+820%)
Mutual labels:  p2p, peer-to-peer
Rats Search
BitTorrent P2P multi-platform search engine for Desktop and Web servers with integrated torrent client.
Stars: ✭ 1,037 (+1196.25%)
Mutual labels:  network, p2p
Ciruela
A peer-to-peer synchronization software for servers in datacenters.
Stars: ✭ 61 (-23.75%)
Mutual labels:  p2p, peer-to-peer
Cause
An EDN-like CRDT (Causal Tree) for Clojure & ClojureScript that automatically tracks history and resolves conflicts.
Stars: ✭ 68 (-15%)
Mutual labels:  p2p, distributed-systems
Mesh
A secure, anonymous, peer-to-peer, instant messenger!
Stars: ✭ 74 (-7.5%)
Mutual labels:  p2p, peer-to-peer
Js Ipfs
IPFS implementation in JavaScript
Stars: ✭ 6,129 (+7561.25%)
Mutual labels:  p2p, peer-to-peer

go2p

golang p2p framework

By v-braun - viktor-braun.de.

Build Status codecov Go Report Card Documentation PR welcome

Description

GO2P is a P2P framework, designed with flexibility and simplicity in mind. You can use a pre configured stack (encryption, compression, etc.) or built your own based on the existing modules.

GO2P use the middleware pattern as a core pattern for messages. If you have used expressJS, OWIN or other HTTP/Web based frameworks you should be familiar with that.
The basic idea is that an outgoing message is passed through multiple middleware functions. Each of this functions can manipulate the message.
A middleware function could encrypt, compress, log or sign the message.
Outgoing messages will be processed through the middleware functions and incomming messages in the inverted order:

Installation

go get github.com/v-braun/go2p

Usage

You like code? Checkout the chat example

The simplest way to use this framework is to create a new instance of the full configured TCP based network stack:

    localAddr := "localhost:7077"
	net := go2p.NewNetworkConnectionTCP(*localAddr, &map[string]func(peer *go2p.Peer, msg *go2p.Message){
		"msg": func(peer *go2p.Peer, msg *go2p.Message) {
			fmt.Printf("%s > %s\n", peer.RemoteAddress(), msg.PayloadGetString())
		},
    })
    
    net.OnPeer(func(p *go2p.Peer) {
		fmt.Printf("new peer: %s\n", p.RemoteAddress())
    })
    
    err := net.Start()
	if err != nil {
		panic(err)
    }

    defer net.Stop()
    

    // connects to another peer via tcp
    net.ConnectTo("tcp", "localhost:7077")

    // send a message to the 'msg' route 
    net.SendBroadcast(go2p.NewMessageRoutedFromString("msg", "hello go2p"))



Advanced Usage

The function NewNetworkConnectionTCP is a shorthand for the advanced configuration of a network stack.

	op := go2p.NewTCPOperator("tcp", localAddr) // creates a tcp based operator (net.Dialer and net.Listener)
	peerStore := go2p.NewDefaultPeerStore(10) // creates a simple peer store that limits connections to 10

	conn := go2p.NewNetworkConnection(). // creates a new instance of the builder
		WithOperator(op). // adds the operator to the network stack
		WithPeerStore(peerStore). // adds the peer store to the network stack
		WithMiddleware(go2p.Routes(routes)). // adds the routes middleware
		WithMiddleware(go2p.Headers()). // adds the headers middleware
		WithMiddleware(go2p.Crypt()). // adds encryption
		WithMiddleware(go2p.Log()). // adds logging
		Build() // creates the network 

This code creates a new NetworkConnection that use tcp communication, a default PeerStore and some middlewares.
Outgoing messages will now pass the following middlewares:

(app logic) -> Routing -> Headers -> Crypt -> Log -> (network) 

Incomming messages will pass the following middlewares

(app logic) <- Routing <- Headers <- Crypt <- Log <- (network)

Authors

image
v-braun

Contributing

Make sure to read these guides before getting started:

License

go2p is available under the MIT License. See LICENSE for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].