pull/146/head
Chip Senkbeil 2 years ago
parent cb6e7e85cd
commit 2abc9b9220
No known key found for this signature in database
GPG Key ID: 35EF1F8EC72A4131

@ -429,11 +429,6 @@ where
type Response = DistantMsg<DistantResponseData>;
type LocalData = D;
/// Overridden to leverage [`DistantApi`] implementation of `config`
fn config(&self) -> ServerConfig {
T::config(&self.api)
}
/// Overridden to leverage [`DistantApi`] implementation of `on_accept`
async fn on_accept(&self, local_data: &mut Self::LocalData) {
T::on_accept(&self.api, local_data).await

@ -3,7 +3,9 @@ use crate::{
ManagerRequest, ManagerResponse, Map,
};
use async_trait::async_trait;
use distant_net::{Client, Listener, MpscListener, Request, Response, ServerCtx, ServerHandler};
use distant_net::{
Client, Listener, MpscListener, Request, Response, Server, ServerCtx, ServerHandler,
};
use log::*;
use std::{collections::HashMap, io, sync::Arc};
use tokio::{
@ -188,7 +190,7 @@ impl DistantManager {
}
.to_lowercase();
let (writer, reader) = {
let transport = {
let lock = self.connect_handlers.read().await;
let handler = lock.get(&scheme).ok_or_else(|| {
io::Error::new(
@ -199,7 +201,7 @@ impl DistantManager {
handler.connect(&destination, &options, auth).await?
};
let connection = DistantManagerConnection::new(destination, options, writer, reader);
let connection = DistantManagerConnection::new(destination, options, transport);
let id = connection.id;
self.connections.write().await.insert(id, connection);
Ok(id)
@ -251,10 +253,6 @@ impl DistantManager {
#[derive(Default)]
pub struct DistantManagerServerConnection {
/// Authentication client that manager can use when establishing a new connection
/// and needing to get authentication details from the client to move forward
auth_client: Option<Mutex<AuthClient>>,
/// Holds on to open channels feeding data back from a server to some connected client,
/// enabling us to cancel the tasks on demand
channels: RwLock<HashMap<ChannelId, DistantManagerChannel>>,
@ -414,15 +412,12 @@ impl ServerHandler for DistantManager {
mod tests {
use super::*;
use distant_net::{
AuthClient, FramedTransport, HeapAuthServer, InmemoryTransport, IntoSplit, MappedListener,
OneshotListener, PlainCodec, ServerExt, ServerRef,
FramedTransport, InmemoryTransport, MappedListener, OneshotListener, PlainCodec, ServerRef,
};
/// Create a new server, bypassing the start loop
fn setup() -> DistantManager {
let (_, rx) = mpsc::channel(1);
DistantManager {
auth_client_rx: Mutex::new(rx),
config: Default::default(),
connections: RwLock::new(HashMap::new()),
launch_handlers: Arc::new(RwLock::new(HashMap::new())),

@ -1,5 +1,5 @@
use super::{BoxedConnectHandler, BoxedLaunchHandler, ConnectHandler, LaunchHandler};
use distant_net::{ServerRef, ServerState};
use distant_net::ServerRef;
use std::{collections::HashMap, io, sync::Weak};
use tokio::sync::RwLock;
@ -59,10 +59,6 @@ impl DistantManagerRef {
}
impl ServerRef for DistantManagerRef {
fn state(&self) -> &ServerState {
self.inner.state()
}
fn is_finished(&self) -> bool {
self.inner.is_finished()
}

@ -6,6 +6,13 @@ use std::{io, net::IpAddr};
pub struct TcpServerBuilder<T>(Server<T>);
impl<T> Server<T> {
/// Consume [`Server`] and produce a builder for a TCP variant.
pub fn into_tcp_builder(self) -> TcpServerBuilder<T> {
TcpServerBuilder(self)
}
}
impl Default for TcpServerBuilder<()> {
fn default() -> Self {
Self(Server::new())

@ -6,6 +6,13 @@ use std::{io, path::Path};
pub struct UnixSocketServerBuilder<T>(Server<T>);
impl<T> Server<T> {
/// Consume [`Server`] and produce a builder for a Unix socket variant.
pub fn into_unix_socket_builder(self) -> UnixSocketServerBuilder<T> {
UnixSocketServerBuilder(self)
}
}
impl Default for UnixSocketServerBuilder<()> {
fn default() -> Self {
Self(Server::new())

@ -9,6 +9,13 @@ use std::{
pub struct WindowsPipeServerBuilder<T>(Server<T>);
impl<T> Server<T> {
/// Consume [`Server`] and produce a builder for a Windows pipe variant.
pub fn into_windows_pipe_builder(self) -> WindowsPipeServerBuilder<T> {
WindowsPipeServerBuilder(self)
}
}
impl Default for WindowsPipeServerBuilder<()> {
fn default() -> Self {
Self(Server::new())

Loading…
Cancel
Save