Skip to content

Commit fa6f028

Browse files
committed
Initial release — secure local P2P mesh networking for iOS/macOS
Zero-dependency MultipeerConnectivity library with DTLS encryption, HMAC-SHA256 envelope integrity, multi-hop relay routing, brute-force protection, and host-side pool code authentication.
1 parent 9feb5b8 commit fa6f028

21 files changed

Lines changed: 8670 additions & 0 deletions

‎.gitignore‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
.build/
3+
*.xcodeproj/
4+
xcuserdata/
5+
DerivedData/
6+
.swiftpm/
7+
Package.resolved

‎Package.swift‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// swift-tools-version: 6.0
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "ConnectionPool",
6+
platforms: [.iOS(.v17), .macOS(.v14)],
7+
products: [
8+
.library(name: "ConnectionPool", targets: ["ConnectionPool"]),
9+
],
10+
targets: [
11+
.target(
12+
name: "ConnectionPool",
13+
path: "Sources"
14+
),
15+
]
16+
)

‎README.md‎

Lines changed: 451 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// ConnectionPoolConfiguration.swift
2+
// ConnectionPool
3+
//
4+
// Created by Olib AI (www.olib.ai)
5+
// StealthOS - stealthos.app
6+
7+
import Foundation
8+
9+
/// Protocol for pluggable block list storage.
10+
///
11+
/// Implement this protocol to provide encrypted or otherwise secure persistence
12+
/// for the device block list. If no provider is configured on
13+
/// `ConnectionPoolConfiguration`, `DeviceBlockListService` falls back to plain
14+
/// `UserDefaults`.
15+
public protocol BlockListStorageProvider: Sendable {
16+
/// Persist raw data for the given key.
17+
func save(_ data: Data, forKey key: String) throws
18+
/// Load previously persisted data for the given key, or `nil` if none exists.
19+
func load(forKey key: String) throws -> Data?
20+
}
21+
22+
/// Static configuration point for the ConnectionPool package.
23+
///
24+
/// The host app should call `ConnectionPoolConfiguration.logger = ...` at startup
25+
/// to inject its logging infrastructure. If not configured, a default `os.Logger`
26+
/// fallback is used.
27+
public enum ConnectionPoolConfiguration {
28+
/// Logger instance injected by the host app.
29+
/// Set this before any ConnectionPool APIs are used.
30+
nonisolated(unsafe) public static var logger: ConnectionPoolLogger?
31+
32+
/// Optional secure storage provider for the device block list.
33+
///
34+
/// When set, `DeviceBlockListService` persists block list data through this
35+
/// provider instead of plain `UserDefaults`. The host app should wire this to
36+
/// an encrypted storage backend (e.g., Keychain or SecureDataStore).
37+
///
38+
/// Set this at app startup alongside the logger, before any ConnectionPool
39+
/// APIs are used.
40+
@MainActor public static var blockListStorageProvider: BlockListStorageProvider?
41+
}

‎Sources/ConnectionPool.swift‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// ConnectionPool.swift
2+
// ConnectionPool
3+
//
4+
// Created by Olib AI (www.olib.ai)
5+
// StealthOS - stealthos.app
6+
7+
/// ConnectionPool Module
8+
/// Provides local peer-to-peer connectivity using MultipeerConnectivity framework.
9+
/// Enables secure local chat, multiplayer gaming, and file sharing without internet.
10+
11+
@_exported import Foundation
12+
13+
// Re-export public types
14+
public typealias PeerID = String

‎Sources/Models/BlockedDevice.swift‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// BlockedDevice.swift
2+
// ConnectionPool
3+
//
4+
// Created by Olib AI (www.olib.ai)
5+
// StealthOS - stealthos.app
6+
7+
import Foundation
8+
9+
/// Reason a device was blocked
10+
public enum BlockReason: String, Codable, Sendable {
11+
/// Host manually blocked the device
12+
case manual
13+
/// Device was auto-blocked after too many failed join attempts
14+
case bruteForce
15+
}
16+
17+
/// Represents a device that has been blocked from joining the pool
18+
public struct BlockedDevice: Identifiable, Codable, Sendable {
19+
public let id: String
20+
public let peerDisplayName: String
21+
public let blockedAt: Date
22+
public let reason: BlockReason
23+
24+
public init(
25+
id: String,
26+
peerDisplayName: String,
27+
blockedAt: Date = Date(),
28+
reason: BlockReason
29+
) {
30+
self.id = id
31+
self.peerDisplayName = peerDisplayName
32+
self.blockedAt = blockedAt
33+
self.reason = reason
34+
}
35+
}

0 commit comments

Comments
 (0)