Skip to content

Commit 62ae139

Browse files
authored
tower-abci: gate UDS support for unix OSes (#37)
Follow up to the addition of unix socket support [0], making that feature conditional on building for a target OS family of "unix" [1]. [0] #35 [1] https://doc.rust-lang.org/reference/conditional-compilation.html#target_family Co-authored-by: Conor Schaefer <[email protected]>
1 parent 1e622b1 commit 62ae139

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/v034/server.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
use std::convert::{TryFrom, TryInto};
2-
use std::path::Path;
32

43
use futures::future::{FutureExt, TryFutureExt};
54
use futures::sink::SinkExt;
65
use futures::stream::{FuturesOrdered, StreamExt};
76
use tokio::io::{AsyncReadExt, AsyncWriteExt};
87
use tokio::{
9-
net::{TcpListener, ToSocketAddrs, UnixListener},
8+
net::{TcpListener, ToSocketAddrs},
109
select,
1110
};
12-
use tokio_util::codec::{FramedRead, FramedWrite};
13-
use tower::{Service, ServiceExt};
1411

1512
use crate::BoxError;
1613
use tendermint::abci::MethodKind;
17-
1814
use tendermint::v0_34::abci::{
1915
ConsensusRequest, ConsensusResponse, InfoRequest, InfoResponse, MempoolRequest,
2016
MempoolResponse, Request, Response, SnapshotRequest, SnapshotResponse,
2117
};
18+
use tokio_util::codec::{FramedRead, FramedWrite};
19+
use tower::{Service, ServiceExt};
20+
21+
#[cfg(target_family = "unix")]
22+
use std::path::Path;
23+
#[cfg(target_family = "unix")]
24+
use tokio::net::UnixListener;
2225

2326
/// An ABCI server which listens for connections and forwards requests to four
2427
/// component ABCI [`Service`]s.
@@ -126,6 +129,7 @@ where
126129
ServerBuilder::default()
127130
}
128131

132+
#[cfg(target_family = "unix")]
129133
pub async fn listen_unix(self, path: impl AsRef<Path>) -> Result<(), BoxError> {
130134
let listener = UnixListener::bind(path)?;
131135
let addr = listener.local_addr()?;

src/v037/server.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
use std::convert::{TryFrom, TryInto};
2-
use std::path::Path;
32

43
use futures::future::{FutureExt, TryFutureExt};
54
use futures::sink::SinkExt;
65
use futures::stream::{FuturesOrdered, StreamExt};
76
use tokio::io::{AsyncReadExt, AsyncWriteExt};
87
use tokio::{
9-
net::{TcpListener, ToSocketAddrs, UnixListener},
8+
net::{TcpListener, ToSocketAddrs},
109
select,
1110
};
11+
1212
use tokio_util::codec::{FramedRead, FramedWrite};
1313
use tower::{Service, ServiceExt};
1414

1515
use crate::BoxError;
1616
use tendermint::abci::MethodKind;
1717

18+
#[cfg(target_family = "unix")]
19+
use std::path::Path;
20+
#[cfg(target_family = "unix")]
21+
use tokio::net::UnixListener;
22+
1823
use tendermint::v0_37::abci::{
1924
ConsensusRequest, ConsensusResponse, InfoRequest, InfoResponse, MempoolRequest,
2025
MempoolResponse, Request, Response, SnapshotRequest, SnapshotResponse,
@@ -126,6 +131,7 @@ where
126131
ServerBuilder::default()
127132
}
128133

134+
#[cfg(target_family = "unix")]
129135
pub async fn listen_unix(self, path: impl AsRef<Path>) -> Result<(), BoxError> {
130136
let listener = UnixListener::bind(path)?;
131137
let addr = listener.local_addr()?;

0 commit comments

Comments
 (0)