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.2
MultiStreamSelect (MSS) Protocol Negotiation Package (Embedded)
⭐️ 0
🕓 1 year ago
iOS macOS
.package(url: "https://github.com/swift-libp2p/swift-libp2p-mss.git", from: "0.0.2")

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.

Note:

Table of Contents

Overview

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.

Install

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"))
    ],
    ...
        .target(
            ...
            dependencies: [
                ...
                .product(name: "LibP2PMSS", package: "swift-libp2p-mss"),
            ]),
    ...
)

Usage

Heads up ‼️

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

Example

TODO


import LibP2PMSS

/// When you configure your app
app.transportUpgraders.use(.mss)

API

N/A

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.

GitHub

link
Stars: 0
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

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