packages feed

moesocks 0.1.0.27 → 0.1.1.0

raw patch · 10 files changed

+136/−129 lines, 10 files

Files

CHANGELOG.md view
@@ -1,6 +1,10 @@+0.1.1.0+-------+* Use TCP_NOTSENT_LOWAT option to reduce latency+ 0.1.0.27 ---------* Make local respect `forbidden-ip` as well, this reduce unnecessary connection+* Make local respect `forbidden-ip` as well, this reduce unnecessary connections   to the remote. * Clean up logging. 
README.md view
@@ -53,9 +53,8 @@         moesocks --help  * You might want to run `moesocks` under some kind of a supervising daemon to-  auto restart the program if it crashes. Yes, it will likely to core dump after-  some random period of time (yes, I'm working on it); On the positive side,-  there is no memory leak!+  auto restart the program if it crashes, likely due to [#10590], the fix of+  which was not included in the `7.10.2` release.   Features@@ -107,5 +106,5 @@ [shadowsocks-go]:https://github.com/shadowsocks/shadowsocks-go [shadowsocks-haskell]:https://github.com/rnons/shadowsocks-haskell [config.json]:https://raw.githubusercontent.com/nfjinjing/moesocks/master/config.json-+[#10590]:https://ghc.haskell.org/trac/ghc/ticket/10590 
moesocks.cabal view
@@ -1,6 +1,6 @@ name:               moesocks category:           Network-version:            0.1.0.27+version:            0.1.1.0 license:            Apache-2.0 synopsis:           A functional firewall killer description:        A socks5 proxy using the client / server architecture.@@ -23,8 +23,9 @@  executable moesocks   main-is:             Main.hs-  ghc-options:        -Wall -fno-warn-unused-do-bind -threaded -                      -rtsopts "-with-rtsopts=-N -c"+  ghc-options:        -Wall -fno-warn-unused-do-bind -O2 +                      -threaded+                      -- -rtsopts "-with-rtsopts=-N -c"   build-depends:       base > 4 && <= 5                       , HsOpenSSL                       , aeson
src/Main.hs view
@@ -3,6 +3,7 @@ import Control.Monad.Except import Control.Monad.Reader hiding (local) import Network.MoeSocks.App+import Network.MoeSocks.Encrypt import Network.MoeSocks.Helper import Network.MoeSocks.Options import Options.Applicative hiding (Parser)@@ -10,10 +11,10 @@ import System.Exit  main :: IO ()-main = do+main = ssl - do   _options <- execParser opts   r <- runExceptT - runReaderT moeApp _options   case r of-    Left e -> pute e >> exitFailure+    Left e -> error_ e >> exitFailure     Right _ -> pure () 
src/Network/MoeSocks/App.hs view
@@ -147,7 +147,7 @@      Just _config -> do       let configStr = showConfig _config ^. _Text :: String-      io - puts - "Using config: " <> configStr+      io - debug_ - "Using config: " <> configStr       pure - _config                 @@ -173,7 +173,7 @@   _options <- ask    io - initLogger - _options ^. verbosity   -  io - puts - show _options+  io - debug_ - show _options      _config <- parseConfig - _options   let _c = _config@@ -200,14 +200,13 @@                      case aAppType of             TCP_App -> do-              _info - "LT: " <> aID <> " nyaa!"+              info_ - "LT: " <> aID <> " nyaa!"               listen _localSocket maxListenQueue                let handleLocal _socket = do                     _s@(_newSocket, _newSockAddr) <- accept _socket                     setSocketCloseOnExec _newSocket-                    -- send immediately!-                    setSocketOption _socket NoDelay 1 +                    setSocketSendFast _socket                                          forkIO - catchExceptAsyncLog "LT" -                                logSA "L TCP client socket" (pure _s) -@@ -216,12 +215,12 @@               forever - handleLocal _localSocket              UDP_App -> do-              _info - "LU: " <> aID <> " nyaa!"+              info_ - "LU: " <> aID <> " nyaa!"               let handleLocal = do                     (_msg, _sockAddr) <-                          recvFrom _localSocket _PacketLength -                    puts - "L UDP: " <> show _msg+                    debug_ - "L UDP: " <> show _msg                                          let _s = (_localSocket, _sockAddr) @@ -267,20 +266,17 @@   let remote_TCP_App :: (Socket, SockAddr) -> IO ()       remote_TCP_App s = logSA "R loop" (pure s) -         \(_remoteSocket, _remoteAddr) -> do-          _info - "RT: TCP relay " <> showWrapped _remoteAddr <> " nyaa!"+          info_ - "RT: TCP relay " <> showWrapped _remoteAddr <> " nyaa!"            setSocketOption _remoteSocket ReuseAddr 1           bindSocket _remoteSocket _remoteAddr -          {-let _maximum_number_of_queued_connection = 1 :: Int-}-           listen _remoteSocket maxListenQueue            let handleRemote _socket = do                 (_newSocket, _) <- accept _socket                 setSocketCloseOnExec _newSocket-                -- send immediately!-                setSocketOption _socket NoDelay 1 +                setSocketSendFast _socket                                  forkIO - catchExceptAsyncLog "RT" -                              logSocket "R remote socket" (pure _newSocket) -@@ -291,7 +287,7 @@   let remote_UDP_App :: (Socket, SockAddr) -> IO ()       remote_UDP_App s = logSA "R loop" (pure s) -         \(_remoteSocket, _remoteAddr) -> do-          _info - "RU: UDP relay " <> showWrapped _remoteAddr <> " nyaa!"+          info_ - "RU: UDP relay " <> showWrapped _remoteAddr <> " nyaa!"            setSocketOption _remoteSocket ReuseAddr 1           bindSocket _remoteSocket _remoteAddr@@ -299,7 +295,7 @@           let handleRemote = do                 (_msg, _sockAddr) <- recvFrom _remoteSocket _PacketLength -                puts - "R UDP: " <> show _msg+                debug_ - "R UDP: " <> show _msg                  let _s = (_remoteSocket, _sockAddr) @@ -307,8 +303,6 @@                 forkIO - catchExceptAsyncLog "RU" -                              remote_UDP_RequestHandler _env _msg _s -                -           forever handleRemote  @@ -358,7 +352,7 @@               then                  forever - sleep 1000               else-                pute "Nothing to run!"+                error_ "Nothing to run!"                            else _socks5App 
src/Network/MoeSocks/Common.hs view
@@ -42,7 +42,7 @@ withCheckedForbidden_IP_List :: AddressType -> [IPRange] -> IO a -> IO () withCheckedForbidden_IP_List aAddressType aForbidden_IP_List aIO =    if checkForbidden_IP_List aAddressType aForbidden_IP_List -    then pute - showAddressType aAddressType ^. _Text +    then error_ - showAddressType aAddressType ^. _Text                  <> " is in forbidden-ip list"     else () <$ aIO @@ -57,6 +57,10 @@                    _r ^. addressType . to showAddressType . _Text                 <> ":"                 <> _r ^. portNumber . to show++showRelay :: SockAddr -> ClientRequest -> String+showRelay aSockAddr aClientRequest = +      show aSockAddr <> " -> " <> showRequest aClientRequest  addressType_To_Family :: AddressType -> Maybe Family addressType_To_Family (IPv4_address _) = Just AF_INET
src/Network/MoeSocks/Encrypt.hs view
@@ -5,7 +5,13 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE LambdaCase #-} -module Network.MoeSocks.Encrypt where+module Network.MoeSocks.Encrypt +(+  initCipherBox+, identityCipher+, ssl+)+where  import Control.Lens import Control.Monad.Except@@ -102,39 +108,39 @@                         in                         pure - Just (0, pure mempty, constCipher, constCipher) -  | otherwise =+  | otherwise = ssl -        fmap eitherToMaybe - runExceptT - initCipherBox' aMethod aPassword  initCipherBox' :: Text -> Text -> MaybeT_IO CipherBox initCipherBox' aMethod aPassword = do-  _method <- mio - ssl - getCipherByName - aMethod ^. _Text+  _method <- mio - getCipherByName - aMethod ^. _Text    (_keyLength, _IV_Length) <- getMaybe - methods ^? ix aMethod    let _hashed = hashKey (review utf8 aPassword) _keyLength _IV_Length-      _IV_Maker = ssl - randBytes _IV_Length+      _IV_Maker = randBytes _IV_Length        _encryptBuilder :: CipherBuilder       _encryptBuilder _iv = do-          _ctx <- ssl - E.cipherInitBS _method _hashed _iv Encrypt+          _ctx <- E.cipherInitBS _method _hashed _iv Encrypt            let _encrypt :: Cipher               _encrypt = \case-                  S.Nothing -> ssl - E.cipherFinalBS _ctx+                  S.Nothing -> E.cipherFinalBS _ctx                   S.Just _bytes -> do-                    ssl - E.cipherUpdateBS _ctx _bytes+                    E.cipherUpdateBS _ctx _bytes            pure _encrypt        _decryptBuilder :: CipherBuilder        _decryptBuilder _iv = do-          _ctx <- ssl - E.cipherInitBS _method _hashed _iv Decrypt+          _ctx <- E.cipherInitBS _method _hashed _iv Decrypt            let _decrypt :: Cipher               _decrypt = \case-                  S.Nothing -> ssl - E.cipherFinalBS _ctx+                  S.Nothing -> E.cipherFinalBS _ctx                   S.Just _bytes -> do-                    ssl - E.cipherUpdateBS _ctx _bytes +                    E.cipherUpdateBS _ctx _bytes                       pure _decrypt           
src/Network/MoeSocks/Helper.hs view
@@ -67,38 +67,23 @@   {-aIO <* takeMVar syncLock-}   aIO -{-puts :: String -> IO ()-}-{-puts = sync . debugM "moe" . ("😽  " <>)-}--{-pute :: String -> IO ()-}-{-pute = sync . errorM "moe" . ("😾  " <>)-}--{-_warning :: String -> IO ()-}-{-_warning = sync . warningM "moe" . ("😾  " <>)-}--{-_info :: String -> IO ()-}-{-_info = sync . infoM "moe" . ("😺  " <>)-}--{-_notice :: String -> IO ()-}-{-_notice = sync . noticeM "moe" . ("😼  " <>)-}--puts :: String -> IO ()-puts = sync . debugM "moe" +debug_ :: String -> IO ()+debug_ = sync . debugM "moe"  -pute :: String -> IO ()-pute = sync . errorM "moe" +error_ :: String -> IO ()+error_ = sync . errorM "moe"  -_warning :: String -> IO ()-_warning = sync . warningM "moe" +warning_ :: String -> IO ()+warning_ = sync . warningM "moe"  -_info :: String -> IO ()-_info = sync . infoM "moe" +info_ :: String -> IO ()+info_ = sync . infoM "moe"  -_notice :: String -> IO ()-_notice = sync . noticeM "moe" +notice_ :: String -> IO ()+notice_ = sync . noticeM "moe"  -puteT :: Text -> IO ()-puteT = pute . view _Text+error_T :: Text -> IO ()+error_T = error_ . view _Text  showBytes :: ByteString -> String showBytes = show . S.unpack@@ -110,13 +95,13 @@ foreverRun _io = do   forever - do     _io-    puts "foreverRun delay 1 second"+    debug_ "foreverRun delay 1 second"     sleep 1  logClose :: String -> Socket -> IO () logClose aID aSocket = do   pure aID-  puts - "Closing socket " <> aID+  debug_ - "Closing socket " <> aID   close aSocket   @@ -125,7 +110,7 @@ logSocketWithAddress aID _init f = do   catch (bracket _init (logClose aID . fst) f) -        \(e :: SomeException) -> do-      puts - "logSocket: Exception in " <> aID <> ": " <> show e+      debug_ - "logSocket: Exception in " <> aID <> ": " <> show e       throw e  logSA:: String -> IO (Socket, SockAddr) -> @@ -135,31 +120,31 @@ logSocket :: String -> IO Socket -> (Socket -> IO a) -> IO a logSocket aID _init f =   catch (bracket _init (logClose aID) f) - \e -> do-      puts - "Exception in " <> aID <> ": " <> show (e :: SomeException)+      debug_ - "Exception in " <> aID <> ": " <> show (e :: SomeException)       throw e  catchExceptAsyncLog :: String -> IO a -> IO () catchExceptAsyncLog aID aIO = catches (() <$ aIO)                  [                    Handler - \(e :: AsyncException) -> do-                            pute - "ASyncException in " +                            error_ - "ASyncException in "                                      <> aID                                     <> " : " <> show e                             throw e                 , Handler - \(e :: SomeException) -> -                            pute - aID+                            error_ - aID                                     <> ": " <> show e                 ]  catchIO:: String -> IO a -> IO () catchIO aID aIO = catch (() <$ aIO) - \e ->-                pute - "IOError in " <> aID <> ": " +                error_ - "IOError in " <> aID <> ": "                    <> show (e :: IOException)                  logException :: String -> IO a -> IO () logException aID aIO = catch (() <$ aIO) - \e ->                          do-                          puts - "Error in " <> aID <> ": " +                          debug_ - "Error in " <> aID <> ": "                              <> show (e :: SomeException)                           throw e @@ -168,7 +153,7 @@   let _io = wrapIO x       aID = x ^. _1 . _Just  -  puts - "waiting for : " <> aID+  debug_ - "waiting for : " <> aID   _io    wrapIO :: (Maybe String, IO c) -> IO ()@@ -192,7 +177,7 @@   let _xID = x ^. _1 . _Just        _yID = y ^. _1 . _Just       _hID = _xID <> " / " <> _yID-  puts - "All done for " <> _hID+  debug_ - "All done for " <> _hID   pure ()  connectTunnel :: (Maybe String, IO ()) -> (Maybe String, IO ()) -> IO ()@@ -214,7 +199,7 @@                         Maybe Family -> Text -> i -> SocketType ->                          IO (Socket, SockAddr) getSocketWithHint maybeFamily aHost aPort aSocketType = do-    {-puts - "getSocket: " <> show aHost <> ":" <> show aPort-}+    {-debug_ - "getSocket: " <> show aHost <> ":" <> show aPort-}      maybeAddrInfo <- firstOf folded <$>                   getAddrInfo (Just hints) @@ -236,9 +221,9 @@           when (aSocketType == Stream) -             setSocketOption _socket NoDelay 1  -          puts - "Getting socket: " <> show addrInfo-          {-puts - "Socket family: " <> show family-}-          {-puts - "Socket protocol: " <> show protocol -}+          debug_ - "Getting socket: " <> show addrInfo+          {-debug_ - "Socket family: " <> show family-}+          {-debug_ - "Socket protocol: " <> show protocol -}            pure (_socket, address)           @@ -279,7 +264,7 @@   where     _loop _buffer = do       _randomLength <- randomRIO (0, aFlushBound)-      {-_notice - "randomLength: " <> show _randomLength-}+      {-notice_ - "randomLength: " <> show _randomLength-}       let (_thisBuffer, _nextBuffer) = S.splitAt _randomLength _buffer       sendAll aSocket _thisBuffer       when (_nextBuffer & isn't _Empty) - do@@ -326,7 +311,7 @@                         Socket -> IO (ByteString, a)     parseSocketWith _id _parser _socket = do       _rawBytes <- recv_ _socket-      {-puts - "rawBytes: " <> show _rawBytes-}+      {-debug_ - "rawBytes: " <> show _rawBytes-}       _bytes <- _decrypt (S.Just _rawBytes)        case _parser - _partial <> _bytes of@@ -350,7 +335,7 @@       _produce _bytesReceived = flip onException (f S.Nothing) - do         _r <- timeoutFor aID aTimeout - recv_ aSocket         {-when ("L" `isPrefixOf` aID) - do-}-          {-_notice - "Get chunk: " <> (show - S.length _r) <> " " <> aID-}+          {-notice_ - "Get chunk: " <> (show - S.length _r) <> " " <> aID-}                  if (_r & isn't _Empty)            then do@@ -363,13 +348,13 @@                let _speed = _bytesK / _timeDiff -              puts - "Produce speed is: " <> show (floor _speed :: Int) <> " K"+              debug_ - "Produce speed is: " <> show (floor _speed :: Int) <> " K"                when (_speed > _throttle) - do                 let _sleepTime = ((_bytesK + (-_timeDiff * _throttle))                                       / _throttle ) * 1000 * 1000 -                puts - "Produce sleeping for: " <> show _sleepTime +                debug_ - "Produce sleeping for: " <> show _sleepTime                          <> " miliseconds."                 threadDelay - floor - _sleepTime               @@ -377,7 +362,7 @@             yield             _produce (_bytesReceived + S.length _r)           else do-            puts -  "Half closed: " <> aID +            debug_ -  "Half closed: " <> aID              f S.Nothing >>= atomically . writeTBQueue aTBQueue . S.Just             atomically - writeTBQueue aTBQueue S.Nothing @@ -406,13 +391,13 @@            let _speed = _bytesK / _timeDiff -          puts - "Consume speed is: " <> show (floor _speed :: Int) <> " K"+          debug_ - "Consume speed is: " <> show (floor _speed :: Int) <> " K"            when (_speed > _throttle) - do             let _sleepTime = ((_bytesK + (-_timeDiff * _throttle))                                   / _throttle ) * 1000 * 1000 -            puts - "Consume sleeping for: " <> show _sleepTime +            debug_ - "Consume sleeping for: " <> show _sleepTime                      <> " miliseconds."             threadDelay - floor - _sleepTime @@ -436,6 +421,18 @@   _consume 0 `onException` _shutdown   pure () ++setSocket_TCP_NOTSENT_LOWAT :: Socket -> IO ()+setSocket_TCP_NOTSENT_LOWAT aSocket = +  let _TCP_NOTSENT_LOWAT = 25+      _TCP_Option = 6+  in+  setSocketOption aSocket (CustomSockOpt (_TCP_Option, _TCP_NOTSENT_LOWAT)) 1 ++setSocketSendFast :: Socket -> IO ()+setSocketSendFast aSocket = do+  setSocketOption aSocket NoDelay 1 +  setSocket_TCP_NOTSENT_LOWAT aSocket   -- Copied and slightly modified from: 
src/Network/MoeSocks/TCP.hs view
@@ -73,7 +73,7 @@   let _addr = _clientRequest ^. addressType       _forbidden_IP = aEnv ^. options . forbidden_IP -  puts - "checking: " <> show _addr <> " ? " <> show _forbidden_IP+  debug_ - "checking: " <> show _addr <> " ? " <> show _forbidden_IP   withCheckedForbidden_IP_List _addr _forbidden_IP - do     let          _c = aEnv ^. config @@ -84,12 +84,12 @@         _initSocket =              getSocket (_c ^. remote) (_c ^. remotePort) Stream  -    puts - "L: " <> show _clientRequest+    debug_ - "L: " <> show _clientRequest          logSA "L remote socket" _initSocket -        \(_remoteSocket, _remoteAddress) -> do       connect _remoteSocket _remoteAddress-+      setSocketSendFast _remoteSocket        _localPeerAddr <- getPeerName aSocket       _remoteSocketName <- getSocketName _remoteSocket@@ -99,9 +99,9 @@         send_ aSocket - builder_To_ByteString _connectionReplyBuilder        -      let _msg = show _localPeerAddr <> " -> " <> showRequest _clientRequest+      let _msg = showRelay _localPeerAddr _clientRequest       -      _info - "LT: " <> _msg+      info_ - "LT: " <> _msg        let handleLocal _remoteSocket = do             _encodeIV <- _cipherBox ^. generate_IV @@ -113,7 +113,7 @@             _sendChannel <- newTBQueueIO - _c ^. tcpBufferSize             _receiveChannel <- newTBQueueIO - _c ^. tcpBufferSize -            let _infoId x = x <> " " <> _msg+            let info_Id x = x <> " " <> _msg                 _timeout = _c ^. timeout * 1000 * 1000                 _throttle =                    if _c ^. throttle@@ -129,7 +129,7 @@                       _partialBytesAfterClientRequest                    let _produce = do-                                    produceLoop (_infoId "L --> + Loop")+                                    produceLoop (info_Id "L --> + Loop")                                       _timeout                                       _NoThrottle                                       aSocket @@ -137,7 +137,7 @@                                       _encrypt                    let _consume = do-                                    consumeLoop (_infoId "L --> - Loop")+                                    consumeLoop (info_Id "L --> - Loop")                                       _timeout                                       _throttle                                       _remoteSocket @@ -146,8 +146,8 @@                                       _flushBound                   finally                     (-                      connectMarket (Just - _infoId "L --> +", _produce)-                                    (Just - _infoId "L --> -", _consume)+                      connectMarket (Just - info_Id "L --> +", _produce)+                                    (Just - info_Id "L --> -", _consume)                     ) -                     pure () @@ -155,7 +155,7 @@                   _decodeIV <- recv _remoteSocket (_cipherBox ^. ivLength)                   _decrypt <- _cipherBox ^. decryptBuilder - _decodeIV -                  let _produce = produceLoop (_infoId "L <-- + Loop")+                  let _produce = produceLoop (info_Id "L <-- + Loop")                                     _timeout                                     _NoThrottle                                     _remoteSocket @@ -163,7 +163,7 @@                                     _decrypt                    let _consume = do-                                    consumeLoop (_infoId "L <-- - Loop")+                                    consumeLoop (info_Id "L <-- - Loop")                                       _timeout                                       _NoThrottle                                       aSocket @@ -172,14 +172,14 @@                                       _flushBound                   finally                      (-                      connectMarket (Just - _infoId "L <-- +", _produce)-                                    (Just - _infoId "L <-- -", _consume)+                      connectMarket (Just - info_Id "L <-- +", _produce)+                                    (Just - info_Id "L <-- -", _consume)                     ) -                     pure ()              connectTunnel-              (Just - _infoId "L -->", sendThread)-              (Just - _infoId "L <--", receiveThread)+              (Just - info_Id "L -->", sendThread)+              (Just - info_Id "L <--", receiveThread)         handleLocal _remoteSocket@@ -210,23 +210,24 @@         (_addr, _) = sockAddr_To_Pair _targetSocketAddress         _forbidden_IP = _options ^. forbidden_IP -    puts - "checking: " <> show _addr <> " ? " <> show _forbidden_IP+    debug_ - "checking: " <> show _addr <> " ? " <> show _forbidden_IP     withCheckedForbidden_IP_List _addr _forbidden_IP - do       connect _targetSocket _targetSocketAddress+      setSocketSendFast _targetSocket        _remotePeerAddr <- getPeerName aSocket       _targetPeerAddr <- getPeerName _targetSocket -      let _msg = show _remotePeerAddr <> " -> " <> showRequest _clientRequest+      let _msg = showRelay _remotePeerAddr _clientRequest -      _info - "RT: " <> _msg+      info_ - "RT: " <> _msg        let            handleTarget _leftOverBytes __targetSocket = do             _sendChannel <- newTBQueueIO - _c ^. tcpBufferSize             _receiveChannel <- newTBQueueIO - _c ^. tcpBufferSize -            let _infoId x = x <> " " <> _msg+            let info_Id x = x <> " " <> _msg                 -- let remote wait slightly longer, so local can timeout                 -- and disconnect                 _timeout = (_c ^. timeout + 30) * 1000 * 1000@@ -242,14 +243,14 @@                                   S.Just _leftOverBytes                    let _produce = do-                                    produceLoop (_infoId "R --> + Loop")+                                    produceLoop (info_Id "R --> + Loop")                                       _timeout                                       _NoThrottle                                        aSocket                                       _sendChannel                                       _decrypt -                  let _consume = consumeLoop (_infoId "R --> - Loop")+                  let _consume = consumeLoop (info_Id "R --> - Loop")                                     _timeout                                     _NoThrottle                                     _targetSocket@@ -259,8 +260,8 @@                    finally                     (-                      connectMarket (Just - _infoId "R --> +", _produce)-                                    (Just - _infoId "R --> -", _consume)+                      connectMarket (Just - info_Id "R --> +", _produce)+                                    (Just - info_Id "R --> -", _consume)                     ) -                     pure () @@ -270,7 +271,7 @@                   sendBytes _receiveChannel _encodeIV                    let _produce = do-                                    produceLoop (_infoId "R <-- + Loop")+                                    produceLoop (info_Id "R <-- + Loop")                                       _timeout                                       _NoThrottle                                        _targetSocket@@ -279,7 +280,7 @@                     let _consume = do-                                    consumeLoop (_infoId "R <-- - Loop")+                                    consumeLoop (info_Id "R <-- - Loop")                                       _timeout                                       _throttle                                       aSocket@@ -289,13 +290,13 @@                    finally                      (-                      connectMarket (Just - _infoId "R <-- +", _produce)-                                    (Just - _infoId "R <-- -", _consume)+                      connectMarket (Just - info_Id "R <-- +", _produce)+                                    (Just - info_Id "R <-- -", _consume)                     ) -                     pure ()              connectTunnel-              (Just - _infoId "R -->", sendThread)-              (Just - _infoId "R <--", receiveThread)+              (Just - info_Id "R -->", sendThread)+              (Just - info_Id "R <--", receiveThread)                    handleTarget _leftOverBytes _targetSocket
src/Network/MoeSocks/UDP.hs view
@@ -56,12 +56,12 @@                             forwardRemoteHost)                           (aForwarding ^. forwardRemotePort)   -  {-puts - "L UDP: " <> show _clientRequest-}+  {-debug_ - "L UDP: " <> show _clientRequest-}    let _addr = _clientRequest ^. addressType       _forbidden_IP = aEnv ^. options . forbidden_IP -  puts - "checking: " <> show _addr <> " ? " <> show _forbidden_IP+  debug_ - "checking: " <> show _addr <> " ? " <> show _forbidden_IP      withCheckedForbidden_IP_List _addr _forbidden_IP - do     _sa <- getSocket (_c ^. remote) (_c ^. remotePort) Datagram@@ -77,10 +77,10 @@          let _bytes = buildShadowSocksRequest _clientRequest aMessage -        {-puts - "L UDP: " <> show _bytes-}+        {-debug_ - "L UDP: " <> show _bytes-} -        let _msg = show aSockAddr <> " -> " <> showRequest _clientRequest-        _info - "LU: " <> _msg+        let _msg = showRelay aSockAddr _clientRequest+        info_ - "LU: " <> _msg                  _eMsg <- _encrypt (S.Just _bytes) @@ -117,20 +117,20 @@    (_decryptedMessage, _clientRequest) <- parseShadowSocksRequest _msg   -  {-puts - "R UDP: " <> show _clientRequest-}-  {-puts - "R UDP: " <> show _decryptedMessage-}+  {-debug_ - "R UDP: " <> show _clientRequest-}+  {-debug_ - "R UDP: " <> show _decryptedMessage-}      logSA "R UDP -->:" (initTarget _clientRequest) - \_r -> do-    {-puts - "R UDP targetSocket: " <> show _r-}+    {-debug_ - "R UDP targetSocket: " <> show _r-}          let (_targetSocket, _targetSocketAddress) = _r          (_addr, _) = sockAddr_To_Pair _targetSocketAddress         _forbidden_IP = _options ^. forbidden_IP -    puts - "checking: " <> show _addr <> " ? " <> show _forbidden_IP+    debug_ - "checking: " <> show _addr <> " ? " <> show _forbidden_IP     withCheckedForbidden_IP_List _addr _forbidden_IP - do-      let _msg = show aSockAddr <> " -> " <> showRequest _clientRequest-      _info - "RU: " <> _msg+      let _msg = showRelay aSockAddr _clientRequest+      info_ - "RU: " <> _msg        connect _targetSocket _targetSocketAddress       @@ -138,7 +138,7 @@        _r <- buildShadowSocksRequest _clientRequest <$> recv_ _targetSocket -      {-puts - "R UDP <--: " <> show _r-}+      {-debug_ - "R UDP <--: " <> show _r-}        when (_r & isn't _Empty) - do         _encodeIV <- _cipherBox ^. generate_IV