Hello community, here is the log from the commit of package ghc-socks for openSUSE:Factory checked in at 2016-05-17 17:14:43 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-socks (Old) and /work/SRC/openSUSE:Factory/.ghc-socks.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-socks" Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-socks/ghc-socks.changes 2015-05-27 12:46:05.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-socks.new/ghc-socks.changes 2016-05-17 17:14:44.000000000 +0200 @@ -1,0 +2,6 @@ +Sat May 7 06:33:56 UTC 2016 - [email protected] + +- update to 0.5.5 +- remove uselees _service + +------------------------------------------------------------------- Old: ---- _service socks-0.5.4.tar.gz New: ---- socks-0.5.5.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-socks.spec ++++++ --- /var/tmp/diff_new_pack.rIgGbh/_old 2016-05-17 17:14:45.000000000 +0200 +++ /var/tmp/diff_new_pack.rIgGbh/_new 2016-05-17 17:14:45.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package ghc-socks # -# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -15,60 +15,71 @@ # Please submit bugfixes or comments via http://bugs.opensuse.org/ # - %global pkg_name socks -Name: ghc-socks -Version: 0.5.4 + +Name: ghc-%{pkg_name} +Version: 0.5.5 Release: 0 Summary: Socks proxy (version 5) implementation -License: BSD-3-Clause Group: System/Libraries -Url: http://hackage.haskell.org/package/%{pkg_name} -Source0: http://hackage.haskell.org/packages/archive/%{pkg_name}/%{version}/%{pkg_name}-%{version}.tar.gz + +License: BSD-3-Clause +Url: https://hackage.haskell.org/package/%{pkg_name} +Source0: https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz +BuildRoot: %{_tmppath}/%{name}-%{version}-build + BuildRequires: ghc-Cabal-devel +BuildRequires: ghc-rpm-macros # Begin cabal-rpm deps: BuildRequires: ghc-bytestring-devel BuildRequires: ghc-cereal-devel BuildRequires: ghc-network-devel -BuildRequires: ghc-rpm-macros -BuildRoot: %{_tmppath}/%{name}-%{version}-build # End cabal-rpm deps %description -Socks proxy (version 5) implementation for Haskell. +Socks proxy (version 5) implementation. + %package devel Summary: Haskell %{pkg_name} library development files Group: Development/Libraries/Other -Requires: %{name} = %{version}-%{release} Requires: ghc-compiler = %{ghc_version} -Provides: %{name}-static = %{version}-%{release} +Requires(post): ghc-compiler = %{ghc_version} +Requires(postun): ghc-compiler = %{ghc_version} +Requires: %{name} = %{version}-%{release} %description devel This package provides the Haskell %{pkg_name} library development files. + %prep %setup -q -n %{pkg_name}-%{version} + %build -%{ghc_lib_build} +%ghc_lib_build + %install -%{ghc_lib_install} +%ghc_lib_install + %post devel -%{ghc_pkg_recache} +%ghc_pkg_recache + %postun devel -%{ghc_pkg_recache} +%ghc_pkg_recache + %files -f %{name}.files %defattr(-,root,root,-) %doc LICENSE -%{_datadir}/%{pkg_name}-%{version} + %files devel -f %{name}-devel.files %defattr(-,root,root,-) %doc Example.hs README.md + %changelog ++++++ socks-0.5.4.tar.gz -> socks-0.5.5.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/socks-0.5.4/Network/Socks5/Parse.hs new/socks-0.5.5/Network/Socks5/Parse.hs --- old/socks-0.5.4/Network/Socks5/Parse.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/socks-0.5.5/Network/Socks5/Parse.hs 2016-05-05 07:30:40.000000000 +0200 @@ -0,0 +1,217 @@ +{-# LANGUAGE Rank2Types #-} +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE OverloadedStrings #-} +-- | +-- Module : Network.Socks5.Parse +-- License : BSD-style +-- Maintainer : Vincent Hanquez <[email protected]> +-- Stability : experimental +-- Portability : portable +-- +-- A very simple bytestring parser related to Parsec and Attoparsec +-- +-- Simple example: +-- +-- > > parse ((,) <$> take 2 <*> byte 0x20 <*> (bytes "abc" *> anyByte)) "xx abctest" +-- > ParseOK "est" ("xx", 116) +-- +module Network.Socks5.Parse + ( Parser + , Result(..) + -- * run the Parser + , parse + , parseFeed + -- * Parser methods + , byte + , anyByte + , bytes + , take + , takeWhile + , takeAll + , skip + , skipWhile + , skipAll + , takeStorable + ) where + +import Control.Applicative +import Control.Monad +import Data.ByteString (ByteString) +import qualified Data.ByteString as B +import qualified Data.ByteString.Internal as B (toForeignPtr) +import Data.Word +import Foreign.Storable (Storable, peekByteOff, sizeOf) +import Foreign.ForeignPtr (withForeignPtr) +import Prelude hiding (take, takeWhile) + +import System.IO.Unsafe (unsafePerformIO) + +-- | Simple parsing result, that represent respectively: +-- +-- * failure: with the error message +-- +-- * continuation: that need for more input data +-- +-- * success: the remaining unparsed data and the parser value +data Result a = + ParseFail String + | ParseMore (ByteString -> Result a) + | ParseOK ByteString a + +instance Show a => Show (Result a) where + show (ParseFail err) = "ParseFailure: " ++ err + show (ParseMore _) = "ParseMore _" + show (ParseOK b a) = "ParseOK " ++ show a ++ " " ++ show b + +type Failure r = ByteString -> String -> Result r +type Success a r = ByteString -> a -> Result r + +-- | Simple ByteString parser structure +newtype Parser a = Parser + { runParser :: forall r . ByteString -> Failure r -> Success a r -> Result r } + +instance Monad Parser where + fail errorMsg = Parser $ \buf err _ -> err buf ("failed: " ++ errorMsg) + return v = Parser $ \buf _ ok -> ok buf v + m >>= k = Parser $ \buf err ok -> + runParser m buf err (\buf' a -> runParser (k a) buf' err ok) +instance MonadPlus Parser where + mzero = fail "Parser.MonadPlus.mzero" + mplus f g = Parser $ \buf err ok -> + -- rewrite the err callback of @f to call @g + runParser f buf (\_ _ -> runParser g buf err ok) ok +instance Functor Parser where + fmap f p = Parser $ \buf err ok -> + runParser p buf err (\b a -> ok b (f a)) +instance Applicative Parser where + pure = return + (<*>) d e = d >>= \b -> e >>= \a -> return (b a) +instance Alternative Parser where + empty = fail "Parser.Alternative.empty" + (<|>) = mplus + +-- | Run a parser on an @initial ByteString. +-- +-- If the Parser need more data than available, the @feeder function +-- is automatically called and fed to the More continuation. +parseFeed :: Monad m => m B.ByteString -> Parser a -> B.ByteString -> m (Result a) +parseFeed feeder p initial = loop $ parse p initial + where loop (ParseMore k) = feeder >>= (loop . k) + loop r = return r + +-- | Run a Parser on a ByteString and return a 'Result' +parse :: Parser a -> ByteString -> Result a +parse p s = runParser p s (\_ msg -> ParseFail msg) (\b a -> ParseOK b a) + +------------------------------------------------------------ +getMore :: Parser () +getMore = Parser $ \buf err ok -> ParseMore $ \nextChunk -> + if B.null nextChunk + then err buf "EOL: need more data" + else ok (B.append buf nextChunk) () + +getAll :: Parser () +getAll = Parser $ \buf err ok -> ParseMore $ \nextChunk -> + if B.null nextChunk + then ok buf () + else runParser getAll (B.append buf nextChunk) err ok + +flushAll :: Parser () +flushAll = Parser $ \buf err ok -> ParseMore $ \nextChunk -> + if B.null nextChunk + then ok buf () + else runParser getAll B.empty err ok + +------------------------------------------------------------ + +-- | Get the next byte from the parser +anyByte :: Parser Word8 +anyByte = Parser $ \buf err ok -> + case B.uncons buf of + Nothing -> runParser (getMore >> anyByte) buf err ok + Just (c1,b2) -> ok b2 c1 + +-- | Parse a specific byte at current position +-- +-- if the byte is different than the expected on, +-- this parser will raise a failure. +byte :: Word8 -> Parser () +byte w = Parser $ \buf err ok -> + case B.uncons buf of + Nothing -> runParser (getMore >> byte w) buf err ok + Just (c1,b2) | c1 == w -> ok b2 () + | otherwise -> err buf ("byte " ++ show w ++ " : failed") + +-- | Parse a sequence of bytes from current position +-- +-- if the following bytes don't match the expected +-- bytestring completely, the parser will raise a failure +bytes :: ByteString -> Parser () +bytes allExpected = consumeEq allExpected + where errMsg = "bytes " ++ show allExpected ++ " : failed" + + -- partially consume as much as possible or raise an error. + consumeEq expected = Parser $ \actual err ok -> + let eLen = B.length expected in + if B.length actual >= eLen + then -- enough data for doing a full match + let (aMatch,aRem) = B.splitAt eLen actual + in if aMatch == expected + then ok aRem () + else err actual errMsg + else -- not enough data, match as much as we have, and then recurse. + let (eMatch, eRem) = B.splitAt (B.length actual) expected + in if actual == eMatch + then runParser (getMore >> consumeEq eRem) B.empty err ok + else err actual errMsg + +------------------------------------------------------------ + +-- | Take a storable from the current position in the stream +takeStorable :: Storable d + => Parser d +takeStorable = anyStorable undefined + where + anyStorable :: Storable d => d -> Parser d + anyStorable a = do + (fptr, off, _) <- B.toForeignPtr <$> take (sizeOf a) + return $ unsafePerformIO $ withForeignPtr fptr $ \ptr -> peekByteOff ptr off + +-- | Take @n bytes from the current position in the stream +take :: Int -> Parser ByteString +take n = Parser $ \buf err ok -> + if B.length buf >= n + then let (b1,b2) = B.splitAt n buf in ok b2 b1 + else runParser (getMore >> take n) buf err ok + +-- | Take bytes while the @predicate hold from the current position in the stream +takeWhile :: (Word8 -> Bool) -> Parser ByteString +takeWhile predicate = Parser $ \buf err ok -> + case B.span predicate buf of + (_, "") -> runParser (getMore >> takeWhile predicate) buf err ok + (b1, b2) -> ok b2 b1 + +-- | Take the remaining bytes from the current position in the stream +takeAll :: Parser ByteString +takeAll = Parser $ \buf err ok -> + runParser (getAll >> returnBuffer) buf err ok + where + returnBuffer = Parser $ \buf _ ok -> ok B.empty buf + +-- | Skip @n bytes from the current position in the stream +skip :: Int -> Parser () +skip n = Parser $ \buf err ok -> + if B.length buf >= n + then ok (B.drop n buf) () + else runParser (getMore >> skip (n - B.length buf)) B.empty err ok + +-- | Skip bytes while the @predicate hold from the current position in the stream +skipWhile :: (Word8 -> Bool) -> Parser () +skipWhile p = Parser $ \buf err ok -> + case B.span p buf of + (_, "") -> runParser (getMore >> skipWhile p) B.empty err ok + (_, b2) -> ok b2 () + +-- | Skip all the remaining bytes from the current position in the stream +skipAll :: Parser () +skipAll = Parser $ \buf err ok -> runParser flushAll buf err ok diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/socks-0.5.4/Network/Socks5/Wire.hs new/socks-0.5.5/Network/Socks5/Wire.hs --- old/socks-0.5.4/Network/Socks5/Wire.hs 2013-10-25 10:00:53.000000000 +0200 +++ new/socks-0.5.5/Network/Socks5/Wire.hs 2016-05-05 07:30:40.000000000 +0200 @@ -20,6 +20,7 @@ import Network.Socket (PortNumber) import Network.Socks5.Types +import Network.Socks5.Parse as P (anyByte, take) -- | Initial message sent by client with the list of authentification methods supported data SocksHello = SocksHello { getSocksHelloMethods :: [SocksMethod] } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/socks-0.5.4/Network/Socks5.hs new/socks-0.5.5/Network/Socks5.hs --- old/socks-0.5.4/Network/Socks5.hs 2013-10-25 10:00:53.000000000 +0200 +++ new/socks-0.5.5/Network/Socks5.hs 2016-05-05 07:30:40.000000000 +0200 @@ -35,6 +35,7 @@ -- * Variants , socksConnectAddr , socksConnectName + , socksConnectTo' , socksConnectTo , socksConnectWith ) where @@ -119,6 +120,13 @@ return sock -- | similar to Network connectTo but use a socks proxy with default socks configuration. +socksConnectTo' :: String -> PortID -> String -> PortID -> IO Socket +socksConnectTo' sockshost socksport desthost destport = do + sport <- resolvePortID socksport + let socksConf = defaultSocksConf sockshost sport + socksConnectWith socksConf desthost destport + +-- | similar to Network connectTo but use a socks proxy with default socks configuration. socksConnectTo :: String -> PortID -> String -> PortID -> IO Handle socksConnectTo sockshost socksport desthost destport = do sport <- resolvePortID socksport diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/socks-0.5.4/socks.cabal new/socks-0.5.5/socks.cabal --- old/socks-0.5.4/socks.cabal 2013-10-25 10:00:53.000000000 +0200 +++ new/socks-0.5.5/socks.cabal 2016-05-05 07:30:40.000000000 +0200 @@ -1,5 +1,5 @@ Name: socks -Version: 0.5.4 +Version: 0.5.5 Description: Socks proxy (version 5) implementation. License: BSD3 License-file: LICENSE @@ -12,7 +12,7 @@ stability: experimental Cabal-Version: >=1.6 Homepage: http://github.com/vincenthz/hs-socks -data-files: README.md, Example.hs +extra-doc-files: README.md, Example.hs Library Build-Depends: base >= 3 && < 5 @@ -25,6 +25,7 @@ Other-modules: Network.Socks5.Wire Network.Socks5.Conf Network.Socks5.Command + Network.Socks5.Parse ghc-options: -Wall -fno-warn-missing-signatures -fwarn-tabs source-repository head
