{-# LANGUAGE MultiWayIf #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} module Main where import Control.Concurrent import Control.Monad import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as C8 import Data.UnixTime import Data.Word import Foreign.C.Types import qualified Network.HTTP3.Client as H3 import Network.TLS.QUIC import System.Console.GetOpt import System.Environment import System.Exit import System.IO import Text.Printf import qualified UnliftIO.Timeout as T import ClientX import Common import Network.QUIC import Network.QUIC.Client import Network.QUIC.Internal hiding (RTT0) data Options = Options { optDebugLog :: Bool , optShow :: Bool , optQLogDir :: Maybe FilePath , optKeyLogFile :: Maybe FilePath , optGroups :: Maybe String , optValidate :: Bool , optHQ :: Bool , optVerNego :: Bool , optResumption :: Bool , opt0RTT :: Bool , optRetry :: Bool , optQuantum :: Bool , optInteractive :: Bool , optMigration :: Maybe ConnectionControl , optPacketSize :: Maybe Int , optPerformance :: Word64 , optNumOfReqs :: Int , optUnconSock :: Bool } deriving (Show) defaultOptions :: Options defaultOptions = Options { optDebugLog = False , optShow = False , optQLogDir = Nothing , optKeyLogFile = Nothing , optGroups = Nothing , optHQ = False , optValidate = False , optVerNego = False , optResumption = False , opt0RTT = False , optRetry = False , optQuantum = False , optInteractive = False , optMigration = Nothing , optPacketSize = Nothing , optPerformance = 0 , optNumOfReqs = 1 , optUnconSock = True } usage :: String usage = "Usage: h3-client [OPTION] addr port [path]" options :: [OptDescr (Options -> Options)] options = [ Option ['d'] ["debug"] (NoArg (\o -> o{optDebugLog = True})) "print debug info" , Option ['v'] ["show-content"] (NoArg (\o -> o{optShow = True})) "print downloaded content" , Option ['q'] ["qlog-dir"] (ReqArg (\dir o -> o{optQLogDir = Just dir}) "