1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use super::traits::*;
use crate::common::protocol::tunnel::TunnelName;
use crate::util::cancellation::CancellationListener;
#[warn(unused_imports)]
use crate::util::tunnel_stream::TunnelStream;
use anyhow::{Context, Error as AnyErr, Result};
use futures::future::BoxFuture;
use futures::{AsyncWriteExt, FutureExt, StreamExt};
use tokio_util::sync::CancellationToken;
pub struct NoOpAuthenticationHandler {}
impl NoOpAuthenticationHandler {
pub fn new() -> NoOpAuthenticationHandler {
NoOpAuthenticationHandler {}
}
}
impl std::fmt::Debug for NoOpAuthenticationHandler {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"({})",
std::any::type_name::<NoOpAuthenticationHandler>()
)
}
}
impl AuthenticationHandler for NoOpAuthenticationHandler {
fn authenticate<'a>(
&'a self,
_channel: Box<dyn TunnelStream + Send + Unpin + 'a>,
tunnel_info: TunnelInfo,
_shutdown_notifier: &'a CancellationListener,
) -> BoxFuture<'a, Result<TunnelName, AuthenticationError>> {
async move {
let peer_addr = tunnel_info.addr;
let id = TunnelName::new(peer_addr.to_string());
Ok(id)
}
.boxed()
}
}