The Swift implementation of the libp2p networking stack
libp2p is a networking stack and library modularized out of The IPFS Project, and bundled separately for other tools to use.
libp2p is the product of a long, and arduous quest of understanding -- a deep dive into the internet's network stack, and plentiful peer-to-peer protocols from the past. Building large-scale peer-to-peer systems has been complex and difficult in the last 15 years, and libp2p is a way to fix that. It is a "network stack" -- a protocol suite -- that cleanly separates concerns, and enables sophisticated applications to only use the protocols they absolutely need, without giving up interoperability and upgradeability. libp2p grew out of IPFS, but it is built so that lots of people can use it, for lots of different projects.
To learn more, check out the following resources:
Include the following dependency in your Package.swift file
let package = Package( ... dependencies: [ ... .package(name: "LibP2P", url: "https://github.com/swift-libp2p/swift-libp2p.git", .upToNextMajor(from: "0.1.0")) ], ... .target( ... dependencies: [ ... .product(name: "LibP2P", package: "swift-libp2p"), ]), ... )
import LibP2P import LibP2PNoise import LibP2PMPLEX /// Configure your Libp2p networking stack... let lib = try Application(.development, peerID: PeerID(.Ed25519)) lib.security.use(.noise) lib.muxers.use(.mplex) lib.servers.use(.tcp(host: "127.0.0.1", port: 0)) /// Register your routes handlers... /// - Note: Uses the same syntax as swift-vapor try lib.routes() /// Start libp2p lib.start() /// Do some networking stuff... 📡 /// At some later point, when you're done with libp2p... lib.shutdown()
Contributions are welcomed! This code is very much a proof of concept. I can guarantee you there's a better / safer way to accomplish the same results. Any suggestions, improvements, or even just critiques, are welcome!
Let's make this code better together! 🤝
MIT © 2022 Breth Inc.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4