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