Skip to content

Crate Map

Dwaar is organized as a Cargo workspace under crates/. Each crate has a single responsibility; dwaar-cli is the only entry point that wires them together.

dwaar-ingress is an independent binary that talks to the Dwaar admin HTTP API over the network; it does not link any Dwaar library crates.

CrateTypeDescriptionKey Types
dwaar-corelibCore proxy engine — ProxyHttp implementation, route table, per-request context, cache, QUIC/H3 bridge with H2 upstream multiplexing, file server, FastCGI clientDwaarProxy, RouteTable, Route, RequestContext, Handler, QuicService, BufferedConn, H2ConnPool
dwaar-configlibDwaarfile parser, AST model, config compiler, hot-reload watcherDwaarConfig, SiteBlock, Directive, ConfigWatcher, CompiledTlsConfig
dwaar-tlslibTLS termination, SNI-based cert dispatch, ACME client (Let’s Encrypt + Google Trust Services), OCSP stapling, mTLSSniResolver, CertStore, ChallengeSolver, CertIssuer, TlsBackgroundService
dwaar-analyticslibFirst-party analytics — JS snippet, beacon collection, in-memory aggregation (HyperLogLog, t-digest, top-K), Prometheus metrics, HTML injector, decompressorAggregationService, AggEvent, AnalyticsSnapshot, HtmlInjector, PrometheusMetrics, RateCacheMetrics
dwaar-pluginslibPlugin trait and chain, built-in plugins: bot detection (Aho-Corasick), rate limiting (token bucket), IP filter (CIDR trie), compression (gzip/br/zstd), security headers, under-attack mode, forward auth, WASM pluginsDwaarPlugin, PluginChain, PluginCtx, BotDetector, RateLimiter, CompressionPlugin, WasmPlugin
dwaar-adminlibAdmin HTTP API service — route inspection, live metrics, config reload, health endpointAdminService
dwaar-loglibStructured request logging — RequestLog type, batch writer background service, stdout/file/unix-socket output destinationsRequestLog, LogSender, LogReceiver, LogOutput, FileRotationWriter, UnixSocketWriter
dwaar-geolibGeoIP lookup — IP to country/city via memory-mapped MaxMind GeoLite2 databaseGeoLookup, CityResult
dwaar-dockerlibDocker socket watcher — discovers containers via labels, emits route add/remove eventsDockerClient, ContainerRoute
dwaar-clibinProcess entry point — CLI argument parsing, Pingora service assembly, background service wiring, signal handlingmain
dwaar-ingressbinKubernetes ingress controller — watches Ingress resources via kube-rs, translates to Dwaar admin API callsmain

dwaar-clicrates/dwaar-cli/src/main.rs

Section titled “dwaar-cli — crates/dwaar-cli/src/main.rs”

The only binary that links the full Dwaar library stack. Responsibilities:

  • Parse CLI flags (clap) including --config, --no-tls, --no-metrics, --no-cache, --h3
  • Compile the Dwaarfile via dwaar-config into a RouteTable and CompiledTlsConfig
  • Build and register Pingora services: HTTP proxy, HTTPS proxy, QUIC listener (H3), admin API
  • Wire background services: TlsBackgroundService (ACME renewal), LogReceiver (batch writer), AggregationService (analytics), PrometheusMetrics scrape endpoint
  • Load optional subsystems: GeoIP database, Docker watcher, jemalloc allocator
  • Call server.run_forever() to hand off control to Pingora’s multi-threaded runtime

dwaar-ingresscrates/dwaar-ingress/src/main.rs

Section titled “dwaar-ingress — crates/dwaar-ingress/src/main.rs”

A standalone Kubernetes controller. Does not link any Dwaar library crates. Responsibilities:

  • Connect to the Kubernetes API server using in-cluster credentials (via kube-rs)
  • Watch Ingress resources in the configured namespace using a reflector/watcher pattern
  • Translate Ingress spec (host, paths, TLS secrets) into Dwaar admin API calls (POST /admin/routes, DELETE /admin/routes/:domain)
  • Handle leader election so only one replica applies changes when running with multiple replicas
  • Reconnect with exponential backoff on API server disconnects