mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 02:05:30 +00:00
http_private: add config, launch with cli helpers
This commit is contained in:
parent
6e97bff93f
commit
088daa72ff
8 changed files with 200 additions and 30 deletions
|
|
@ -1 +1,2 @@
|
|||
pub mod request;
|
||||
pub mod socket;
|
||||
|
|
|
|||
5
aquatic_http_private/src/workers/request.rs
Normal file
5
aquatic_http_private/src/workers/request.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
use crate::config::Config;
|
||||
|
||||
pub fn run_request_worker(config: Config) -> anyhow::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
mod db;
|
||||
mod routes;
|
||||
|
||||
use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpListener};
|
||||
use std::net::{SocketAddr, TcpListener};
|
||||
|
||||
use anyhow::Context;
|
||||
use axum::{routing::get, Extension, Router};
|
||||
use sqlx::mysql::MySqlPoolOptions;
|
||||
|
||||
pub fn run_socket_worker() -> anyhow::Result<()> {
|
||||
let addr = SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::LOCALHOST, 3000));
|
||||
use crate::config::Config;
|
||||
|
||||
let tcp_listener = create_tcp_listener(addr, false)?;
|
||||
pub fn run_socket_worker(config: Config) -> anyhow::Result<()> {
|
||||
let tcp_listener = create_tcp_listener(config.network.address)?;
|
||||
|
||||
let runtime = tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
|
|
@ -40,7 +40,7 @@ async fn run_app(tcp_listener: TcpListener) -> anyhow::Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn create_tcp_listener(addr: SocketAddr, only_ipv6: bool) -> anyhow::Result<TcpListener> {
|
||||
fn create_tcp_listener(addr: SocketAddr) -> anyhow::Result<TcpListener> {
|
||||
let domain = if addr.is_ipv4() {
|
||||
socket2::Domain::IPV4
|
||||
} else {
|
||||
|
|
@ -49,10 +49,6 @@ fn create_tcp_listener(addr: SocketAddr, only_ipv6: bool) -> anyhow::Result<TcpL
|
|||
|
||||
let socket = socket2::Socket::new(domain, socket2::Type::STREAM, Some(socket2::Protocol::TCP))?;
|
||||
|
||||
if only_ipv6 {
|
||||
socket.set_only_v6(true).with_context(|| "set only_ipv6")?;
|
||||
}
|
||||
|
||||
socket
|
||||
.set_reuse_port(true)
|
||||
.with_context(|| "set_reuse_port")?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue