fix(network): skip unix listener on windows (#287)

This commit is contained in:
Santiago Carmuega 2023-09-11 03:31:05 +02:00 committed by GitHub
parent a0e96bd309
commit 673aaf95f0
2 changed files with 7 additions and 3 deletions

View file

@ -1,10 +1,13 @@
use std::path::Path; use std::path::Path;
use thiserror::Error; use thiserror::Error;
use tokio::net::{TcpListener, UnixListener}; use tokio::net::TcpListener;
use tokio::task::JoinHandle; use tokio::task::JoinHandle;
use tracing::{debug, error}; use tracing::{debug, error};
#[cfg(not(target_os = "windows"))]
use tokio::net::UnixListener;
use crate::miniprotocols::handshake::{n2c, n2n, Confirmation, VersionNumber}; use crate::miniprotocols::handshake::{n2c, n2n, Confirmation, VersionNumber};
use crate::miniprotocols::PROTOCOL_N2N_HANDSHAKE; use crate::miniprotocols::PROTOCOL_N2N_HANDSHAKE;
use crate::{ use crate::{
@ -250,6 +253,7 @@ pub struct NodeServer {
// statequery: localstate::Server, // statequery: localstate::Server,
} }
#[cfg(not(target_os = "windows"))]
impl NodeServer { impl NodeServer {
pub async fn accept(listener: &UnixListener, magic: u64) -> Result<Self, Error> { pub async fn accept(listener: &UnixListener, magic: u64) -> Result<Self, Error> {
let (bearer, _) = Bearer::accept_unix(listener) let (bearer, _) = Bearer::accept_unix(listener)

View file

@ -6,14 +6,14 @@ use std::net::SocketAddr;
use std::path::Path; use std::path::Path;
use thiserror::Error; use thiserror::Error;
use tokio::io::AsyncWriteExt; use tokio::io::AsyncWriteExt;
use tokio::net::{TcpListener, TcpStream, ToSocketAddrs, UnixListener}; use tokio::net::{TcpListener, TcpStream, ToSocketAddrs};
use tokio::select; use tokio::select;
use tokio::sync::mpsc::error::SendError; use tokio::sync::mpsc::error::SendError;
use tokio::time::Instant; use tokio::time::Instant;
use tracing::{debug, error, trace}; use tracing::{debug, error, trace};
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
use tokio::net::UnixStream; use tokio::net::{UnixListener, UnixStream};
const HEADER_LEN: usize = 8; const HEADER_LEN: usize = 8;