refactor: comprehensive audit — fix bugs, harden security, deduplicate providers, add CI/Docker
Phase 1: Fix compilation (config_path Option<PathBuf>, streaming test, stale test cleanup) Phase 2: Fix critical bugs (remove block_on deadlocks in 4 providers, fix broken SQL query builder) Phase 3: Security hardening (session manager, real auth, token masking, Gemini key to header, password policy) Phase 4: Implement stubs (real provider test, /proc health metrics, client/provider/backup endpoints, has_images) Phase 5: Code quality (shared provider helpers, explicit re-exports, all Clippy warnings fixed, unwrap removal, 6 unused deps removed, dashboard split into 7 sub-modules) Phase 6: Infrastructure (GitHub Actions CI, multi-stage Dockerfile, rustfmt.toml, clippy.toml, script fixes)
This commit is contained in:
35
src/main.rs
35
src/main.rs
@@ -1,16 +1,15 @@
|
||||
use anyhow::Result;
|
||||
use axum::{Router, routing::get};
|
||||
use std::net::SocketAddr;
|
||||
use tracing::{info, error};
|
||||
use tracing::{error, info};
|
||||
|
||||
use llm_proxy::{
|
||||
config::AppConfig,
|
||||
state::AppState,
|
||||
config::AppConfig,
|
||||
dashboard, database,
|
||||
providers::ProviderManager,
|
||||
database,
|
||||
rate_limiting::{CircuitBreakerConfig, RateLimitManager, RateLimiterConfig},
|
||||
server,
|
||||
dashboard,
|
||||
rate_limiting::{RateLimitManager, RateLimiterConfig, CircuitBreakerConfig},
|
||||
state::AppState,
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
@@ -33,7 +32,7 @@ async fn main() -> Result<()> {
|
||||
|
||||
// Initialize provider manager with configured providers
|
||||
let provider_manager = ProviderManager::new();
|
||||
|
||||
|
||||
// Initialize all supported providers (they handle their own enabled check)
|
||||
let supported_providers = vec!["openai", "gemini", "deepseek", "grok", "ollama"];
|
||||
for name in supported_providers {
|
||||
@@ -43,22 +42,28 @@ async fn main() -> Result<()> {
|
||||
}
|
||||
|
||||
// Create rate limit manager
|
||||
let rate_limit_manager = RateLimitManager::new(
|
||||
RateLimiterConfig::default(),
|
||||
CircuitBreakerConfig::default(),
|
||||
);
|
||||
|
||||
let rate_limit_manager = RateLimitManager::new(RateLimiterConfig::default(), CircuitBreakerConfig::default());
|
||||
|
||||
// Fetch model registry from models.dev
|
||||
let model_registry = match llm_proxy::utils::registry::fetch_registry().await {
|
||||
Ok(registry) => registry,
|
||||
Err(e) => {
|
||||
error!("Failed to fetch model registry: {}. Using empty registry.", e);
|
||||
llm_proxy::models::registry::ModelRegistry { providers: std::collections::HashMap::new() }
|
||||
llm_proxy::models::registry::ModelRegistry {
|
||||
providers: std::collections::HashMap::new(),
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Create application state
|
||||
let state = AppState::new(config.clone(), provider_manager, db_pool, rate_limit_manager, model_registry, config.server.auth_tokens.clone());
|
||||
let state = AppState::new(
|
||||
config.clone(),
|
||||
provider_manager,
|
||||
db_pool,
|
||||
rate_limit_manager,
|
||||
model_registry,
|
||||
config.server.auth_tokens.clone(),
|
||||
);
|
||||
|
||||
// Create application router
|
||||
let app = Router::new()
|
||||
|
||||
Reference in New Issue
Block a user