Skip to content

Linux + iPhone Continuity / iMessage / SMS

fmt

Zack Bartel4d2c0c1bb074
diff --git a/apple/Tether/Protocol/TetherMessage.swift b/apple/Tether/Protocol/TetherMessage.swift
index 277a7c6..dfb7e49 100644
--- a/apple/Tether/Protocol/TetherMessage.swift
+++ b/apple/Tether/Protocol/TetherMessage.swift
@@ -9,7 +9,7 @@ import Foundation
// MARK: - Command Enum
-/// All known command types in the Tether protocol.
+// All known command types in the Tether protocol.
enum TetherCommand: String, Codable, Sendable {
// Client → Daemon
case clipboardSet = "clipboard_set"
@@ -30,11 +30,11 @@ enum TetherCommand: String, Codable, Sendable {
// MARK: - Message
-/// A single Tether protocol message.
-///
-/// Uses a flat structure with optional fields — the daemon's JSON payloads
-/// share a unified shape where only the relevant fields are present
-/// for each command type.
+// A single Tether protocol message.
+//
+// Uses a flat structure with optional fields — the daemon's JSON payloads
+// share a unified shape where only the relevant fields are present
+// for each command type.
struct TetherMessage: Codable, Sendable {
let command: String
@@ -68,27 +68,27 @@ struct TetherMessage: Codable, Sendable {
// MARK: - Convenience Initializers
extension TetherMessage {
- /// Create a `clipboard_set` message.
+ // Create a `clipboard_set` message.
static func clipboardSet(_ text: String) -> TetherMessage {
TetherMessage(command: TetherCommand.clipboardSet.rawValue, content: text)
}
- /// Create a `clipboard_get` request.
+ // Create a `clipboard_get` request.
static func clipboardGet() -> TetherMessage {
TetherMessage(command: TetherCommand.clipboardGet.rawValue)
}
- /// Create a `pair_request` message.
+ // Create a `pair_request` message.
static func pairRequest(deviceName: String) -> TetherMessage {
TetherMessage(command: TetherCommand.pairRequest.rawValue, deviceName: deviceName)
}
- /// Create a `pair_accepted` message (replying to a request).
+ // Create a `pair_accepted` message (replying to a request).
static var pairAccepted: TetherMessage {
TetherMessage(command: TetherCommand.pairAccepted.rawValue)
}
- /// Create a `file_start` message.
+ // Create a `file_start` message.
static func fileStart(filename: String, size: Int64, transferId: String) -> TetherMessage {
TetherMessage(
command: TetherCommand.fileStart.rawValue,
@@ -98,7 +98,7 @@ extension TetherMessage {
)
}
- /// Create a `file_chunk` message.
+ // Create a `file_chunk` message.
static func fileChunk(transferId: String, chunkIndex: Int, data: String) -> TetherMessage {
TetherMessage(
command: TetherCommand.fileChunk.rawValue,
@@ -108,12 +108,12 @@ extension TetherMessage {
)
}
- /// Create a `file_end` message.
+ // Create a `file_end` message.
static func fileEnd(transferId: String) -> TetherMessage {
TetherMessage(command: TetherCommand.fileEnd.rawValue, transferId: transferId)
}
- /// The parsed command enum, if recognized.
+ // The parsed command enum, if recognized.
var parsedCommand: TetherCommand? {
TetherCommand(rawValue: command)
}
diff --git a/apple/Tether/Protocol/TetherProtocol.swift b/apple/Tether/Protocol/TetherProtocol.swift
index 59ba13d..f8b58ba 100644
--- a/apple/Tether/Protocol/TetherProtocol.swift
+++ b/apple/Tether/Protocol/TetherProtocol.swift
@@ -7,8 +7,8 @@
import Foundation
-/// Handles encoding and decoding of `TetherMessage` values using the
-/// newline-delimited JSON wire format spoken by `tetherd`.
+// Handles encoding and decoding of `TetherMessage` values using the
+// newline-delimited JSON wire format spoken by `tetherd`.
enum TetherProtocol {
private static let encoder: JSONEncoder = {
let e = JSONEncoder()
@@ -26,7 +26,7 @@ enum TetherProtocol {
// MARK: - Encoding
- /// Encode a message to its wire representation (JSON + trailing newline).
+ // Encode a message to its wire representation (JSON + trailing newline).
static func encode(_ message: TetherMessage) throws -> Data {
var data = try encoder.encode(message)
data.append(newline)
@@ -35,13 +35,13 @@ enum TetherProtocol {
// MARK: - Decoding
- /// Scan a mutable buffer for complete newline-delimited messages.
- ///
- /// Parsed messages are returned and their bytes are consumed from `buffer`.
- /// Any trailing partial line is left in `buffer` for the next call.
- ///
- /// Lines that fail JSON parsing (e.g. the daemon's bare `OK\n` response)
- /// are silently skipped.
+ // Scan a mutable buffer for complete newline-delimited messages.
+ //
+ // Parsed messages are returned and their bytes are consumed from `buffer`.
+ // Any trailing partial line is left in `buffer` for the next call.
+ //
+ // Lines that fail JSON parsing (e.g. the daemon's bare `OK\n` response)
+ // are silently skipped.
static func decode(buffer: inout Data) -> [TetherMessage] {
var messages: [TetherMessage] = []
diff --git a/apple/Tether/Services/BonjourDiscovery.swift b/apple/Tether/Services/BonjourDiscovery.swift
index cd59896..6f6608b 100644
--- a/apple/Tether/Services/BonjourDiscovery.swift
+++ b/apple/Tether/Services/BonjourDiscovery.swift
@@ -8,7 +8,7 @@
import Foundation
import Network
-/// A single discovered `tetherd` instance on the local network.
+// A single discovered `tetherd` instance on the local network.
struct DiscoveredHost: Identifiable, Sendable {
let id = UUID()
let name: String
@@ -16,22 +16,22 @@ struct DiscoveredHost: Identifiable, Sendable {
let fingerprint: String
}
-/// Scans the local network for `tetherd` daemons advertising `_tether._tcp`
-/// via Bonjour/mDNS and exposes the results as an observable list.
+// Scans the local network for `tetherd` daemons advertising `_tether._tcp`
+// via Bonjour/mDNS and exposes the results as an observable list.
@Observable
final class BonjourDiscovery {
private static let serviceType = "_tether._tcp"
- /// Our own fingerprint, to filter ourselves out of the results.
+ // Our own fingerprint, to filter ourselves out of the results.
var localFingerprint: String?
- /// Our own device name, as a fallback filter if the TXT record hasn't arrived.
+ // Our own device name, as a fallback filter if the TXT record hasn't arrived.
var localDeviceName: String?
- /// Currently discovered hosts (updated live as services appear/disappear).
+ // Currently discovered hosts (updated live as services appear/disappear).
private(set) var hosts: [DiscoveredHost] = []
- /// Whether the browser is actively scanning.
+ // Whether the browser is actively scanning.
private(set) var isScanning = false
private var browser: NWBrowser?
@@ -39,7 +39,7 @@ final class BonjourDiscovery {
// MARK: - Public
- /// Start scanning for `_tether._tcp` services.
+ // Start scanning for `_tether._tcp` services.
func startScanning(forceRestart: Bool = false) {
if forceRestart {
stopScanning(clearHosts: true)
@@ -79,7 +79,7 @@ final class BonjourDiscovery {
self.browser = browser
}
- /// Stop scanning.
+ // Stop scanning.
func stopScanning(clearHosts: Bool = false) {
browser?.cancel()
browser = nil
diff --git a/apple/Tether/Services/CertificateManager.swift b/apple/Tether/Services/CertificateManager.swift
index e5e2b0e..348302a 100644
--- a/apple/Tether/Services/CertificateManager.swift
+++ b/apple/Tether/Services/CertificateManager.swift
@@ -11,8 +11,8 @@ import Security
import CryptoKit
import UIKit
-/// Manages the app's TLS identity (self-signed RSA cert + private key)
-/// and the set of known remote host fingerprints.
+// Manages the app's TLS identity (self-signed RSA cert + private key)
+// and the set of known remote host fingerprints.
@Observable
final class CertificateManager {
private static let keyTag = "net.jeedup.Tether.key"
@@ -20,25 +20,25 @@ final class CertificateManager {
private static let knownHostsKey = "TetherKnownHosts"
private static let localDeviceNameKey = "TetherLocalDeviceName"
- /// SHA-256 fingerprint of our own certificate (lowercase hex, no separators).
+ // SHA-256 fingerprint of our own certificate (lowercase hex, no separators).
private(set) var myFingerprint: String = ""
- /// Map of known host fingerprints → device name.
+ // Map of known host fingerprints → device name.
private(set) var knownHosts: [String: String] = [:]
- /// Name of this device as presented to others.
+ // Name of this device as presented to others.
var localDeviceName: String = "" {
didSet {
UserDefaults.standard.set(localDeviceName, forKey: Self.localDeviceNameKey)
}
}
- /// The `SecIdentity` used for mTLS client authentication.
+ // The `SecIdentity` used for mTLS client authentication.
private var identity: SecIdentity?
// MARK: - Initialization
- /// Load or create the TLS identity and populate known hosts.
+ // Load or create the TLS identity and populate known hosts.
func initialize() {
loadKnownHosts()
loadLocalDeviceName()
@@ -58,7 +58,7 @@ final class CertificateManager {
myFingerprint = fingerprintFromIdentity(newIdentity) ?? ""
}
- /// Returns the `SecIdentity` for use with `Network.framework` TLS options.
+ // Returns the `SecIdentity` for use with `Network.framework` TLS options.
func getIdentity() -> SecIdentity? {
identity
}
@@ -81,8 +81,8 @@ final class CertificateManager {
// MARK: - Fingerprint
- /// Compute the SHA-256 fingerprint of a DER-encoded certificate.
- /// Output matches the daemon's `generate_fingerprint`: lowercase hex, no separators.
+ // Compute the SHA-256 fingerprint of a DER-encoded certificate.
+ // Output matches the daemon's `generate_fingerprint`: lowercase hex, no separators.
static func fingerprint(ofCertificate cert: SecCertificate) -> String {
let der = SecCertificateCopyData(cert) as Data
let hash = SHA256.hash(data: der)
@@ -154,8 +154,8 @@ final class CertificateManager {
// MARK: - Private — Certificate Generation
- /// Generate a 2048-bit RSA keypair + self-signed X.509v3 certificate and
- /// store both in the Keychain as a `SecIdentity`.
+ // Generate a 2048-bit RSA keypair + self-signed X.509v3 certificate and
+ // store both in the Keychain as a `SecIdentity`.
private func generateAndStoreIdentity() -> SecIdentity? {
// 1. Generate RSA 2048 keypair in Keychain
let keyAttrs: [String: Any] = [
@@ -219,7 +219,7 @@ final class CertificateManager {
// MARK: - ASN.1 DER Construction
- /// Build a minimal self-signed X.509v3 certificate in DER format.
+ // Build a minimal self-signed X.509v3 certificate in DER format.
private func buildSelfSignedCertificate(
publicKeyDER: Data,
privateKey: SecKey,
diff --git a/apple/Tether/Services/TetherConnection.swift b/apple/Tether/Services/TetherConnection.swift
index 11debed..f2aef78 100644
--- a/apple/Tether/Services/TetherConnection.swift
+++ b/apple/Tether/Services/TetherConnection.swift
@@ -10,7 +10,7 @@ import Foundation
import Network
import Security
-/// Connection state exposed to the UI.
+// Connection state exposed to the UI.
enum ConnectionState: Sendable, Equatable {
case disconnected
case connecting
@@ -18,36 +18,36 @@ enum ConnectionState: Sendable, Equatable {
case failed(String)
}
-/// Manages a single TCP+TLS connection to a `tetherd` instance.
-///
-/// Uses `Network.framework` (`NWConnection`) with custom TLS options that:
-/// - Present our self-signed client certificate for mTLS.
-/// - Accept any server certificate (the daemon also uses self-signed certs).
-/// - Capture the server's SHA-256 fingerprint during the TLS handshake.
+// Manages a single TCP+TLS connection to a `tetherd` instance.
+//
+// Uses `Network.framework` (`NWConnection`) with custom TLS options that:
+// - Present our self-signed client certificate for mTLS.
+// - Accept any server certificate (the daemon also uses self-signed certs).
+// - Capture the server's SHA-256 fingerprint during the TLS handshake.
@Observable
final class TetherConnection {
- /// Current connection state.
+ // Current connection state.
private(set) var state: ConnectionState = .disconnected
- /// The server's TLS certificate fingerprint, captured during handshake.
+ // The server's TLS certificate fingerprint, captured during handshake.
private(set) var serverFingerprint: String = ""
private var connection: NWConnection?
private var receiveBuffer = Data()
- /// Callback invoked on the main queue for each decoded message.
+ // Callback invoked on the main queue for each decoded message.
var onMessage: ((TetherMessage) -> Void)?
- /// Callback invoked when the connection state changes.
+ // Callback invoked when the connection state changes.
var onStateChange: ((ConnectionState) -> Void)?
// MARK: - Public API
- /// Connect to a discovered tetherd endpoint using mTLS.
- ///
- /// - Parameters:
- /// - endpoint: The Bonjour or direct `NWEndpoint` to connect to.
- /// - identity: The client's `SecIdentity` for mTLS authentication.
+ // Connect to a discovered tetherd endpoint using mTLS.
+ //
+ // - Parameters:
+ // - endpoint: The Bonjour or direct `NWEndpoint` to connect to.
+ // - identity: The client's `SecIdentity` for mTLS authentication.
func connect(to endpoint: NWEndpoint, identity: SecIdentity) {
disconnect()
@@ -83,7 +83,7 @@ final class TetherConnection {
updateState(.connecting)
}
- /// Connect directly to a host:port (for manual connection).
+ // Connect directly to a host:port (for manual connection).
func connect(host: String, port: UInt16, identity: SecIdentity) {
let endpoint = NWEndpoint.hostPort(
host: NWEndpoint.Host(host),
@@ -92,11 +92,11 @@ final class TetherConnection {
connect(to: endpoint, identity: identity)
}
- /// Accept a pre-established incoming connection from `TetherServer`.
- ///
- /// - Parameters:
- /// - connection: The `NWConnection` already established and in `.ready` state.
- /// - fingerprint: The verified TLS fingerprint of the incoming client.
+ // Accept a pre-established incoming connection from `TetherServer`.
+ //
+ // - Parameters:
+ // - connection: The `NWConnection` already established and in `.ready` state.
+ // - fingerprint: The verified TLS fingerprint of the incoming client.
func accept(incomingConnection conn: NWConnection, fingerprint: String) {
disconnect()
self.serverFingerprint = fingerprint
@@ -112,7 +112,7 @@ final class TetherConnection {
startReceiving()
}
- /// Disconnect and tear down the connection.
+ // Disconnect and tear down the connection.
func disconnect() {
connection?.cancel()
connection = nil
@@ -121,7 +121,7 @@ final class TetherConnection {
updateState(.disconnected)
}
- /// Send a protocol message to the daemon.
+ // Send a protocol message to the daemon.
func send(_ message: TetherMessage) {
guard let conn = connection else { return }
@@ -201,7 +201,7 @@ final class TetherConnection {
// MARK: - Private — TLS Fingerprint
- /// Extract the server's certificate and compute its SHA-256 fingerprint.
+ // Extract the server's certificate and compute its SHA-256 fingerprint.
private func captureServerFingerprint(trust: sec_trust_t) {
let secTrust = sec_trust_copy_ref(trust).takeRetainedValue()
diff --git a/apple/Tether/Services/TetherServer.swift b/apple/Tether/Services/TetherServer.swift
index e42acf7..4cfcf7a 100644
--- a/apple/Tether/Services/TetherServer.swift
+++ b/apple/Tether/Services/TetherServer.swift
@@ -17,7 +17,7 @@ final class TetherServer: NSObject, NetServiceDelegate {
var isListening = false
- /// Callback when a verified inbound connection is received
+ // Callback when a verified inbound connection is received
var onNewConnection: ((NWConnection, String) -> Void)?
func start(identity: SecIdentity, localDeviceName: String, fingerprint: String) {
diff --git a/apple/Tether/ViewModels/TetherViewModel.swift b/apple/Tether/ViewModels/TetherViewModel.swift
index 771e39e..38c9137 100644
--- a/apple/Tether/ViewModels/TetherViewModel.swift
+++ b/apple/Tether/ViewModels/TetherViewModel.swift
@@ -11,7 +11,7 @@ import SwiftUI
import UniformTypeIdentifiers
import UIKit
-/// High-level app state.
+// High-level app state.
enum AppConnectionState: Equatable {
case disconnected
case discovering
@@ -20,7 +20,7 @@ enum AppConnectionState: Equatable {
case connected
}
-/// A clipboard history entry.
+// A clipboard history entry.
struct ClipboardEntry: Identifiable {
let id = UUID()
let content: String
@@ -45,7 +45,7 @@ struct ClipboardEntry: Identifiable {
}
}
-/// Tracks an active file transfer.
+// Tracks an active file transfer.
struct FileTransfer: Identifiable {
enum Direction {
case outgoing
@@ -73,35 +73,35 @@ final class TetherViewModel {
// MARK: - Published State
- /// Whether clipboard updates from remote devices are automatically written to the local pasteboard.
+ // Whether clipboard updates from remote devices are automatically written to the local pasteboard.
var autoSyncClipboard: Bool = true {
didSet {
UserDefaults.standard.set(autoSyncClipboard, forKey: TetherViewModel.autoSyncClipboardKey)
}
}
- /// Overall connection state.
+ // Overall connection state.
private(set) var appState: AppConnectionState = .disconnected
- /// Name of the connected device, if any.
+ // Name of the connected device, if any.
private(set) var connectedDeviceName: String?
- /// Clipboard history (most recent first).
+ // Clipboard history (most recent first).
private(set) var clipboardHistory: [ClipboardEntry] = []
- /// Active file transfers.
+ // Active file transfers.
private(set) var activeTransfers: [FileTransfer] = []
- /// Completed file transfers.
+ // Completed file transfers.
private(set) var completedTransfers: [FileTransfer] = []
- /// Whether the pairing sheet should be presented.
+ // Whether the pairing sheet should be presented.
var showPairingSheet = false
- /// Status message for the pairing flow.
+ // Status message for the pairing flow.
private(set) var pairingStatus: String = ""
- /// Error message to display, if any.
+ // Error message to display, if any.
var errorMessage: String?
// MARK: - Services
@@ -111,7 +111,7 @@ final class TetherViewModel {
let connection = TetherConnection()
let server = TetherServer()
- /// The chunk size for file transfers (48KB raw → 64KB base64).
+ // The chunk size for file transfers (48KB raw → 64KB base64).
private let fileChunkSize = 48 * 1024
private var hasInitialized = false
private var pendingReconnectTask: Task<Void, Never>?
@@ -129,7 +129,7 @@ final class TetherViewModel {
// MARK: - Initialization
- /// Call once at app startup.
+ // Call once at app startup.
func initialize() {
guard !hasInitialized else { return }
hasInitialized = true
@@ -185,7 +185,7 @@ final class TetherViewModel {
// MARK: - Connection
- /// Connect to a discovered host.
+ // Connect to a discovered host.
func connectTo(host: DiscoveredHost) {
guard let identity = certificateManager.getIdentity() else {
errorMessage = "TLS identity not available. Please restart the app."
@@ -198,7 +198,7 @@ final class TetherViewModel {
connection.connect(to: host.endpoint, identity: identity)
}
- /// Connect by IP address and port.
+ // Connect by IP address and port.
func connectTo(host: String, port: UInt16) {
guard let identity = certificateManager.getIdentity() else {
errorMessage = "TLS identity not available. Please restart the app."
@@ -211,7 +211,7 @@ final class TetherViewModel {
connection.connect(host: host, port: port, identity: identity)
}
- /// Disconnect from the daemon.
+ // Disconnect from the daemon.
func disconnect() {
manualDisconnect = true
pendingReconnectTask?.cancel()
@@ -225,7 +225,7 @@ final class TetherViewModel {
// MARK: - Clipboard
- /// Send the current iOS clipboard content to the daemon.
+ // Send the current iOS clipboard content to the daemon.
func sendClipboard() {
#if canImport(UIKit)
guard let text = UIPasteboard.general.string, !text.isEmpty else {
@@ -251,12 +251,12 @@ final class TetherViewModel {
}
}
- /// Request the current clipboard from the daemon.
+ // Request the current clipboard from the daemon.
func requestClipboard() {
connection.send(.clipboardGet())
}
- /// Copy a clipboard entry to the iOS pasteboard.
+ // Copy a clipboard entry to the iOS pasteboard.
func copyToLocalClipboard(_ text: String) {
#if canImport(UIKit)
UIPasteboard.general.string = text
@@ -268,7 +268,7 @@ final class TetherViewModel {
// MARK: - File Transfer
- /// Send a file to the daemon using its URL.
+ // Send a file to the daemon using its URL.
func sendFile(url: URL) {
let isSecurityScoped = url.startAccessingSecurityScopedResource()
let filename = url.lastPathComponent
@@ -288,7 +288,7 @@ final class TetherViewModel {
}
}
- /// Send raw data to the daemon.
+ // Send raw data to the daemon.
func sendFile(data fileData: Data, filename: String) {
let transferId = UUID().uuidString
let totalSize = Int64(fileData.count)
@@ -609,9 +609,9 @@ final class TetherViewModel {
}
}
- /// Call after the daemon accepts the pairing request.
- /// The daemon will start accepting our commands, so we just need to
- /// save the server fingerprint and transition to connected state.
+ // Call after the daemon accepts the pairing request.
+ // The daemon will start accepting our commands, so we just need to
+ // save the server fingerprint and transition to connected state.
func confirmPairing() {
let serverFP = connection.serverFingerprint
let name = connectedDeviceName ?? "Desktop"
diff --git a/apple/Tether/Views/AppStoreScreenshots.swift b/apple/Tether/Views/AppStoreScreenshots.swift
index ffaf9c6..596009b 100644
--- a/apple/Tether/Views/AppStoreScreenshots.swift
+++ b/apple/Tether/Views/AppStoreScreenshots.swift
@@ -12,8 +12,8 @@ import SwiftUI
// MARK: - Screenshot Configurations
-/// A container view designed perfectly to show off the App Store screenshots
-/// for the main active states of the Tether application.
+// A container view designed perfectly to show off the App Store screenshots
+// for the main active states of the Tether application.
struct AppStoreScreenshots: View {
@State private var selectedTab = 0
@@ -42,9 +42,9 @@ struct AppStoreScreenshots: View {
// MARK: - Previews
-/// Use Xcode Previews to configure your simulator to exactly what you need.
-/// Run this specific preview on the Simulator and use the simulator's
-/// built-in "Save Screen" (Cmd+S) or `xcrun simctl io booted screenshot` feature.
+// Use Xcode Previews to configure your simulator to exactly what you need.
+// Run this specific preview on the Simulator and use the simulator's
+// built-in "Save Screen" (Cmd+S) or `xcrun simctl io booted screenshot` feature.
#Preview("App Store: Full App (Dark)") {
AppStoreScreenshots()
.preferredColorScheme(.dark)
diff --git a/src/core/include/tether/clipboard.hpp b/src/core/include/tether/clipboard.hpp
index 852edb7..c8c6ea9 100644
--- a/src/core/include/tether/clipboard.hpp
+++ b/src/core/include/tether/clipboard.hpp
@@ -1,10 +1,10 @@
#include "tether/event_loop.hpp"
-#include <wayland-client.h>
#include <functional>
+#include <map>
#include <memory>
#include <string>
#include <vector>
-#include <map>
+#include <wayland-client.h>
class CCZwlrDataControlManagerV1;
class CCWlSeat;
@@ -15,7 +15,10 @@ namespace tether {
class ClipboardManager {
public:
- ClipboardManager(CCZwlrDataControlManagerV1* manager, CCWlSeat* seat, EpollEventLoop& loop, wl_display* display);
+ ClipboardManager(CCZwlrDataControlManagerV1* manager,
+ CCWlSeat* seat,
+ EpollEventLoop& loop,
+ wl_display* display);
~ClipboardManager();
// Set callback to receive native Wayland clipboard updates
diff --git a/src/core/include/tether/discovery.hpp b/src/core/include/tether/discovery.hpp
index 22c2ac5..b6ccdf7 100644
--- a/src/core/include/tether/discovery.hpp
+++ b/src/core/include/tether/discovery.hpp
@@ -8,35 +8,35 @@
namespace tether {
- /// A single network address where a tetherd instance is reachable.
+ // A single network address where a tetherd instance is reachable.
struct DiscoveredAddress {
- std::string address; ///< IPv4 or IPv6 address
- uint16_t port = 0; ///< TCP port
+ std::string address; //< IPv4 or IPv6 address
+ uint16_t port = 0; //< TCP port
};
- /// Raw per-interface mDNS result (one entry per resolved address).
+ // Raw per-interface mDNS result (one entry per resolved address).
struct DiscoveredHost {
- std::string name; ///< Advertised service name (e.g. hostname)
- std::string address; ///< Resolved IPv4/IPv6 address
- uint16_t port = 0; ///< TCP port the daemon is listening on
- std::string fingerprint; ///< TLS certificate SHA-256 fingerprint from TXT record
+ std::string name; //< Advertised service name (e.g. hostname)
+ std::string address; //< Resolved IPv4/IPv6 address
+ uint16_t port = 0; //< TCP port the daemon is listening on
+ std::string fingerprint; //< TLS certificate SHA-256 fingerprint from TXT record
};
- /// A logical device, grouping all network interfaces that share the same
- /// TLS fingerprint (i.e. the same tetherd instance).
+ // A logical device, grouping all network interfaces that share the same
+ // TLS fingerprint (i.e. the same tetherd instance).
struct DiscoveredDevice {
- std::string name; ///< Advertised service name
- std::string fingerprint; ///< Shared TLS fingerprint
- std::vector<DiscoveredAddress> addresses; ///< All reachable addresses
+ std::string name; //< Advertised service name
+ std::string fingerprint; //< Shared TLS fingerprint
+ std::vector<DiscoveredAddress> addresses; //< All reachable addresses
};
- /// Group raw per-interface results into logical devices by fingerprint.
+ // Group raw per-interface results into logical devices by fingerprint.
std::vector<DiscoveredDevice> group_discovered_hosts(const std::vector<DiscoveredHost>& hosts);
- /// mDNS service discovery using Avahi.
- ///
- /// The daemon calls publish() to advertise itself as `_tether._tcp`.
- /// Clients call discover() to find daemon instances on the LAN.
+ // mDNS service discovery using Avahi.
+ //
+ // The daemon calls publish() to advertise itself as `_tether._tcp`.
+ // Clients call discover() to find daemon instances on the LAN.
class Discovery {
public:
Discovery();
@@ -48,29 +48,29 @@ namespace tether {
Discovery(Discovery&&) noexcept;
Discovery& operator=(Discovery&&) noexcept;
- /// Publish this tetherd instance on the local network.
- /// @param name Human-readable service name (typically the hostname).
- /// @param port TCP port the daemon is listening on.
- /// @param fingerprint SHA-256 fingerprint of the daemon's TLS certificate.
- /// @return true if the service was successfully registered.
+ // Publish this tetherd instance on the local network.
+ // @param name Human-readable service name (typically the hostname).
+ // @param port TCP port the daemon is listening on.
+ // @param fingerprint SHA-256 fingerprint of the daemon's TLS certificate.
+ // @return true if the service was successfully registered.
bool publish(const std::string& name, uint16_t port, const std::string& fingerprint);
- /// Stop advertising this instance. Called automatically by the destructor.
+ // Stop advertising this instance. Called automatically by the destructor.
void unpublish();
- /// Scan the local network for tetherd instances.
- /// Blocks for up to @p timeout_ms milliseconds and returns all hosts found.
- /// @param timeout_ms How long to listen for mDNS responses (default 3 s).
- /// @return A list of discovered hosts (one per interface), possibly empty.
+ // Scan the local network for tetherd instances.
+ // Blocks for up to @p timeout_ms milliseconds and returns all hosts found.
+ // @param timeout_ms How long to listen for mDNS responses (default 3 s).
+ // @return A list of discovered hosts (one per interface), possibly empty.
std::vector<DiscoveredHost> discover(int timeout_ms = 3000);
- /// Start continuous background discovery.
- /// The callback is invoked whenever a new device is found or an existing device is removed.
- /// The callback is executed on the background Avahi thread.
- /// Only one continuous browse session can run per Discovery instance.
+ // Start continuous background discovery.
+ // The callback is invoked whenever a new device is found or an existing device is removed.
+ // The callback is executed on the background Avahi thread.
+ // Only one continuous browse session can run per Discovery instance.
void start_continuous_browse(std::function<void(const std::vector<DiscoveredDevice>&)> callback);
-
- /// Stop continuous background discovery.
+
+ // Stop continuous background discovery.
void stop_continuous_browse();
private:
diff --git a/src/core/include/tether/file_transfer.hpp b/src/core/include/tether/file_transfer.hpp
index f4a1d81..0a76e49 100644
--- a/src/core/include/tether/file_transfer.hpp
+++ b/src/core/include/tether/file_transfer.hpp
@@ -1,8 +1,8 @@
#pragma once
#include <filesystem>
-#include <functional>
#include <fstream>
+#include <functional>
#include <map>
#include <memory>
#include <mutex>