Swiftpack.co - swift-libp2p/swift-libp2p-mss as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by swift-libp2p.
swift-libp2p/swift-libp2p-mss 0.0.1
MultiStreamSelect (MSS) Protocol Negotiation Package (Embedded)
⭐️ 0
🕓 3 days ago
iOS macOS
.package(url: "https://github.com/swift-libp2p/swift-libp2p-mss.git", from: "0.0.1")

LibP2PMSS (Embedded)

Swift Package Manager compatible Build & Test (macos)

MultistreamSelect (MSS) is a Libp2p Transport Upgrader. A Transport Upgrader is responsible for negotiating the protocols that we'll speak when interracting with a remote libp2p Peer.


Table of Contents


Some protocols have sub-protocols or protocol-suites. Often, these sub protocols are optional extensions. Selecting which protocol to use -- or even knowing what is available to chose from -- is not simple.

What if there was a protocol that allowed mounting or nesting other protocols, and made it easy to select which protocol to use?

At the operating system level, protocol selection is usually accomplished using numbered ports, with some out-of-band agreement on the mapping of port numbers to protocols. For example, HTTP requests will use TCP port 80 unless otherwise specified.

multistream-select brings this concept into the "protocol level", which gives you the flexibility to evolve a mapping of human-readable protocol names to the semantics you need, which may change over time.

This is especially useful in environments where connections to arbitrary OS ports is difficult or impossible, for example because one or more parties is behind a NAT. In such cases, a single connection with a stream multiplexer will allow you to open many independent communication channels, but you'll need some mechanism for deciding what protocol to use for each channel. If you support multiple stream multiplexers, you can even use multistream-select to decide which one to use in the first place.


Heads up ‼️

  • This package is embedded into swift-libp2p, there's no need to explicitly include this package in your swift-libp2p project. Include the following dependency in your Package.swift file
let package = Package(
    dependencies: [
        .package(url: "https://github.com/swift-libp2p/swift-libp2p-mss.git", .upToNextMajor(from: "0.0.1"))
            dependencies: [
                .product(name: "LibP2PMSS", package: "swift-libp2p-mss"),


Heads up ‼️

  • This package is embedded into swift-libp2p, there's no need to explicitly include this package in your swift-libp2p project.



import LibP2PMSS

/// When you configure your app




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! 🤝



MIT © 2022 Breth Inc.


Stars: 0
Last commit: 3 days ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics