Moved upstreams to their own dedicated namespace

Signed-off-by: Jacob Kiers <code@kiers.eu>
This commit is contained in:
2023-10-05 00:23:34 +02:00
parent 2116659a14
commit 3a2367ef28
6 changed files with 143 additions and 117 deletions

View File

@@ -2,14 +2,14 @@ use log::{error, info};
use std::collections::{HashMap, HashSet};
use std::net::SocketAddr;
use std::sync::Arc;
use tokio::io;
use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt};
use tokio::task::JoinHandle;
mod protocol;
pub(crate) mod upstream_address;
use crate::config::{ParsedConfig, Upstream};
use crate::config::ParsedConfig;
use crate::upstreams::Upstream;
use protocol::tcp;
#[derive(Debug)]
@@ -212,17 +212,3 @@ mod tests {
// conn.shutdown().await.unwrap();
}
}
async fn copy<'a, R, W>(reader: &'a mut R, writer: &'a mut W) -> io::Result<u64>
where
R: AsyncRead + Unpin + ?Sized,
W: AsyncWrite + Unpin + ?Sized,
{
match io::copy(reader, writer).await {
Ok(u64) => {
let _ = writer.shutdown().await;
Ok(u64)
}
Err(_) => Ok(0),
}
}