diff --git a/src/db.rs b/src/db.rs index e0eb17d..3fa8d5d 100644 --- a/src/db.rs +++ b/src/db.rs @@ -1,8 +1,7 @@ use std::{error::Error, net::IpAddr}; -use json::JsonValue; use log::warn; -use tokio_postgres::{Client, Row, Statement}; +use tokio_postgres::{Client, Row}; const ENDPOINT_TABLE: &str = "endpoints"; const HOSTS_RELATION_TABLE: &str = "hosts"; diff --git a/src/health.rs b/src/health.rs index 83cfbc3..82fc7eb 100644 --- a/src/health.rs +++ b/src/health.rs @@ -26,7 +26,7 @@ pub async fn check(db: &mut BoxyDatabase) { continue; } }; - + let io = TokioIo::new(stream); let (mut sender, conn) = hyper::client::conn::http1::handshake(io).await.unwrap(); diff --git a/src/main.rs b/src/main.rs index 671a19f..42b6a58 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,11 +16,11 @@ use matchers::api::ApiMatcher; use server::Server; use services::{ controller::ControllerService, - matcher::{Matcher, MatcherService}, + matcher::Matcher, }; use tokio::{ sync::Mutex, - time::{self, interval}, + time::{self}, }; use tokio_postgres::NoTls; diff --git a/src/matchers/api.rs b/src/matchers/api.rs index c8c108a..da62e4b 100644 --- a/src/matchers/api.rs +++ b/src/matchers/api.rs @@ -1,13 +1,11 @@ -use std::{net::IpAddr, pin::Pin, sync::Arc}; +use std::{net::IpAddr, sync::Arc}; use async_trait::async_trait; use base64::{Engine, prelude::BASE64_STANDARD}; -use http::request::Parts; use http_body_util::BodyExt; use hyper::{ - Method, Request, StatusCode, - body::{self, Incoming}, - service::Service, + Request, StatusCode, + body::Incoming, }; use json::JsonValue; use log::{debug, error, warn}; @@ -15,10 +13,10 @@ use tokio::{net::TcpStream, sync::Mutex}; use crate::{ config::{Client, Config}, - db::{BoxyDatabase, Endpoint}, + db::BoxyDatabase, routes::api::{AddHost, RegisterEndpoint, RemoveHost}, - server::{GeneralResponse, TcpIntercept, custom_resp, default_response, json_to_vec}, - services::matcher::{Matcher, MatcherService}, + server::{GeneralResponse, custom_resp}, + services::matcher::Matcher, }; #[derive(Debug, Clone)] diff --git a/src/routes/api.rs b/src/routes/api.rs index d137093..8461fb4 100644 --- a/src/routes/api.rs +++ b/src/routes/api.rs @@ -1,12 +1,9 @@ use async_trait::async_trait; -use base64::{Engine, prelude::BASE64_STANDARD}; use http::request::Parts; -use http_body_util::BodyExt; use hyper::{Method, StatusCode}; -use log::{debug, error, warn}; +use log::error; use crate::{ - config::Client, db::Endpoint, matchers::api::ApiMatcher, server::{custom_resp, json_to_vec}, diff --git a/src/services.rs b/src/services.rs index 381d0dc..a2b6a6c 100644 --- a/src/services.rs +++ b/src/services.rs @@ -1,3 +1,3 @@ pub mod controller; -pub mod proxy; pub mod matcher; +pub mod proxy; diff --git a/src/services/matcher.rs b/src/services/matcher.rs index fbcb074..3618f93 100644 --- a/src/services/matcher.rs +++ b/src/services/matcher.rs @@ -1,22 +1,11 @@ -use std::{net::IpAddr, pin::Pin, sync::Arc}; +use std::{pin::Pin, sync::Arc}; use async_trait::async_trait; -use base64::{Engine, prelude::BASE64_STANDARD}; use http::request::Parts; -use http_body_util::BodyExt; -use hyper::{ - Method, Request, StatusCode, - body::{self, Incoming}, - service::Service, -}; -use log::{debug, error, warn}; -use tokio::{net::TcpStream, sync::Mutex}; +use hyper::{Request, StatusCode, body::Incoming, service::Service}; +use tokio::net::TcpStream; -use crate::{ - config::{Client, Config}, - db::{BoxyDatabase, Endpoint}, - server::{GeneralResponse, TcpIntercept, custom_resp, default_response, json_to_vec}, -}; +use crate::server::{GeneralResponse, TcpIntercept, custom_resp, default_response}; // The routes itself #[async_trait] @@ -47,9 +36,11 @@ pub trait Matcher: Clone + Send + Sync + 'static { } // Do something with TCP stream + #[allow(unused_variables)] fn stream(&mut self, stream: &TcpStream) {} // Body parser - made universal for api server cause lazy + #[allow(unused_variables)] async fn body(&mut self, body: Incoming) -> Option> { None }