Compare commits
2 commits
638b0376d8
...
8092c07ee6
Author | SHA1 | Date | |
---|---|---|---|
8092c07ee6 | |||
89df8c684b |
7 changed files with 18 additions and 33 deletions
|
@ -1,8 +1,7 @@
|
||||||
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, Statement};
|
use tokio_postgres::{Client, Row};
|
||||||
|
|
||||||
const ENDPOINT_TABLE: &str = "endpoints";
|
const ENDPOINT_TABLE: &str = "endpoints";
|
||||||
const HOSTS_RELATION_TABLE: &str = "hosts";
|
const HOSTS_RELATION_TABLE: &str = "hosts";
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -16,11 +16,11 @@ use matchers::api::ApiMatcher;
|
||||||
use server::Server;
|
use server::Server;
|
||||||
use services::{
|
use services::{
|
||||||
controller::ControllerService,
|
controller::ControllerService,
|
||||||
matcher::{Matcher, MatcherService},
|
matcher::Matcher,
|
||||||
};
|
};
|
||||||
use tokio::{
|
use tokio::{
|
||||||
sync::Mutex,
|
sync::Mutex,
|
||||||
time::{self, interval},
|
time::{self},
|
||||||
};
|
};
|
||||||
use tokio_postgres::NoTls;
|
use tokio_postgres::NoTls;
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
use std::{net::IpAddr, pin::Pin, sync::Arc};
|
use std::{net::IpAddr, 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::{
|
||||||
Method, Request, StatusCode,
|
Request, StatusCode,
|
||||||
body::{self, Incoming},
|
body::Incoming,
|
||||||
service::Service,
|
|
||||||
};
|
};
|
||||||
use json::JsonValue;
|
use json::JsonValue;
|
||||||
use log::{debug, error, warn};
|
use log::{debug, error, warn};
|
||||||
|
@ -15,10 +13,10 @@ use tokio::{net::TcpStream, sync::Mutex};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::{Client, Config},
|
config::{Client, Config},
|
||||||
db::{BoxyDatabase, Endpoint},
|
db::BoxyDatabase,
|
||||||
routes::api::{AddHost, RegisterEndpoint, RemoveHost},
|
routes::api::{AddHost, RegisterEndpoint, RemoveHost},
|
||||||
server::{GeneralResponse, TcpIntercept, custom_resp, default_response, json_to_vec},
|
server::{GeneralResponse, custom_resp},
|
||||||
services::matcher::{Matcher, MatcherService},
|
services::matcher::Matcher,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
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::{debug, error, warn};
|
use log::error;
|
||||||
|
|
||||||
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},
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
pub mod controller;
|
pub mod controller;
|
||||||
pub mod proxy;
|
|
||||||
pub mod matcher;
|
pub mod matcher;
|
||||||
|
pub mod proxy;
|
||||||
|
|
|
@ -1,22 +1,11 @@
|
||||||
use std::{net::IpAddr, pin::Pin, sync::Arc};
|
use std::{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 http_body_util::BodyExt;
|
use hyper::{Request, StatusCode, body::Incoming, service::Service};
|
||||||
use hyper::{
|
use tokio::net::TcpStream;
|
||||||
Method, Request, StatusCode,
|
|
||||||
body::{self, Incoming},
|
|
||||||
service::Service,
|
|
||||||
};
|
|
||||||
use log::{debug, error, warn};
|
|
||||||
use tokio::{net::TcpStream, sync::Mutex};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::server::{GeneralResponse, TcpIntercept, custom_resp, default_response};
|
||||||
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]
|
||||||
|
@ -47,9 +36,11 @@ 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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue