Skip to content

Commit 249c994

Browse files
authored
Merge pull request #1 from swift-libp2p/ssh-route
Initial Implementation
2 parents b883128 + a18639d commit 249c994

28 files changed

Lines changed: 5645 additions & 12 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ Package.resolved
1111
/public
1212
/docs
1313
.benchmarkBaselines
14+
Tests/LibP2PYAMUXTests/IntegrationTests.swift
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
MIT License
2-
31
Copyright (c) 2025 swift-libp2p
42

53
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -12,10 +10,10 @@ furnished to do so, subject to the following conditions:
1210
The above copyright notice and this permission notice shall be included in all
1311
copies or substantial portions of the Software.
1412

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
19+
OR OTHER DEALINGS IN THE SOFTWARE.

Package.swift

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// swift-tools-version: 6.0
2+
//===----------------------------------------------------------------------===//
3+
//
4+
// This source file is part of the swift-libp2p open source project
5+
//
6+
// Copyright (c) 2022-2025 swift-libp2p project authors
7+
// Licensed under MIT
8+
//
9+
// See LICENSE for license information
10+
// See CONTRIBUTORS for the list of swift-libp2p project authors
11+
//
12+
// SPDX-License-Identifier: MIT
13+
//
14+
//===----------------------------------------------------------------------===//
15+
16+
import PackageDescription
17+
18+
let package = Package(
19+
name: "swift-libp2p-yamux",
20+
platforms: [
21+
.macOS(.v10_15),
22+
.iOS(.v13),
23+
],
24+
products: [
25+
// Products define the executables and libraries a package produces, making them visible to other packages.
26+
.library(
27+
name: "LibP2PYAMUX",
28+
targets: ["LibP2PYAMUX"]
29+
)
30+
],
31+
dependencies: [
32+
// Dependencies declare other packages that this package depends on.
33+
34+
// LibP2P Core Modules
35+
.package(url: "https://github.com/swift-libp2p/swift-libp2p.git", .upToNextMinor(from: "0.3.2")),
36+
37+
// NIO Test Utils
38+
.package(url: "https://github.com/apple/swift-nio.git", .upToNextMajor(from: "2.0.0")),
39+
40+
],
41+
targets: [
42+
// Targets are the basic building blocks of a package, defining a module or a test suite.
43+
// Targets can depend on other targets in this package and products from dependencies.
44+
.target(
45+
name: "LibP2PYAMUX",
46+
dependencies: [
47+
.product(name: "LibP2P", package: "swift-libp2p")
48+
]
49+
),
50+
.testTarget(
51+
name: "LibP2PYAMUXTests",
52+
dependencies: [
53+
"LibP2PYAMUX",
54+
.product(name: "NIOTestUtils", package: "swift-nio"),
55+
]
56+
),
57+
]
58+
)

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ let package = Package(
3434
...
3535
dependencies: [
3636
...
37-
.package(url: "https://github.com/swift-libp2p/swift-libp2p-yamux.git", .upToNextMinor(from: "0.0.1"))
37+
.package(url: "https://github.com/swift-libp2p/swift-libp2p-yamux.git", .upToNextMinor(from: "0.2.0"))
3838
],
3939
...
4040
.target(
@@ -71,8 +71,8 @@ Contributions are welcomed! This code is very much a proof of concept. I can gua
7171
Let's make this code better together! 🤝
7272

7373
## Credits
74-
This repo is just a gnarly fork of the beautiful http2 code by the swift nio team below...
75-
- [Swift NIO HTTP/2](https://github.com/apple/swift-nio-http2.git)
74+
This repo is just a modified fork of the beautiful swift-nio-ssh repo...
75+
- [Swift NIO SSH](https://github.com/apple/swift-nio-ssh)
7676
- [YAMUX Spec](https://github.com/libp2p/specs/blob/master/yamux/README.md)
7777

7878
## License
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the swift-libp2p open source project
4+
//
5+
// Copyright (c) 2022-2025 swift-libp2p project authors
6+
// Licensed under MIT
7+
//
8+
// See LICENSE for license information
9+
// See CONTRIBUTORS for the list of swift-libp2p project authors
10+
//
11+
// SPDX-License-Identifier: MIT
12+
//
13+
//===----------------------------------------------------------------------===//
14+
15+
import NIOCore
16+
17+
//extension ByteBuffer {
18+
// /// A helper function for complex readers that will reset a buffer on nil or on error, as though the read
19+
// /// never occurred.
20+
// internal mutating func rewindOnNilOrError<T>(_ body: (inout ByteBuffer) throws -> T?) rethrows -> T? {
21+
// let originalSelf = self
22+
//
23+
// let returnValue: T?
24+
// do {
25+
// returnValue = try body(&self)
26+
// } catch {
27+
// self = originalSelf
28+
// throw error
29+
// }
30+
//
31+
// if returnValue == nil {
32+
// self = originalSelf
33+
// }
34+
//
35+
// return returnValue
36+
// }
37+
//}

0 commit comments

Comments
 (0)