1pub mod body;
6pub use body::*;
7pub mod compile;
8pub use compile::compile;
9pub mod config;
10pub use config::{Env, EnvReader, LoadedConfig, ProcessEnv, load, scan_rules_dir};
11pub mod conn_context;
12pub use conn_context::*;
13pub mod error;
14pub use error::*;
15pub mod fetch;
16pub use fetch::*;
17pub mod flow_ctx;
18pub use flow_ctx::*;
19pub mod flow_log;
20pub use flow_log::*;
21pub mod ir;
22pub use ir::*;
23pub mod l4;
24pub use l4::*;
25pub mod metadata;
26pub use metadata::*;
27pub mod middleware;
28pub use middleware::*;
29pub mod phase;
30pub mod predicate;
31pub use predicate::*;
32pub mod protocol_detect;
33pub use protocol_detect::*;
34pub mod preset;
35pub use preset::{PresetInvocation, RuleEntry, expand_invocation};
36pub mod rule;
37
38pub mod meta {
39 pub const DESCRIPTION: &str = "A compact programmable proxy engine";
40 pub const COPYRIGHT: &str = "Copyright (C) 2025 Canmi <t@canmi.icu>";
41 pub const HOMEPAGE: &str = "https://vane.canmi.app";
42 pub const REPOSITORY: &str = "https://github.com/canmi21/vane";
43 pub const LICENSE: &str = "MIT";
44 pub const LICENSE_URL: &str = "https://opensource.org/licenses/MIT";
45}
46
47pub mod version {
48 use std::fmt::Write as _;
49
50 use super::meta::{COPYRIGHT, DESCRIPTION, HOMEPAGE, LICENSE_URL, REPOSITORY};
51
52 pub struct BuildInfo {
58 pub version: &'static str,
59 pub commit: &'static str,
60 pub build_date: &'static str,
61 pub rustc: &'static str,
62 pub cargo: &'static str,
63 pub features: &'static [&'static str],
64 pub protocols: &'static [&'static str],
65 }
66
67 #[must_use]
95 pub fn format_version(info: &BuildInfo) -> String {
96 const WIDTH: usize = 12;
97 const INDENT: &str = " ";
98 let mut out = String::new();
99
100 let _ = writeln!(out);
101 let _ = writeln!(out, "{INDENT}Vane — {DESCRIPTION}");
102 let _ = writeln!(out);
103
104 let _ = writeln!(
105 out,
106 "{INDENT}{label:<WIDTH$}{version} ({commit} {date})",
107 label = "Built:",
108 version = info.version,
109 commit = info.commit,
110 date = info.build_date,
111 );
112 let _ = writeln!(out, "{INDENT}{label:<WIDTH$}{value}", label = "Rust:", value = info.rustc);
113 let _ = writeln!(out, "{INDENT}{label:<WIDTH$}{value}", label = "Cargo:", value = info.cargo);
114 if !info.features.is_empty() {
115 let _ = writeln!(
116 out,
117 "{INDENT}{label:<WIDTH$}{value}",
118 label = "Features:",
119 value = info.features.join(", "),
120 );
121 }
122 if !info.protocols.is_empty() {
123 let _ = writeln!(
124 out,
125 "{INDENT}{label:<WIDTH$}{value}",
126 label = "Protocols:",
127 value = info.protocols.join(", "),
128 );
129 }
130 let _ = writeln!(out);
131 let _ = writeln!(out, "{INDENT}{COPYRIGHT}");
132 let _ = writeln!(out);
133 let _ = writeln!(out, "{INDENT}Released under the MIT License without restriction.");
134 let _ = writeln!(out, "{INDENT}This software comes with ABSOLUTELY NO WARRANTY.");
135 let _ = writeln!(out);
136 let _ = writeln!(out, "{INDENT}{label:<WIDTH$}{HOMEPAGE}", label = "Homepage:");
137 let _ = writeln!(out, "{INDENT}{label:<WIDTH$}{REPOSITORY}", label = "Source:");
138 let _ = writeln!(out, "{INDENT}{label:<WIDTH$}{LICENSE_URL}", label = "License:");
139 let _ = writeln!(out);
140
141 out
142 }
143}