packages feed

moesocks 0.1.0.13 → 0.1.0.14

raw patch · 9 files changed

+92/−75 lines, 9 files

Files

+ CHANGELOG.md view
@@ -0,0 +1,3 @@+0.1.0.14+--------+* Add IPv6 support
+ README.md view
@@ -0,0 +1,49 @@+MoeSocks+========+++A socks5 proxy using the client / server architecture.++MoeSocks is greatly inspired by [shadowsocks].++A sample `config.json` file is included in this repository and the cabal+archive.++type `moesocks --help` for help.++Features+--------+* TCP port forwarding +* Per connection throttling (as a side effect of trying to find a bug in the+remote)++Not working+-----------+* Remote is flaky +* Socks4 / Socks4a+* UDP over Socks5+* Four times slower then original Python's implementation++Planning features+------------------+* None++Note+------++There's a bug that prevents remote from working correctly.++You should use the python implementation of [shadowsocks] on the remote+server.++There is an earlier implementation of [shadowsocks in Haskell] by rnons that+makes MoeSocks possible. ++The original goal of MoeSocks is to provide extra configurability to standard+shadowsocks, but it has been discarded since the remote is too flaky. ++[shadowsocks]:https://github.com/shadowsocks/shadowsocks +[shadowsocks in Haskell]:https://github.com/rnons/shadowsocks-haskell+++
moesocks.cabal view
@@ -1,6 +1,6 @@ name:               moesocks category:           Network-version:            0.1.0.13+version:            0.1.0.14 license:            Apache-2.0 synopsis:           A functional firewall killer description:        A socks5 proxy using the client / server architecture.@@ -14,7 +14,8 @@ tested-with:        GHC == 7.10.1  extra-source-files:     config.json-                      , readme.md+                      , README.md+                      , CHANGELOG.md  source-repository head   type: git
− readme.md
@@ -1,50 +0,0 @@-MoeSocks-========---A socks5 proxy using the client / server architecture.--MoeSocks is greatly inspired by [shadowsocks].--A sample `config.json` file is included in this repository and the cabal-archive.--type `moesocks --help` for help.--Features----------* TCP port forwarding -* Per connection throttling (as a side effect of trying to find a bug in the-remote)--Not working-------------* Remote is flaky -* IPv6-* Socks4 / Socks4a-* UDP over Socks5-* Four times slower then original Python's implementation--Planning features--------------------* None--Note---------There's a bug that prevents remote from working correctly.--You should use the python implementation of [shadowsocks] on the remote-server.--There is an earlier implementation of [shadowsocks in Haskell] by rnons that-makes MoeSocks possible. --The original goal of MoeSocks is to provide extra configurability to standard-shadowsocks, but it has been discarded since the remote is too flaky. --[shadowsocks]:https://github.com/shadowsocks/shadowsocks -[shadowsocks in Haskell]:https://github.com/rnons/shadowsocks-haskell---
src/Network/MoeSocks/App.hs view
@@ -36,14 +36,16 @@ import qualified System.IO as IO import qualified System.Log.Handler as LogHandler + showAddressType :: AddressType -> Text showAddressType (IPv4_address xs) = view (from _Text) -                                        concat - L.intersperse "." -                                        map show - xs ^.. each showAddressType (Domain_name x)   = x -showAddressType x                 = error --                                            "IPv6 target not supported:"-                                            <> show x+showAddressType (IPv6_address xs) = view (from _Text) -+                                      concat - L.intersperse ":" - +                                      map show -+                                        xs ^.. each  showConnectionType :: ConnectionType -> String showConnectionType TCP_IP_stream_connection = "TCP_Stream"
src/Network/MoeSocks/BuilderAndParser.hs view
@@ -20,6 +20,8 @@ import qualified Data.ByteString.Builder as B import qualified Prelude as P +{-import Debug.Trace-}+ socksVersion :: Word8 socksVersion = 5 @@ -89,12 +91,13 @@    SockAddrInet6 _port _ _host _ ->                                     let -                                        _r@(_a, _b, _c, _d) = +                                        _r@(_a, _b, _c, _d, _e, _f, _g, _h) =                                            decode . runPut . put - _host-                                          :: (Word32, Word32, Word32, Word32)+                                          :: (Word16, Word16, Word16, Word16+                                              , Word16, Word16, Word16, Word16)                                     in -                                    ( IPv6_address - flip4 _r+                                    ( IPv6_address - _r ^.. each                                     , fromIntegral _port                                     ) @@ -138,7 +141,7 @@      IPv6_address _address ->                             B.word8 4-                       <> foldMapOf each B.word32BE _address+                       <> foldMapOf each B.word16BE _address   @@ -161,11 +164,6 @@       addressTypeBuilder (aClientRequest ^. addressType)   <>  portBuilder (aClientRequest ^. portNumber) -anyWord32be :: Parser Word32-anyWord32be = do-  _b <- count 4 anyWord8-  pure - decode - runPut - put _b- addressTypeParser :: Parser AddressType addressTypeParser = choice   [@@ -182,15 +180,17 @@                         _nameLength <- anyWord8                         view utf8 <$> (take - fromIntegral _nameLength) -  {-, IPv6_address <$>  do-}-                        {-word8 4 -}-                        {-_a <- anyWord32be-}-                        {-_b <- anyWord32be-}-                        {-_c <- anyWord32be-}-                        {-_d <- anyWord32be -}-                        {-pure - (_a, _b, _c, _d)-}+  , IPv6_address <$>  do+                        word8 4 +                        _r <- count 8 anyWord16+                        {-pure - trace ("parsed IPv6: " <> show _r) _r-}+                        pure _r   ] +anyWord16 :: Parser Word16+anyWord16 = do+  _b <- (,) <$> anyWord8 <*> anyWord8+  pure - decode - runPut - put _b  shadowSocksRequestParser :: Parser ClientRequest shadowSocksRequestParser = do
src/Network/MoeSocks/Helper.hs view
@@ -185,6 +185,8 @@ getSocket :: (Integral i, Show i) => Text -> i -> SocketType ->                                       IO (Socket, SockAddr) getSocket aHost aPort aSocketType = do+    {-puts - "getSocket: " <> show aHost <> ":" <> show aPort-}+     maybeAddrInfo <- firstOf folded <$>                   getAddrInfo (Just hints)                                (Just - aHost ^. _Text) (Just - show aPort)@@ -205,6 +207,7 @@           setSocketOption _socket NoDelay 1             {-puts - "Getting socket: " <> show address-}+          {-puts - "Socket family: " <> show family-}            pure (_socket, address)           @@ -212,7 +215,7 @@     hints = defaultHints {               addrFlags = [AI_ADDRCONFIG, AI_NUMERICSERV]             , addrSocketType = aSocketType-            , addrFamily = AF_INET+            {-, addrFamily = AF_INET-}             }  builder_To_ByteString :: B.Builder -> ByteString
src/Network/MoeSocks/Options.hs view
@@ -11,7 +11,7 @@ import System.Log.Logger import qualified Options.Applicative as O import Data.Attoparsec.Text (Parser, takeWhile, char, decimal, skipSpace, -                              parseOnly, many')+                              parseOnly, many', choice)  optionParser :: O.Parser MoeOptions optionParser = @@ -65,7 +65,16 @@         skipSpace         _localForwardingPort <- decimal         char ':'-        _localForwardingRemoteHost <- takeWhile (/= ':')+        _localForwardingRemoteHost <- +          choice+            [+              do +                char '['+                _h <- takeWhile (/= ']')+                char ']'+                return _h+            , takeWhile (/= ':')+            ]         char ':'         _localForwardingRemotePort <- decimal 
src/Network/MoeSocks/Type.hs view
@@ -30,7 +30,7 @@ data AddressType =      IPv4_address (Word8, Word8, Word8, Word8)   | Domain_name Text-  | IPv6_address (Word32, Word32, Word32, Word32)+  | IPv6_address [Word16]   deriving (Show, Eq)  type Port = Int