]> nmode's Git Repositories - signal-cli/commitdiff
Compile UnixStream support only on unix systems
authorAsamK <asamk@gmx.de>
Sat, 12 Jul 2025 09:41:52 +0000 (11:41 +0200)
committerAsamK <asamk@gmx.de>
Sat, 12 Jul 2025 09:42:12 +0000 (11:42 +0200)
client/src/cli.rs
client/src/jsonrpc.rs
client/src/main.rs
client/src/transports/mod.rs

index e0abb717b03ec731e830e8cb98190dc2e2dd5f00..90809e1b77494c4edddb5569d0d509ac9112dc51 100644 (file)
@@ -15,6 +15,7 @@ pub struct Cli {
     pub json_rpc_tcp: Option<Option<SocketAddr>>,
 
     /// UNIX socket address and port of signal-cli daemon
     pub json_rpc_tcp: Option<Option<SocketAddr>>,
 
     /// UNIX socket address and port of signal-cli daemon
+    #[cfg(unix)]
     #[arg(long, conflicts_with = "json_rpc_tcp")]
     pub json_rpc_socket: Option<Option<OsString>>,
 
     #[arg(long, conflicts_with = "json_rpc_tcp")]
     pub json_rpc_socket: Option<Option<OsString>>,
 
index 3b6d583bb9a55a0ea1b1c5d873d1cf6b5c040432..6874652dc0750a3a8026985cc3b758684bea4969 100644 (file)
@@ -410,6 +410,7 @@ pub async fn connect_tcp(
     Ok(ClientBuilder::default().build_with_tokio(sender, receiver))
 }
 
     Ok(ClientBuilder::default().build_with_tokio(sender, receiver))
 }
 
+#[cfg(unix)]
 pub async fn connect_unix(
     socket_path: impl AsRef<Path>,
 ) -> Result<impl SubscriptionClientT, std::io::Error> {
 pub async fn connect_unix(
     socket_path: impl AsRef<Path>,
 ) -> Result<impl SubscriptionClientT, std::io::Error> {
index 6466b2e628d4d7a216e1f19c9cdcd8b8f4ad13b6..f82ee237eb3a23f5aca8cf386f66cbc667467b0d 100644 (file)
@@ -482,23 +482,30 @@ async fn connect(cli: Cli) -> Result<Value, RpcError> {
 
         handle_command(cli, client).await
     } else {
 
         handle_command(cli, client).await
     } else {
-        let socket_path = cli
-            .json_rpc_socket
-            .clone()
-            .unwrap_or(None)
-            .or_else(|| {
-                std::env::var_os("XDG_RUNTIME_DIR").map(|runtime_dir| {
-                    PathBuf::from(runtime_dir)
-                        .join(DEFAULT_SOCKET_SUFFIX)
-                        .into()
+        #[cfg(windows)]
+        {
+            Err(RpcError::Custom("Invalid socket".into()))
+        }
+        #[cfg(unix)]
+        {
+            let socket_path = cli
+                .json_rpc_socket
+                .clone()
+                .unwrap_or(None)
+                .or_else(|| {
+                    std::env::var_os("XDG_RUNTIME_DIR").map(|runtime_dir| {
+                        PathBuf::from(runtime_dir)
+                            .join(DEFAULT_SOCKET_SUFFIX)
+                            .into()
+                    })
                 })
                 })
-            })
-            .unwrap_or_else(|| ("/run".to_owned() + DEFAULT_SOCKET_SUFFIX).into());
-        let client = jsonrpc::connect_unix(socket_path)
-            .await
-            .map_err(|e| RpcError::Custom(format!("Failed to connect to socket: {e}")))?;
+                .unwrap_or_else(|| ("/run".to_owned() + DEFAULT_SOCKET_SUFFIX).into());
+            let client = jsonrpc::connect_unix(socket_path)
+                .await
+                .map_err(|e| RpcError::Custom(format!("Failed to connect to socket: {e}")))?;
 
 
-        handle_command(cli, client).await
+            handle_command(cli, client).await
+        }
     }
 }
 
     }
 }
 
index ad552cbf12e3b00e71421fd105766b283fd5b3b3..ed1963a0639ade4cc6ecb54730464225b8dbc3d6 100644 (file)
@@ -2,6 +2,7 @@ use futures_util::{stream::StreamExt, Sink, SinkExt, Stream};
 use jsonrpsee::core::client::{ReceivedMessage, TransportReceiverT, TransportSenderT};
 use thiserror::Error;
 
 use jsonrpsee::core::client::{ReceivedMessage, TransportReceiverT, TransportSenderT};
 use thiserror::Error;
 
+#[cfg(unix)]
 pub mod ipc;
 mod stream_codec;
 pub mod tcp;
 pub mod ipc;
 mod stream_codec;
 pub mod tcp;