47 lines
1.2 KiB
Haskell
47 lines
1.2 KiB
Haskell
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
module Main (main) where
|
|
|
|
import Aenebris.Config
|
|
import Aenebris.Proxy
|
|
import Network.HTTP.Client (newManager, defaultManagerSettings)
|
|
import System.Environment (getArgs)
|
|
import System.Exit (exitFailure)
|
|
import System.IO (hPutStrLn, stderr)
|
|
|
|
main :: IO ()
|
|
main = do
|
|
args <- getArgs
|
|
|
|
-- Get config file path from args or use default
|
|
let configPath = case args of
|
|
(path:_) -> path
|
|
[] -> "config.yaml"
|
|
|
|
putStrLn $ "Loading configuration from: " ++ configPath
|
|
|
|
-- Load configuration
|
|
result <- loadConfig configPath
|
|
case result of
|
|
Left err -> do
|
|
hPutStrLn stderr $ "ERROR: Failed to load configuration"
|
|
hPutStrLn stderr err
|
|
exitFailure
|
|
|
|
Right config -> do
|
|
-- Validate configuration
|
|
case validateConfig config of
|
|
Left err -> do
|
|
hPutStrLn stderr $ "ERROR: Invalid configuration"
|
|
hPutStrLn stderr err
|
|
exitFailure
|
|
|
|
Right () -> do
|
|
putStrLn "✓ Configuration loaded and validated successfully"
|
|
|
|
-- Create HTTP client manager
|
|
manager <- newManager defaultManagerSettings
|
|
|
|
-- Start the proxy
|
|
startProxy config manager
|