summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index b588f2d..da5c2f5 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -12,6 +12,7 @@ use crate::server::SharedConfig;
mod arguments;
mod client;
mod config;
+mod protocol;
mod server;
fn load_config<P: AsRef<Path>>(file_path: P) -> config::Root {
@@ -74,7 +75,8 @@ async fn main() -> io::Result<()> {
}
async fn server_main(cfg: config::Root) -> io::Result<()> {
- let listener = TcpListener::bind(cfg.server.unwrap().listen).await?;
+ let server_config = cfg.server.unwrap();
+ let listener = TcpListener::bind(server_config.listen).await?;
info!("Server listening on {:?}", listener);
let max_srv_name_length = cfg
.service
@@ -89,6 +91,7 @@ async fn server_main(cfg: config::Root) -> io::Result<()> {
max_srv_name_length,
services: cfg.service,
allow_help: cfg.allow_help,
+ no_ack_extension: server_config.no_ack_extension,
}));
loop {
let (sock, addr) = listener.accept().await?;
@@ -97,6 +100,7 @@ async fn server_main(cfg: config::Root) -> io::Result<()> {
}
async fn client_server_main(
+ cfg: &'static client::SharedConfig,
upstream_addr: &'static String,
listener: TcpListener,
service_name: &'static String,
@@ -104,20 +108,32 @@ async fn client_server_main(
loop {
let (sock, addr) = listener.accept().await?;
info!("Client connected: {}", addr);
- tokio::spawn(client::handle_client(sock, upstream_addr, service_name));
+ tokio::spawn(client::handle_client(
+ cfg,
+ sock,
+ upstream_addr,
+ service_name,
+ ));
}
}
async fn client_main(cfg: config::Root) -> io::Result<()> {
let mut fut_servers = Vec::new();
- let upstream_addr = Box::leak(Box::new(cfg.client.unwrap().addr));
+ let client_cfg = cfg.client.unwrap();
+
+ let upstream_addr = Box::leak(Box::new(client_cfg.addr));
+
+ let shared_config = Box::leak(Box::new(client::SharedConfig {
+ no_ack: client_cfg.no_ack,
+ }));
for s in cfg.service {
let listener = TcpListener::bind(&s.addr).await?;
info!("Server listening on {:?} (service {})", listener, &s.name);
let service_name = Box::leak(Box::new(s.name));
fut_servers.push(tokio::spawn(client_server_main(
+ shared_config,
upstream_addr,
listener,
service_name,