Linux + iPhone Continuity / iMessage / SMS
fmt
Zack Bartel08f12bdd73cf
diff --git a/src/core/include/tether/client.hpp b/src/core/include/tether/client.hppindex 28e7f45..5d897eb 100644--- a/src/core/include/tether/client.hpp+++ b/src/core/include/tether/client.hpp@@ -1,39 +1,39 @@#pragma once-#include <string>#include <openssl/ssl.h>+#include <string>#include <vector>namespace tether {-class Client {-public:- Client();- ~Client();+ class Client {+ public:+ Client();+ ~Client();++ // host="" uses the local UNIX socket, auto-launching the daemon if needed.+ // host!="" opens a TCP+TLS connection to a remote daemon.+ bool connect(const std::string& host = "", int port = 5134);+ void disconnect();+ bool is_connected() const;- // host="" uses the local UNIX socket, auto-launching the daemon if needed.- // host!="" opens a TCP+TLS connection to a remote daemon.- bool connect(const std::string& host = "", int port = 5134);- void disconnect();- bool is_connected() const;+ // Base Level payload loop+ std::string send_and_wait(const std::string& payload);- // Base Level payload loop- std::string send_and_wait(const std::string& payload);+ // High Level Features+ std::string get_clipboard(std::string& err_out);+ bool set_clipboard(const std::string& text, std::string& err_out);- // High Level Features- std::string get_clipboard(std::string& err_out);- bool set_clipboard(const std::string& text, std::string& err_out);-- std::string list_devices();- bool accept_device(const std::string& fingerprint, const std::string& name = "Paired Device");- std::string pair(const std::string& device_name, std::string& err_out);+ std::string list_devices();+ bool accept_device(const std::string& fingerprint, const std::string& name = "Paired Device");+ std::string pair(const std::string& device_name, std::string& err_out);- bool send_file(const std::string& path, std::string& err_out);+ bool send_file(const std::string& path, std::string& err_out);-private:- int connect_unix(bool retry);+ private:+ int connect_unix(bool retry);- int sock_ = -1;- SSL* ssl_ = nullptr;-};+ int sock_ = -1;+ SSL* ssl_ = nullptr;+ };} // namespace tetherdiff --git a/src/core/include/tether/discovery.hpp b/src/core/include/tether/discovery.hppindex 69e6e0c..d89237d 100644--- a/src/core/include/tether/discovery.hpp+++ b/src/core/include/tether/discovery.hpp@@ -9,23 +9,23 @@ namespace tether {/// 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).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).struct DiscoveredDevice {- std::string name; ///< Advertised service name- std::string fingerprint; ///< Shared TLS fingerprint+ std::string name; ///< Advertised service name+ std::string fingerprint; ///< Shared TLS fingerprintstd::vector<DiscoveredAddress> addresses; ///< All reachable addresses};@@ -52,8 +52,7 @@ namespace tether {/// @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);+ bool publish(const std::string& name, uint16_t port, const std::string& fingerprint);/// Stop advertising this instance. Called automatically by the destructor.void unpublish();@@ -70,4 +69,3 @@ namespace tether {};} // namespace tether-diff --git a/src/core/include/tether/net.hpp b/src/core/include/tether/net.hppindex 727e5a1..d59f126 100644--- a/src/core/include/tether/net.hpp+++ b/src/core/include/tether/net.hpp@@ -51,9 +51,7 @@ namespace tether {private:void handle_accept(int fd);void handle_client(int client_fd);- void spawn_pair_dialog(int client_fd, SSL* ssl,- const std::string& fingerprint,- const std::string& device_name);+ void spawn_pair_dialog(int client_fd, SSL* ssl, const std::string& fingerprint, const std::string& device_name);EpollEventLoop& loop_;int server_fd_ = -1;