make 'src/common' actually common

- delete no longer needed lookup_ipv4
- delete no longer needed path_exists
- move gen_tls_client_config from common to client
- move gen_tls_server_config from common to server
This commit is contained in:
ayham 2021-06-01 18:59:07 +03:00
parent f2c4d46ffe
commit 66af765def
Signed by: ayham
GPG Key ID: EAB7F5A9DF503678
9 changed files with 4 additions and 34 deletions

View File

@ -5,7 +5,7 @@ use tokio::net::TcpStream;
use tokio_rustls::webpki::DNSNameRef;
use tokio_rustls::TlsConnector;
use crate::common::misc::gen_tls_client_config::gen_tls_client_config;
use crate::client::network::gen_tls_client_config::gen_tls_client_config;
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};

View File

@ -1,2 +1,3 @@
pub mod cmd;
pub mod handle_data;
pub mod gen_tls_client_config;

View File

@ -1,19 +0,0 @@
use std::net::{SocketAddr, ToSocketAddrs};
/// Looks up a string hostname and port, returns a SocketAddr represnting that hostname and port.
///
/// Arguments:
/// host - hostname to search.
/// port - port on hostname to search.
///
/// Returns: SocketAddr
pub fn lookup_ipv4(host: &str, port: u16) -> SocketAddr {
let addrs = (host, port).to_socket_addrs().unwrap();
for addr in addrs {
if let SocketAddr::V4(_) = addr {
return addr;
}
}
unreachable!("Cannot lookup address");
}

View File

@ -1,7 +1,3 @@
pub mod assert_msg;
pub mod gen_tls_client_config;
pub mod gen_tls_server_config;
pub mod lookup_ipv4;
pub mod path_exists;
pub mod return_flags;
pub mod servers_pool;

View File

@ -1,9 +0,0 @@
/// Simple copy-pasta for checking for path existance.
///
/// Used in gen_log() and libtrader_init_log(). Checks if path is exists or not.
///
/// Arguments:
/// path - The path to check
pub fn path_exists(path: &str) -> bool {
std::fs::metadata(path).is_ok()
}

View File

@ -9,7 +9,7 @@ use tokio_rustls::TlsAcceptor;
use std::net::ToSocketAddrs;
use crate::common::misc::gen_tls_server_config::gen_tls_server_config;
use crate::server::network::gen_tls_server_config::gen_tls_server_config;
use crate::server::db::config::{DB_ACC_PASS, DB_ACC_USER};
use crate::server::db::initializer::db_connect;

View File

@ -1,3 +1,4 @@
pub mod cmd;
pub mod handle_data;
pub mod jwt_wrapper;
pub mod gen_tls_server_config;