hprox 0.5.0 → 0.5.1
raw patch · 5 files changed
+28/−8 lines, 5 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Network.HProx: DEBUG :: LogLevel
+ Network.HProx: ERROR :: LogLevel
+ Network.HProx: INFO :: LogLevel
+ Network.HProx: NONE :: LogLevel
+ Network.HProx: TRACE :: LogLevel
+ Network.HProx: WARN :: LogLevel
+ Network.HProx: [_log] :: Config -> String
+ Network.HProx: data LogLevel
- Network.HProx: Config :: Maybe String -> Int -> [(String, CertFile)] -> Maybe String -> Maybe FilePath -> Maybe String -> Maybe String -> Maybe String -> Bool -> ByteString -> LogLevel -> Config
+ Network.HProx: Config :: Maybe String -> Int -> [(String, CertFile)] -> Maybe String -> Maybe FilePath -> Maybe String -> Maybe String -> Maybe String -> Bool -> ByteString -> String -> LogLevel -> Config
Files
- Changelog.md +5/−0
- README.md +1/−1
- hprox.cabal +1/−1
- src/Network/HProx.hs +20/−6
- src/Network/HProx/Log.hs +1/−0
Changelog.md view
@@ -1,3 +1,8 @@+## 0.5.1++- export `LogLevel` type to make `Config` actually customizable+- add `--log` option to specify logging type+ ## 0.5.0 - initial HTTP/3 (QUIC) support
README.md view
@@ -54,7 +54,7 @@ hprox -p 443 -s example.com:$HOME/.acme.sh/example.com/fullchain.cer:$HOME/.acme.sh/example.com/example.com.key ``` -Browsers can be configured with PAC file URL `https://example.com/.hprox/proxy.pac`.+Browsers can be configured with PAC file URL `https://example.com/.hprox/config.pac`. * To work with `v2ray-plugin`, with fallback page to [ubuntu archive](http://archive.ubuntu.com/):
hprox.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: hprox-version: 0.5.0+version: 0.5.1 synopsis: a lightweight HTTP proxy server, and more description: Please see the README on GitHub at <https://github.com/bjin/hprox#readme> category: Web
src/Network/HProx.hs view
@@ -12,6 +12,7 @@ module Network.HProx ( CertFile (..) , Config (..)+ , LogLevel (..) , defaultConfig , getConfig , run@@ -72,6 +73,7 @@ , _doh :: Maybe String , _naive :: Bool , _name :: BS8.ByteString+ , _log :: String , _loglevel :: LogLevel #ifdef QUIC_ENABLED , _quic :: Maybe Int@@ -80,7 +82,7 @@ -- | Default value of 'Config', same as running @hprox@ without arguments defaultConfig :: Config-defaultConfig = Config Nothing 3000 [] Nothing Nothing Nothing Nothing Nothing False "hprox" INFO+defaultConfig = Config Nothing 3000 [] Nothing Nothing Nothing Nothing Nothing False "hprox" "stdout" INFO #ifdef QUIC_ENABLED Nothing #endif@@ -120,6 +122,7 @@ <*> doh <*> naive <*> name+ <*> logging <*> loglevel #ifdef QUIC_ENABLED <*> quic@@ -183,6 +186,13 @@ <> showDefault <> help "specify the server name for the 'Server' header") + logging = strOption+ ( long "log"+ <> metavar "<none|stdout|stderr|file>"+ <> value "stdout"+ <> showDefault+ <> help "specify the logging type")+ loglevel = option (maybeReader logLevelReader) ( long "loglevel" <> metavar "<trace|debug|info|warn|error|none>"@@ -200,6 +210,12 @@ setuid :: String -> IO () setuid user = getUserEntryForName user >>= setUserID . userID +getLoggerType :: String -> LogType' LogStr+getLoggerType "none" = LogNone+getLoggerType "stdout" = LogStdout 4096+getLoggerType "stderr" = LogStderr 4096+getLoggerType file = LogFileNoRotate file 4096+ -- | Read 'Config' from command line arguments getConfig :: IO Config getConfig = execParser parser@@ -208,7 +224,7 @@ run :: Application -- ^ fallback application -> Config -- ^ configuration -> IO ()-run fallback Config{..} = withLogger (LogStdout 4096) _loglevel $ \logger -> do+run fallback Config{..} = withLogger (getLoggerType _log) _loglevel $ \logger -> do logger INFO $ "hprox " <> toLogStr (showVersion version) <> " started" logger INFO $ "bind to TCP port " <> toLogStr (fromMaybe "[::]" _bind) <> ":" <> toLogStr _port @@ -276,14 +292,12 @@ , tlsSessionManager = Just smgr } - logAndFail msg = logger WARN (toLogStr msg) >> fail msg-- onSNI Nothing = logAndFail "SNI: unspecified"+ onSNI Nothing = fail "SNI: unspecified" onSNI (Just host) | checkSNI host primaryHost = return mempty | otherwise = lookupSNI host otherCerts - lookupSNI host [] = logAndFail ("SNI: unknown hostname (" ++ show host ++ ")")+ lookupSNI host [] = fail ("SNI: unknown hostname (" ++ show host ++ ")") lookupSNI host ((p, cert) : cs) | checkSNI host p = return (TLS.Credentials [cert]) | otherwise = lookupSNI host cs
src/Network/HProx/Log.hs view
@@ -17,6 +17,7 @@ import System.Log.FastLogger +-- | Logging level, default value is INFO data LogLevel = TRACE | DEBUG | INFO