[workspace]
members = [
    ".",
    "ant-quic-workspace-hack",
]

[package]
name = "ant-quic"
version = "0.22.0"
edition = "2024"
rust-version = "1.88.0"
license = "MIT OR Apache-2.0"
autobins = false
repository = "https://github.com/dirvine/ant-quic"
description = "QUIC transport protocol with advanced NAT traversal for P2P networks"
keywords = ["quic", "nat-traversal", "p2p", "autonomi", "networking"]
categories = ["network-programming", "asynchronous"]
exclude = [
    ".github/",
    ".githooks/",
    ".serena/",
    ".codecov.yml",
    ".DS_Store",
    "*.DS_Store",
    "release-build/",
    "docs/rfcs/*.pdf",
    "docs/diagrams/",
    "docs/planning/",
    "target/",
    "scripts/",
    "tests/data/large_files/",
    "benches/",
    "examples/chat_demo.rs",
    "examples/dashboard_demo.rs",
    "examples/simple_chat.rs",
    "examples/nat_simulation.rs",
]

[features]
# Default features include essential functionality with 100% PQC support
# v0.15.0: Simplified feature flags - crypto is always enabled
default = ["platform-verifier", "network-discovery"]

# Platform-specific certificate verification
platform-verifier = ["dep:rustls-platform-verifier"]

# Configure `tracing` to log events via `log` if no `tracing` subscriber exists
log = ["tracing/log"]

# Enhanced network interface discovery
network-discovery = ["dep:socket2", "dep:nix"]

# Fuzzing/testing features
arbitrary = ["dep:arbitrary"]

# Internal QUIC logging
__qlog = ["dep:qlog"]

# Zero-cost tracing system
trace = []
trace-full = ["trace"]

# Enhanced testing features
property_testing = ["dep:proptest", "dep:proptest-derive"]
fuzzing = ["arbitrary"]

# BLE transport support (Linux and macOS)
# Enables Bluetooth Low Energy transport for short-range P2P
# - Linux: Uses BlueZ via bluer crate
# - macOS: Uses Core Bluetooth via btleplug crate
ble = ["dep:btleplug"]

[dependencies]
# Core dependencies
async-trait = "0.1"
bytes = ">=1.11.1"
rustc-hash = "2"
rand = "0.8"
thiserror = "2.0.3"
tinyvec = { version = "1.1", features = ["alloc"] }
tracing = { version = "0.1.10", default-features = false, features = ["std", "attributes", "log"] }

serde = { version = "1", features = ["derive"] }
serde_json = "1"
serde_yaml = "0.9"
# Ed25519 removed in v0.2.0+ - Pure PQC uses ML-DSA-65 only
x25519-dalek = { version = "2.0", features = ["static_secrets"] }

# Post-Quantum Cryptography - required in v0.12.0+
saorsa-pqc = { version = "0.4" }

# Data structures
slab = "0.4.11"
indexmap = "2.0"

lru-slab = "0.1.2"

# Bootstrap cache dependencies
dirs = "5.0"

# Platform keychain/keyring for secure credential storage
keyring = "3"

# Crypto dependencies (required for PQC)
rustls = { version = "0.23.35", default-features = false, features = ["std", "aws-lc-rs"] }
aws-lc-rs = { version = "1.12", default-features = false, features = ["unstable", "aws-lc-sys", "prebuilt-nasm"] }
rustls-platform-verifier = { version = "0.6", optional = true }
# PQC crypto - required in v0.12.0+
# v0.2: aws-lc-rs-unstable enables ML-DSA-65 signatures
rustls-post-quantum = { version = "0.2", features = ["aws-lc-rs-unstable"] }

# Network discovery dependencies (optional)
socket2 = { version = "0.5", optional = true }
nix = { version = "0.29", features = ["resource", "net"], optional = true }

# BLE transport dependencies (cross-platform, optional)
# btleplug supports Linux (BlueZ), macOS (Core Bluetooth), and Windows (WinRT)
btleplug = { version = "0.11", optional = true }

# Essential dependencies (formerly production-ready)
rcgen = { version = "0.14" }
tokio-util = { version = "0.7" }
futures-util = { version = "0.3" }

time = { version = "0.3.47" }
rustls-pemfile = { version = "2.0" }

# Feature-specific dependencies (optional)
arbitrary = { version = "1.3", optional = true, features = ["derive"] }
qlog = { version = "0.13", optional = true }

# Essential dependencies
uuid = { version = "1.0", features = ["v4", "serde"] }
unicode-width = "=0.2.0"  # Pinned to match ratatui's requirement
hex = "0.4"
sha2 = "0.10"
once_cell = "1.21"
dashmap = "6"
# Faster mutexes that don't poison and have fair locking
parking_lot = "0.12"
zeroize = { version = "1.8", features = ["derive"] }
proptest = { version = "1.5", features = ["std"], optional = true }
proptest-derive = { version = "0.5", optional = true }

# criterion moved to dev-dependencies for benchmarks

# Dependencies for ant-quic binary
anyhow = "1"
clap = { version = "4", features = ["derive"] }
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
tokio = { version = "1.28.1", features = ["full"] }
tracing-subscriber = { version = "0.3.0", default-features = false, features = ["env-filter", "fmt", "ansi", "time", "local-time", "json"] }
quinn-udp = { version = "0.5", features = ["log", "tracing"] }
pin-project-lite = "0.2"

# Compliance validator dependencies
regex = "1.11"
chrono = { version = "0.4", features = ["serde"] }
rustls-native-certs = "0.8"

# Platform-specific target dependencies
[target.'cfg(windows)'.dependencies]
windows = { version = "0.58", features = [
    "Win32_Foundation",
    "Win32_NetworkManagement_IpHelper",
    "Win32_NetworkManagement_Ndis",
    "Win32_Networking_WinSock",
    "Win32_System",
    "Win32_System_IO",
    "Win32_System_Threading",
] }

[target.'cfg(target_os = "linux")'.dependencies]
# Note: Using raw libc netlink sockets instead of netlink-packet crates
# to avoid transitive dependency on unmaintained 'paste' crate
hex = "0.4"
sha2 = "0.10"
[target.'cfg(target_os = "macos")'.dependencies]
system-configuration = "0.6"
core-foundation = "0.9"

[target.'cfg(unix)'.dependencies]
libc = "0.2"

[dev-dependencies]
ant-quic-workspace-hack = { path = "ant-quic-workspace-hack" }
assert_matches = "1.1"
hex-literal = "0.4"
rand_pcg = "0.3"
rcgen = "0.14"
tracing-subscriber = { version = "0.3.0", default-features = false, features = ["env-filter", "fmt", "ansi", "time", "local-time", "json"] }
tempfile = "3"
lazy_static = "1"
anyhow = "1"
serde_yaml = "0.9"
serde_json = "1"
webpki-roots = "1.0"
tokio = { version = "1.36", features = ["full"] }
quickcheck = "1.0"
quickcheck_macros = "1.0"
criterion = { version = "0.5", features = ["html_reports"] }
proptest = { version = "1.5", features = ["std"] }
proptest-derive = { version = "0.5" }

# Enhanced testing dependencies
# cargo-mutants is a CLI tool, not a library dependency
# Install with: cargo install cargo-mutants
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(fuzzing)', 'cfg(wasm_browser)', 'cfg(feature, values("arbitrary", "__qlog"))'] }

# Main P2P binary with NAT traversal support
[[bin]]
name = "ant-quic"
path = "src/bin/ant-quic.rs"

# Interoperability test runner
[[bin]]
name = "interop-test"
path = "src/bin/interop-test.rs"

# Public endpoint tester
[[bin]]
name = "test-public-endpoints"
path = "src/bin/test_public_endpoints.rs"

# E2E test node with metrics push and data verification
[[bin]]
name = "e2e-test-node"
path = "src/bin/e2e-test-node.rs"

# Benchmarks
[[bench]]
name = "quic_benchmarks"
harness = false

[[bench]]
name = "relay_queue"
harness = false

[[bench]]
name = "candidate_discovery"
harness = false

[[bench]]
name = "nat_traversal"
harness = false

[[bench]]
name = "address_discovery_bench"
harness = false

[[bench]]
name = "connection_management"
harness = false

[[bench]]
name = "nat_traversal_performance"
harness = false

[[bench]]
name = "connection_router"
harness = false

[[bench]]
name = "pqc_memory_pool_bench"
harness = false


# Test categorization
[[test]]
name = "quick"
path = "tests/quick/main.rs"

[[test]]
name = "standard"
path = "tests/standard/main.rs"

[[test]]
name = "long"
path = "tests/long/main.rs"

[[test]]
name = "property_tests"
path = "tests/property_tests/main.rs"

[package.metadata.docs.rs]
features = ["platform-verifier", "log"]

# cargo-machete false positives: these are optional/feature-gated dependencies
[package.metadata.cargo-machete]
ignored = ["proptest-derive", "x25519-dalek"]

 # Realistic clippy configuration - focus on meaningful issues
 [lints.clippy]
 # Deny unwrap/expect in production code - tests can use #[allow(clippy::unwrap_used)]
 unwrap_used = { level = "deny", priority = 1 }
 expect_used = { level = "deny", priority = 1 }

# Allow indexing - often used for accessing known-good indices in hot paths
indexing_slicing = { level = "allow", priority = 2 }

# Allow arithmetic operations - performance-critical networking code often needs this
arithmetic_side_effects = { level = "allow", priority = 2 }

# Keep these enabled for safety and correctness
all = { level = "warn", priority = -1 }
correctness = { level = "deny", priority = 1 }
suspicious = { level = "warn", priority = 0 }
complexity = { level = "warn", priority = 0 }
perf = { level = "warn", priority = 0 }

# Disable overly pedantic lints
pedantic = { level = "allow", priority = -1 }
restriction = { level = "allow", priority = -1 }

# Selectively enable some useful pedantic lints, but allow exceptions
must_use_candidate = { level = "allow", priority = 2 }  # Too noisy for test constructors
missing_errors_doc = { level = "allow", priority = 2 }  # Too noisy for internal APIs
missing_panics_doc = { level = "allow", priority = 2 }  # Too noisy for test code
module_name_repetitions = { level = "allow", priority = 2 }  # Common in networking protocols

# Allow print statements in examples and test utilities
print_stdout = { level = "allow", priority = 2 }
print_stderr = { level = "allow", priority = 2 }

# Allow enum variant names that end with Error - common pattern for error types
enum_variant_names = { level = "allow", priority = 2 }

# Allow reasonable nesting in complex state machines and protocol handlers
excessive_nesting = { level = "allow", priority = 2 }

# Release profile - disable debug info to fix Windows linker LNK1318 error
# This error occurs when PDB files exceed limits on Windows CI
[profile.release]
debug = false
strip = "symbols"
# Completely disable debug info to prevent PDB generation on Windows
# Without this, the linker still creates PDB files which can exceed limits
split-debuginfo = "off"
# Use LTO to reduce binary size and avoid PDB size issues
lto = "thin"

# Patch crates.io dependencies to use local version
[patch.crates-io]
ant-quic = { path = "." }
