hookup 0.1.0.0 → 0.1.1.0
raw patch · 4 files changed
+53/−17 lines, 4 filesdep −template-haskellPVP ok
version bump matches the API change (PVP)
Dependencies removed: template-haskell
API changes (from Hackage documentation)
Files
- ChangeLog.md +8/−1
- hookup.cabal +11/−4
- src/Hookup.hs +30/−12
- src/Hookup/OpenSSL.hsc +4/−0
ChangeLog.md view
@@ -1,5 +1,12 @@ # Revision history for hookup -## 0.1.0.0 -- YYYY-mm-dd+## 0.1.1.0 -- 2017-05-13++* Better error message for old openssl version+* Nicer displayedExceptions+* Dropped unused template-haskell dependency+* More haddock comments++## 0.1.0.0 -- 2016-10-05 * First version. Released on an unsuspecting world.
hookup.cabal view
@@ -1,5 +1,5 @@ name: hookup-version: 0.1.0.0+version: 0.1.1.0 synopsis: Abstraction over creating network connections with SOCKS5 and TLS description: This package provides an abstraction for communicating with line-oriented network services while abstracting over the use of SOCKS5 and TLS (via OpenSSL)@@ -12,18 +12,25 @@ category: Network build-type: Simple extra-source-files: ChangeLog.md+homepage: https://github.com/glguy/irc-core+bug-reports: https://github.com/glguy/irc-core/issues+tested-with: GHC==8.0.2 cabal-version: >=1.10 +source-repository head+ type: git+ location: git://github.com/glguy/irc-core.git+ branch: v2+ library exposed-modules: Hookup other-modules: Hookup.OpenSSL extra-libraries: ssl- build-depends: base >=4.9 && <4.10,+ build-depends: base >=4.9 && <4.11, socks >=0.5 && <0.6, network >=2.6 && <2.7, bytestring >=0.10 && <0.11, HsOpenSSL >=0.11.2.3 && <0.12,- HsOpenSSL-x509-system >=0.1 && <0.2,- template-haskell >=2.11 && <2.12+ HsOpenSSL-x509-system >=0.1 && <0.2 hs-source-dirs: src default-language: Haskell2010
src/Hookup.hs view
@@ -32,6 +32,7 @@ import Data.ByteString (ByteString) import qualified Data.ByteString as B import Data.Foldable+import Data.List (intercalate) import Network (PortID(..)) import Network.Socket (Socket, AddrInfo, PortNumber, HostName) import qualified Network.Socket as Socket@@ -63,13 +64,14 @@ } --- | TLS connection parameters+-- | TLS connection parameters. These parameters are passed to+-- OpenSSL when making a secure connection. data TlsParams = TlsParams- { tpClientCertificate :: Maybe FilePath- , tpClientPrivateKey :: Maybe FilePath- , tpServerCertificate :: Maybe FilePath- , tpCipherSuite :: String- , tpInsecure :: Bool+ { tpClientCertificate :: Maybe FilePath -- ^ Path to client certificate+ , tpClientPrivateKey :: Maybe FilePath -- ^ Path to client private key+ , tpServerCertificate :: Maybe FilePath -- ^ Path to CA certificate bundle+ , tpCipherSuite :: String -- ^ OpenSSL cipher suite name (e.g. "HIGH")+ , tpInsecure :: Bool -- ^ Disables certificate checking } @@ -85,7 +87,15 @@ | LineTruncated deriving Show -instance Exception ConnectionFailure+-- | 'displayException' implemented for prettier messages+instance Exception ConnectionFailure where+ displayException LineTruncated = "connection closed while reading line"+ displayException LineTooLong = "line length exceeded maximum"+ displayException (ConnectionFailure xs) =+ "connection attempts failed due to: " +++ intercalate ", " (map displayException xs)+ displayException (HostnameResolutionFailure x) =+ "hostname resolution failed: " ++ displayException x ------------------------------------------------------------------------ -- Opening sockets@@ -156,8 +166,10 @@ closeNetworkHandle :: NetworkHandle -> IO ()-closeNetworkHandle (SSL s) = SSL.shutdown s SSL.Unidirectional closeNetworkHandle (Socket s) = Socket.close s+closeNetworkHandle (SSL s) =+ do SSL.shutdown s SSL.Unidirectional+ traverse_ Socket.close (SSL.sslSocket s) networkSend :: NetworkHandle -> ByteString -> IO () networkSend (Socket s) = SocketB.sendAll s@@ -194,8 +206,15 @@ -- | Receive a line from the network connection. Both--- @"\r\n"@ and @"\n"@ are recognized.+-- @"\\r\\n"@ and @"\\n"@ are recognized. --+-- Returning 'Nothing' means that the peer has closed its half of+-- the connection.+--+-- Unterminated lines will raise a 'LineTruncated' exception. This+-- can happen if the peer transmits some data and closes its end+-- without transmitting a line terminator.+-- -- Throws: 'ConnectionAbruptlyTerminated', 'ConnectionFailure', 'IOError' recvLine :: Connection -> Int -> IO (Maybe ByteString) recvLine (Connection buf h) n =@@ -217,15 +236,14 @@ else go (bsn + B.length more) more (bs:bss) --- | Remove the trailing @'\r'@ if one is found.+-- | Remove the trailing @'\\r'@ if one is found. cleanEnd :: ByteString -> ByteString cleanEnd bs | B.null bs || B.last bs /= 13 = bs | otherwise = B.init bs --- | Send bytes on the network connection. Ensures that the whole message--- is sent.+-- | Send bytes on the network connection. -- -- Throws: 'IOError', 'ProtocolError' send :: Connection -> ByteString -> IO ()
src/Hookup/OpenSSL.hsc view
@@ -10,6 +10,10 @@ #include "openssl/x509_vfy.h" #include "openssl/x509v3.h" +#ifndef X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS+#error "OpenSSL 1.0.2 or later is required. This version was released in Jan 2015 and adds hostname verification"+#endif+ module Hookup.OpenSSL (installVerification) where import Control.Monad (unless)