Git Product home page Git Product logo

swift-libp2p-logo-wide

Swift LibP2P

Swift Package Manager compatible Build & Test (macos and linux)

The Swift implementation of the libp2p networking stack

Table of Contents

Overview

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.

Docs & Examples

Note:

To learn more, check out the following resources:

Disclaimer

  • ‼️ This is a work in progress ‼️
  • ‼️ Please don't use swift-libp2p in anything other than experimental projects until it reaches 1.0 ‼️
  • ‼️ Help it get there sooner by contributing ‼️

Install

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"),
            ]),
    ...
)

Usage

Example

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()

Packages

  • List of packages currently in existence for swift libp2p:
  • Legend: 🟢 = kinda works, 🟡 = doesn't really work yet, 🔴 = not started yet, but on the radar
Name Status Description Build (macOS & Linux)
Libp2p
swift-libp2p 🟢 swift-libp2p entry point Build & Test (macos and linux)
swift-libp2p-core 🟢 Core interfaces, types, and abstractions Build & Test (macos and linux)
Protocol Negotiation
swift-libp2p-mss 🟢 MultistreamSelect transport upgrader (embedded) Build & Test (macos and linux)
Transport
swift-libp2p-tcp 🟢 TCP transport (embedded) N/A
swift-libp2p-udp 🟡 UDP transport (embedded) N/A
swift-libp2p-quic 🔴 TODO: QUIC transport N/A
swift-libp2p-websocket 🟢 WebSocket transport Build & Test (macos and linux)
swift-libp2p-http 🔴 TODO: HTTP1 transport N/A
swift-libp2p-http2 🔴 TODO: HTTP2 transport N/A
Encrypted Channels
swift-libp2p-plaintext 🟢 Plaintext channel Build & Test (macos and linux)
swift-libp2p-noise 🟢 Noise crypto channel Build & Test (macos and linux)
swift-libp2p-tls 🔴 TODO: TLS 1.3+ crypto channel N/A
Stream Muxers
swift-libp2p-mplex 🟢 MPLEX stream multiplexer Build & Test (macos and linux)
swift-libp2p-yamux 🔴 TODO: YAMUX stream multiplexer N/A
Private Network
- - - N/A
NAT Traversal
- - - N/A
Peerstore
swift-libp2p-peerstore 🟡 Reference implementation of peer metadata storage component (embedded) N/A
Connection Manager
swift-libp2p-connection-manager 🟡 Reference implementation of connection manager (embedded) N/A
Routing
swift-libp2p-kad-dht 🟡 Kademlia Distributed Hash Table Build & Test (macos and linux)
Pubsub
swift-libp2p-pubsub 🟡 Core PubSub Protocols & FloodSub and GossipSub Routers Build & Test (macos and linux)
RPC
swift-libp2p-rpc 🔴 TODO: A simple RPC library for libp2p N/A
Utilities/miscellaneous
swift-libp2p-dnsaddr 🟡 A DNSAddr Resolver Build & Test (macos)
swift-libp2p-mdns 🟡 MulticastDNS for LAN discovery Build & Test (macos)
swift-libp2p-identify 🟢 IPFS Identify Protocols (embedded) Build & Test (macos and linux)
Testing and examples
swift-libp2p-testing 🔴 TODO: A collection of testing utilities for libp2p N/A

Dependencies

Name Description Build (macOS & Linux)
Cryptography
swift-libp2p-crypto Crypto abstractions for Keys, Hashes and Ciphers Build & Test (macos and linux)
Multiformats
swift-multibase Self Identifying Base Encodings Build & Test (macos and linux)
swift-multicodec Multiformat Codecs Build & Test (macos and linux)
swift-multihash Self Identifying Hashes Build & Test (macos and linux)
swift-multiaddr Self Identifying Addresses Build & Test (macos and linux)
swift-peer-id Peer IDs Build & Test (macos and linux)
Utilities
swift-bases Base encodings & decodings Build & Test (macos and linux)
swift-varint Protocol Buffer Variable Integers Build & Test (macos and linux)
swift-cid Content Identifiers Build & Test (macos and linux)
External
swift-nio Network application framework N/A

API

/// TODO

Contributing

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 critques, are welcome!

Let's make this code better together! 🤝

Credits

License

MIT © 2022 Breth Inc.

swift-libp2p's Projects

specs icon specs

Technical specifications for the libp2p networking stack

swift-bases icon swift-bases

A collection of encoding and decoding algorithms for various common bases (2, 8, 10, 16, 32, 36, 58, 64)

swift-cid icon swift-cid

Self-describing content-addressed identifiers for distributed systems

swift-libp2p icon swift-libp2p

Swift implementation of libp2p, a modular & extensible networking stack

swift-libp2p-core icon swift-libp2p-core

The core LibP2P Interfaces / Protocols and Abstractions backing the swift-libp2p project

swift-noise icon swift-noise

Swift implementation of the Noise Protocol Framework

swift-peer-id icon swift-peer-id

Abstraction for managing Libp2p public / private key pairs and identities

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.