[package]
name = "trojan"
version.workspace = true
edition.workspace = true
license.workspace = true
authors.workspace = true
repository.workspace = true
homepage.workspace = true
documentation.workspace = true
description = "A Rust implementation of the Trojan protocol"
keywords = ["trojan", "proxy", "tls", "network"]
categories = ["network-programming"]

[workspace]
resolver = "2"
exclude = ["auth-worker"]
members = [
    "crates/trojan-core",
    "crates/trojan-proto",
    "crates/trojan-auth",
    "crates/trojan-config",
    "crates/trojan-metrics",
    "crates/trojan-analytics",
    "crates/trojan-server",
    "crates/trojan-client",
    "crates/trojan-cert",
    "crates/trojan-rs",
    "crates/trojan-relay",
    "crates/trojan-transport",
    "crates/trojan-dns",
    "crates/trojan-lb",
    "crates/trojan-rules",
    "crates/trojan-agent",
    "crates/trojan-protocol",
    "crates/trojan-ddns",
]

[workspace.package]
version = "0.9.1"
edition = "2024"
license = "GPL-3.0-only"
authors = ["trojan-rust <164051043+trojan-rust@users.noreply.github.com>"]
repository = "https://github.com/trojan-rust/trojan-rust"
homepage = "https://github.com/trojan-rust/trojan-rust"
documentation = "https://docs.rs/trojan"

[workspace.dependencies]
trojan = { version = "0.9.1", path = "." }
trojan-core = { version = "0.9.1", path = "crates/trojan-core" }
trojan-proto = { version = "0.9.1", path = "crates/trojan-proto" }
trojan-auth = { version = "0.9.1", path = "crates/trojan-auth" }
trojan-config = { version = "0.9.1", path = "crates/trojan-config" }
trojan-metrics = { version = "0.9.1", path = "crates/trojan-metrics" }
trojan-analytics = { version = "0.9.1", path = "crates/trojan-analytics" }
trojan-server = { version = "0.9.1", path = "crates/trojan-server" }
trojan-client = { version = "0.9.1", path = "crates/trojan-client" }
trojan-cert = { version = "0.9.1", path = "crates/trojan-cert" }
trojan-relay = { version = "0.9.1", path = "crates/trojan-relay" }
trojan-transport = { version = "0.9.1", path = "crates/trojan-transport" }
trojan-dns = { version = "0.9.1", path = "crates/trojan-dns" }
trojan-lb = { version = "0.9.1", path = "crates/trojan-lb" }
trojan-rules = { version = "0.9.1", path = "crates/trojan-rules" }
trojan-agent = { version = "0.9.1", path = "crates/trojan-agent" }
trojan-protocol = { version = "0.9.1", path = "crates/trojan-protocol" }
trojan-ddns = { version = "0.9.1", path = "crates/trojan-ddns" }

# External dependencies (shared across crates)
arc-swap = "1"
hickory-resolver = { version = "0.25", features = [
    "system-config",
    "tokio",
    "tls-aws-lc-rs",
    "https-aws-lc-rs",
    "webpki-roots",
] }
bincode = "=1.3.3"
async-trait = "0.1"
axum = "0.8"
bytes = "1"
clap = { version = "4", features = ["derive"] }
criterion = "0.8"
ctor = "0.6"
futures-util = "0.3"
hex = "0.4"
hostname = "0.4"
metrics = "0.24"
metrics-exporter-prometheus = "0.18"
parking_lot = "0.12"
rcgen = { version = "0.14", default-features = false, features = [
    "aws_lc_rs",
    "pem",
] }
rustls = { version = "0.23", default-features = false, features = [
    "aws_lc_rs",
    "logging",
    "std",
    "tls12",
] }
rustls-pemfile = "2"
rustls-pki-types = "1"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
serde_yaml = "0.9"
sha2 = "0.10"
socket2 = "0.6"
sysinfo = "0.38"
tempfile = "3"
thiserror = "2"
time = "0.3"
tokio = "1"
tokio-rustls = "0.26"
tokio-tungstenite = "0.28"
tokio-util = "0.7"
toml = "1"
tracing = "0.1"
tracing-appender = "0.2"
tracing-subscriber = "0.3"
webpki-roots = "1"

[workspace.lints.rust]
missing_debug_implementations = "warn"

[workspace.lints.clippy]
ptr_as_ptr = "warn"
undocumented_unsafe_blocks = "warn"
cast_possible_truncation = "warn"
cast_possible_wrap = "warn"
cast_sign_loss = "warn"
exit = "warn"
tests_outside_test_module = "warn"
assertions_on_result_states = "warn"
error_impl_error = "warn"
or_fun_call = "warn"

[lints]
workspace = true

[features]
default = [
    "cli",
    "cert",
    "sql-sqlite",
    "sql-mysql",
    "sql-postgres",
    "sql-tls-rustls",
    "agent",
]
cli = ["trojan-auth/cli", "dep:clap", "dep:tokio"]

# Self-upgrade from GitHub releases (disabled by default, enabled in CI builds)
upgrade = [
    "cli",
    "dep:reqwest",
    "dep:serde",
    "dep:serde_json",
    "dep:self-replace",
    "dep:flate2",
    "dep:tar",
    "dep:sha2",
    "dep:hex",
    "dep:tokio-util",
    "dep:futures-util",
    "dep:tempfile",
    "dep:zip",
]

# Panel agent
agent = ["cli", "dep:trojan-agent"]

# Certificate management CLI
cert = ["cli", "dep:trojan-cert"]

# Database drivers for auth CLI
sql-sqlite = ["trojan-auth/sql-sqlite"]
sql-postgres = ["trojan-auth/sql-postgres"]
sql-mysql = ["trojan-auth/sql-mysql"]
sql-tls-rustls = ["trojan-auth/sql-tls-rustls"]
sql-tls-native = ["trojan-auth/sql-tls-native"]

[[bin]]
name = "trojan"
path = "src/main.rs"
required-features = ["cli"]

[dependencies]
trojan-core.workspace = true
trojan-proto.workspace = true
trojan-auth.workspace = true
trojan-config.workspace = true
trojan-metrics.workspace = true
trojan-server.workspace = true
trojan-client.workspace = true
trojan-relay.workspace = true
trojan-cert = { workspace = true, optional = true }
trojan-agent = { workspace = true, optional = true }

rustls.workspace = true

# CLI dependencies
clap = { workspace = true, optional = true }
tokio = { workspace = true, features = [
    "rt-multi-thread",
    "macros",
], optional = true }
reqwest = { version = "0.12", default-features = false, features = [
    "json",
    "stream",
    "rustls-tls",
], optional = true }
serde = { workspace = true, optional = true }
serde_json = { workspace = true, optional = true }
self-replace = { version = "1", optional = true }
flate2 = { version = "1", optional = true }
tar = { version = "0.4", optional = true }
sha2 = { workspace = true, optional = true }
hex = { workspace = true, optional = true }
tokio-util = { workspace = true, features = ["io"], optional = true }
futures-util = { workspace = true, optional = true }
tempfile = { workspace = true, optional = true }

# Windows-only dependencies for upgrade feature
[target.'cfg(windows)'.dependencies]
zip = { version = "8", default-features = false, features = [
    "deflate",
], optional = true }

[profile.release]
opt-level = 3
lto = "fat"
codegen-units = 1
strip = true
panic = "abort"
