Compare commits

..

No commits in common. "8092c07ee6a21fe2c464bb06cf705528079d7949" and "638b0376d827ce3a1c7bc423dba915c6124dc628" have entirely different histories.

7 changed files with 33 additions and 18 deletions

View file

@ -1,7 +1,8 @@
use std::{error::Error, net::IpAddr}; use std::{error::Error, net::IpAddr};
use json::JsonValue;
use log::warn; use log::warn;
use tokio_postgres::{Client, Row}; use tokio_postgres::{Client, Row, Statement};
const ENDPOINT_TABLE: &str = "endpoints"; const ENDPOINT_TABLE: &str = "endpoints";
const HOSTS_RELATION_TABLE: &str = "hosts"; const HOSTS_RELATION_TABLE: &str = "hosts";

View file

@ -26,7 +26,7 @@ pub async fn check(db: &mut BoxyDatabase) {
continue; continue;
} }
}; };
let io = TokioIo::new(stream); let io = TokioIo::new(stream);
let (mut sender, conn) = hyper::client::conn::http1::handshake(io).await.unwrap(); let (mut sender, conn) = hyper::client::conn::http1::handshake(io).await.unwrap();

View file

@ -16,11 +16,11 @@ use matchers::api::ApiMatcher;
use server::Server; use server::Server;
use services::{ use services::{
controller::ControllerService, controller::ControllerService,
matcher::Matcher, matcher::{Matcher, MatcherService},
}; };
use tokio::{ use tokio::{
sync::Mutex, sync::Mutex,
time::{self}, time::{self, interval},
}; };
use tokio_postgres::NoTls; use tokio_postgres::NoTls;

View file

@ -1,11 +1,13 @@
use std::{net::IpAddr, sync::Arc}; use std::{net::IpAddr, pin::Pin, sync::Arc};
use async_trait::async_trait; use async_trait::async_trait;
use base64::{Engine, prelude::BASE64_STANDARD}; use base64::{Engine, prelude::BASE64_STANDARD};
use http::request::Parts;
use http_body_util::BodyExt; use http_body_util::BodyExt;
use hyper::{ use hyper::{
Request, StatusCode, Method, Request, StatusCode,
body::Incoming, body::{self, Incoming},
service::Service,
}; };
use json::JsonValue; use json::JsonValue;
use log::{debug, error, warn}; use log::{debug, error, warn};
@ -13,10 +15,10 @@ use tokio::{net::TcpStream, sync::Mutex};
use crate::{ use crate::{
config::{Client, Config}, config::{Client, Config},
db::BoxyDatabase, db::{BoxyDatabase, Endpoint},
routes::api::{AddHost, RegisterEndpoint, RemoveHost}, routes::api::{AddHost, RegisterEndpoint, RemoveHost},
server::{GeneralResponse, custom_resp}, server::{GeneralResponse, TcpIntercept, custom_resp, default_response, json_to_vec},
services::matcher::Matcher, services::matcher::{Matcher, MatcherService},
}; };
#[derive(Debug, Clone)] #[derive(Debug, Clone)]

View file

@ -1,9 +1,12 @@
use async_trait::async_trait; use async_trait::async_trait;
use base64::{Engine, prelude::BASE64_STANDARD};
use http::request::Parts; use http::request::Parts;
use http_body_util::BodyExt;
use hyper::{Method, StatusCode}; use hyper::{Method, StatusCode};
use log::error; use log::{debug, error, warn};
use crate::{ use crate::{
config::Client,
db::Endpoint, db::Endpoint,
matchers::api::ApiMatcher, matchers::api::ApiMatcher,
server::{custom_resp, json_to_vec}, server::{custom_resp, json_to_vec},

View file

@ -1,3 +1,3 @@
pub mod controller; pub mod controller;
pub mod matcher;
pub mod proxy; pub mod proxy;
pub mod matcher;

View file

@ -1,11 +1,22 @@
use std::{pin::Pin, sync::Arc}; use std::{net::IpAddr, pin::Pin, sync::Arc};
use async_trait::async_trait; use async_trait::async_trait;
use base64::{Engine, prelude::BASE64_STANDARD};
use http::request::Parts; use http::request::Parts;
use hyper::{Request, StatusCode, body::Incoming, service::Service}; use http_body_util::BodyExt;
use tokio::net::TcpStream; use hyper::{
Method, Request, StatusCode,
body::{self, Incoming},
service::Service,
};
use log::{debug, error, warn};
use tokio::{net::TcpStream, sync::Mutex};
use crate::server::{GeneralResponse, TcpIntercept, custom_resp, default_response}; use crate::{
config::{Client, Config},
db::{BoxyDatabase, Endpoint},
server::{GeneralResponse, TcpIntercept, custom_resp, default_response, json_to_vec},
};
// The routes itself // The routes itself
#[async_trait] #[async_trait]
@ -36,11 +47,9 @@ pub trait Matcher: Clone + Send + Sync + 'static {
} }
// Do something with TCP stream // Do something with TCP stream
#[allow(unused_variables)]
fn stream(&mut self, stream: &TcpStream) {} fn stream(&mut self, stream: &TcpStream) {}
// Body parser - made universal for api server cause lazy // Body parser - made universal for api server cause lazy
#[allow(unused_variables)]
async fn body(&mut self, body: Incoming) -> Option<Result<GeneralResponse, hyper::Error>> { async fn body(&mut self, body: Incoming) -> Option<Result<GeneralResponse, hyper::Error>> {
None None
} }