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 wasm_runtime;
30pub use wasm_runtime::*;
31pub mod phase;
32pub mod predicate;
33pub use predicate::*;
34pub mod protocol_detect;
35pub use protocol_detect::*;
36pub mod preset;
37pub use preset::{PresetInvocation, RuleEntry, expand_invocation};
38pub mod rule;
39
40pub mod meta {
41 pub const DESCRIPTION: &str = "A compact programmable proxy engine";
42 pub const COPYRIGHT: &str = "Copyright (C) 2025 Canmi <t@canmi.icu>";
43 pub const HOMEPAGE: &str = "https://vane.canmi.app";
44 pub const REPOSITORY: &str = "https://github.com/canmi21/vane";
45 pub const LICENSE: &str = "MIT";
46 pub const LICENSE_URL: &str = "https://opensource.org/licenses/MIT";
47}
48
49pub mod version {
50 use owo_colors::{OwoColorize, Stream, Style};
51
52 use super::meta::{COPYRIGHT, DESCRIPTION, HOMEPAGE, LICENSE_URL, REPOSITORY};
53
54 pub struct BuildInfo {
61 pub version: &'static str,
62 pub commit: &'static str,
63 pub build_date: &'static str,
64 pub rustc: &'static str,
65 pub cargo: &'static str,
66 pub features: &'static [&'static str],
67 pub protocols: &'static [&'static str],
68 }
69
70 pub fn print_banner(info: &BuildInfo) {
109 const WIDTH: usize = 12;
110 const INDENT: &str = " ";
111
112 let brand_bold = Style::new().yellow().bold();
113 let brand = Style::new().yellow();
114 let prose = Style::new().cyan();
115 let email = Style::new().green();
116 let warning = Style::new().red().bold();
117
118 println!();
119 println!(
120 "{INDENT}{} — {DESCRIPTION}",
121 "Vane".if_supports_color(Stream::Stdout, |t| t.style(brand_bold)),
122 );
123 println!();
124
125 print_label(
126 "Built:",
127 &format!("{} ({} {})", info.version, info.commit, info.build_date),
128 WIDTH,
129 INDENT,
130 );
131 print_label("Rust:", info.rustc, WIDTH, INDENT);
132 print_label("Cargo:", info.cargo, WIDTH, INDENT);
133 if !info.features.is_empty() {
134 print_label("Features:", &info.features.join(", "), WIDTH, INDENT);
135 }
136 if !info.protocols.is_empty() {
137 print_label("Protocols:", &info.protocols.join(", "), WIDTH, INDENT);
138 }
139
140 println!();
141 let (copyright_word, rest) = COPYRIGHT.split_at("Copyright".len());
147 let (middle, email_addr) = match rest.find('<') {
148 Some(i) => rest.split_at(i),
149 None => (rest, ""),
150 };
151 println!(
152 "{INDENT}{}{}{}",
153 copyright_word.if_supports_color(Stream::Stdout, |t| t.style(brand)),
154 middle.if_supports_color(Stream::Stdout, |t| t.style(prose)),
155 email_addr.if_supports_color(Stream::Stdout, |t| t.style(email)),
156 );
157 println!();
158 println!(
162 "{INDENT}Released under the {} without restriction.",
163 "MIT License".if_supports_color(Stream::Stdout, |t| t.style(prose)),
164 );
165 println!(
166 "{INDENT}This software comes with {}.",
167 "ABSOLUTELY NO WARRANTY".if_supports_color(Stream::Stdout, |t| t.style(warning)),
168 );
169 println!();
170
171 print_label("Homepage:", HOMEPAGE, WIDTH, INDENT);
172 print_label("Source:", REPOSITORY, WIDTH, INDENT);
173 print_label("License:", LICENSE_URL, WIDTH, INDENT);
174 println!();
175 }
176
177 fn print_label(label: &str, value: &str, width: usize, indent: &str) {
178 let label_style = Style::new().cyan().bold();
179 let padded = format!("{label:<width$}");
180 let label_styled = padded.if_supports_color(Stream::Stdout, |t| t.style(label_style));
181 println!("{indent}{label_styled}{value}");
182 }
183}