mirror of
https://github.com/MercuryWorkshop/epoxy-tls.git
synced 2025-05-12 14:00:01 -04:00
hide everything except config from rustdoc
This commit is contained in:
parent
a554a5a761
commit
1128ded1bb
2 changed files with 40 additions and 5 deletions
|
@ -19,7 +19,7 @@ use wisp_mux::{
|
||||||
|
|
||||||
use crate::{handle::wisp::utils::get_certificates_from_paths, CLI, CONFIG, RESOLVER};
|
use crate::{handle::wisp::utils::get_certificates_from_paths, CLI, CONFIG, RESOLVER};
|
||||||
|
|
||||||
const VERSION_STRING: &str = concat!(
|
pub const VERSION_STRING: &str = concat!(
|
||||||
"git ",
|
"git ",
|
||||||
env!("VERGEN_GIT_SHA"),
|
env!("VERGEN_GIT_SHA"),
|
||||||
", dirty ",
|
", dirty ",
|
||||||
|
@ -134,10 +134,12 @@ pub enum ProtocolExtensionAuth {
|
||||||
Certificate,
|
Certificate,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
fn default_motd() -> String {
|
fn default_motd() -> String {
|
||||||
format!("epoxy_server ({})", VERSION_STRING)
|
format!("epoxy_server ({})", VERSION_STRING)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
fn is_default_motd(str: &String) -> bool {
|
fn is_default_motd(str: &String) -> bool {
|
||||||
*str == default_motd()
|
*str == default_motd()
|
||||||
}
|
}
|
||||||
|
@ -160,10 +162,10 @@ pub struct WispConfig {
|
||||||
pub auth_extension: Option<ProtocolExtensionAuth>,
|
pub auth_extension: Option<ProtocolExtensionAuth>,
|
||||||
|
|
||||||
#[cfg(feature = "speed-limit")]
|
#[cfg(feature = "speed-limit")]
|
||||||
/// Read limit in bytes/second for all streams.
|
/// Read limit in bytes/second for all streams in a wisp connection.
|
||||||
pub read_limit: f64,
|
pub read_limit: f64,
|
||||||
#[cfg(feature = "speed-limit")]
|
#[cfg(feature = "speed-limit")]
|
||||||
/// Write limit in bytes/second for all streams.
|
/// Write limit in bytes/second for all streams in a wisp connection.
|
||||||
pub write_limit: f64,
|
pub write_limit: f64,
|
||||||
|
|
||||||
#[serde(skip_serializing_if = "HashMap::is_empty")]
|
#[serde(skip_serializing_if = "HashMap::is_empty")]
|
||||||
|
@ -235,11 +237,15 @@ pub struct StreamConfig {
|
||||||
#[derive(Debug, Serialize, Deserialize, Default)]
|
#[derive(Debug, Serialize, Deserialize, Default)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
|
/// Server-specific config.
|
||||||
pub server: ServerConfig,
|
pub server: ServerConfig,
|
||||||
|
/// Wisp-specific configuration.
|
||||||
pub wisp: WispConfig,
|
pub wisp: WispConfig,
|
||||||
|
/// Individual stream-specific configuration.
|
||||||
pub stream: StreamConfig,
|
pub stream: StreamConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct ConfigCache {
|
struct ConfigCache {
|
||||||
pub blocked_ports: Vec<RangeInclusive<u16>>,
|
pub blocked_ports: Vec<RangeInclusive<u16>>,
|
||||||
|
@ -256,6 +262,7 @@ struct ConfigCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
|
#[doc(hidden)]
|
||||||
static ref CONFIG_CACHE: ConfigCache = {
|
static ref CONFIG_CACHE: ConfigCache = {
|
||||||
ConfigCache {
|
ConfigCache {
|
||||||
allowed_ports: CONFIG
|
allowed_ports: CONFIG
|
||||||
|
@ -283,6 +290,7 @@ lazy_static! {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
pub async fn validate_config_cache() {
|
pub async fn validate_config_cache() {
|
||||||
// constructs regexes
|
// constructs regexes
|
||||||
let _ = CONFIG_CACHE.allowed_ports;
|
let _ = CONFIG_CACHE.allowed_ports;
|
||||||
|
@ -358,6 +366,7 @@ impl Default for WispConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WispConfig {
|
impl WispConfig {
|
||||||
|
#[doc(hidden)]
|
||||||
pub async fn to_opts(&self) -> anyhow::Result<(Option<WispV2Handshake>, Vec<u8>, u32)> {
|
pub async fn to_opts(&self) -> anyhow::Result<(Option<WispV2Handshake>, Vec<u8>, u32)> {
|
||||||
if self.wisp_v2 {
|
if self.wisp_v2 {
|
||||||
let mut extensions: Vec<AnyProtocolExtensionBuilder> = Vec::new();
|
let mut extensions: Vec<AnyProtocolExtensionBuilder> = Vec::new();
|
||||||
|
@ -449,40 +458,49 @@ impl Default for StreamConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StreamConfig {
|
impl StreamConfig {
|
||||||
|
#[doc(hidden)]
|
||||||
pub fn allowed_ports(&self) -> &'static [RangeInclusive<u16>] {
|
pub fn allowed_ports(&self) -> &'static [RangeInclusive<u16>] {
|
||||||
&CONFIG_CACHE.allowed_ports
|
&CONFIG_CACHE.allowed_ports
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
pub fn blocked_ports(&self) -> &'static [RangeInclusive<u16>] {
|
pub fn blocked_ports(&self) -> &'static [RangeInclusive<u16>] {
|
||||||
&CONFIG_CACHE.blocked_ports
|
&CONFIG_CACHE.blocked_ports
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
pub fn allowed_hosts(&self) -> &RegexSet {
|
pub fn allowed_hosts(&self) -> &RegexSet {
|
||||||
&CONFIG_CACHE.allowed_hosts
|
&CONFIG_CACHE.allowed_hosts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
pub fn blocked_hosts(&self) -> &RegexSet {
|
pub fn blocked_hosts(&self) -> &RegexSet {
|
||||||
&CONFIG_CACHE.blocked_hosts
|
&CONFIG_CACHE.blocked_hosts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
pub fn allowed_tcp_hosts(&self) -> &RegexSet {
|
pub fn allowed_tcp_hosts(&self) -> &RegexSet {
|
||||||
&CONFIG_CACHE.allowed_tcp_hosts
|
&CONFIG_CACHE.allowed_tcp_hosts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
pub fn blocked_tcp_hosts(&self) -> &RegexSet {
|
pub fn blocked_tcp_hosts(&self) -> &RegexSet {
|
||||||
&CONFIG_CACHE.blocked_tcp_hosts
|
&CONFIG_CACHE.blocked_tcp_hosts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
pub fn allowed_udp_hosts(&self) -> &RegexSet {
|
pub fn allowed_udp_hosts(&self) -> &RegexSet {
|
||||||
&CONFIG_CACHE.allowed_udp_hosts
|
&CONFIG_CACHE.allowed_udp_hosts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
pub fn blocked_udp_hosts(&self) -> &RegexSet {
|
pub fn blocked_udp_hosts(&self) -> &RegexSet {
|
||||||
&CONFIG_CACHE.blocked_udp_hosts
|
&CONFIG_CACHE.blocked_udp_hosts
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
|
#[doc(hidden)]
|
||||||
pub fn ser(&self) -> anyhow::Result<String> {
|
pub fn ser(&self) -> anyhow::Result<String> {
|
||||||
Ok(match CLI.format {
|
Ok(match CLI.format {
|
||||||
ConfigFormat::Json => serde_json::to_string_pretty(self)?,
|
ConfigFormat::Json => serde_json::to_string_pretty(self)?,
|
||||||
|
@ -493,6 +511,7 @@ impl Config {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
pub fn de(string: String) -> anyhow::Result<Self> {
|
pub fn de(string: String) -> anyhow::Result<Self> {
|
||||||
Ok(match CLI.format {
|
Ok(match CLI.format {
|
||||||
ConfigFormat::Json => serde_json::from_str(&string)?,
|
ConfigFormat::Json => serde_json::from_str(&string)?,
|
||||||
|
@ -505,6 +524,7 @@ impl Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, Eq, PartialEq, ValueEnum)]
|
#[derive(Debug, Clone, Copy, Eq, PartialEq, ValueEnum)]
|
||||||
|
#[doc(hidden)]
|
||||||
pub enum ConfigFormat {
|
pub enum ConfigFormat {
|
||||||
Json,
|
Json,
|
||||||
#[cfg(feature = "toml")]
|
#[cfg(feature = "toml")]
|
||||||
|
@ -528,6 +548,7 @@ impl Default for ConfigFormat {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Performant server implementation of the Wisp protocol in Rust, made for epoxy.
|
/// Performant server implementation of the Wisp protocol in Rust, made for epoxy.
|
||||||
|
#[doc(hidden)]
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(version = VERSION_STRING)]
|
#[command(version = VERSION_STRING)]
|
||||||
pub struct Cli {
|
pub struct Cli {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#![feature(ip)]
|
#![doc(html_no_source)]
|
||||||
#![deny(clippy::todo)]
|
#![deny(clippy::todo)]
|
||||||
#![allow(unexpected_cfgs)]
|
#![allow(unexpected_cfgs)]
|
||||||
|
|
||||||
|
@ -26,15 +26,22 @@ use tokio::{
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use wisp_mux::ConnectPacket;
|
use wisp_mux::ConnectPacket;
|
||||||
|
|
||||||
mod config;
|
pub mod config;
|
||||||
|
#[doc(hidden)]
|
||||||
mod handle;
|
mod handle;
|
||||||
|
#[doc(hidden)]
|
||||||
mod listener;
|
mod listener;
|
||||||
|
#[doc(hidden)]
|
||||||
mod route;
|
mod route;
|
||||||
|
#[doc(hidden)]
|
||||||
mod stats;
|
mod stats;
|
||||||
|
#[doc(hidden)]
|
||||||
mod stream;
|
mod stream;
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
type Client = (DashMap<Uuid, (ConnectPacket, ConnectPacket)>, bool);
|
type Client = (DashMap<Uuid, (ConnectPacket, ConnectPacket)>, bool);
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Resolver {
|
pub enum Resolver {
|
||||||
Hickory(TokioAsyncResolver),
|
Hickory(TokioAsyncResolver),
|
||||||
|
@ -60,7 +67,9 @@ impl Resolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
|
#[doc(hidden)]
|
||||||
pub static ref CLI: Cli = Cli::parse();
|
pub static ref CLI: Cli = Cli::parse();
|
||||||
|
#[doc(hidden)]
|
||||||
pub static ref CONFIG: Config = {
|
pub static ref CONFIG: Config = {
|
||||||
if let Some(path) = &CLI.config {
|
if let Some(path) = &CLI.config {
|
||||||
Config::de(
|
Config::de(
|
||||||
|
@ -74,7 +83,9 @@ lazy_static! {
|
||||||
Config::default()
|
Config::default()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#[doc(hidden)]
|
||||||
pub static ref CLIENTS: DashMap<String, Client> = DashMap::new();
|
pub static ref CLIENTS: DashMap<String, Client> = DashMap::new();
|
||||||
|
#[doc(hidden)]
|
||||||
pub static ref RESOLVER: Resolver = {
|
pub static ref RESOLVER: Resolver = {
|
||||||
if CONFIG.stream.dns_servers.is_empty() {
|
if CONFIG.stream.dns_servers.is_empty() {
|
||||||
if let Ok((config, opts)) = read_system_conf() {
|
if let Ok((config, opts)) = read_system_conf() {
|
||||||
|
@ -96,9 +107,11 @@ lazy_static! {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
static JEMALLOCATOR: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
|
static JEMALLOCATOR: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
fn main() -> anyhow::Result<()> {
|
fn main() -> anyhow::Result<()> {
|
||||||
if CLI.default_config {
|
if CLI.default_config {
|
||||||
println!("{}", Config::default().ser()?);
|
println!("{}", Config::default().ser()?);
|
||||||
|
@ -204,6 +217,7 @@ fn main() -> anyhow::Result<()> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
fn handle_stream(stream: ServerRouteResult, id: String) {
|
fn handle_stream(stream: ServerRouteResult, id: String) {
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
CLIENTS.insert(id.clone(), (DashMap::new(), false));
|
CLIENTS.insert(id.clone(), (DashMap::new(), false));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue