packages feed

socks 0.2.0 → 0.3.0

raw patch · 2 files changed

+23/−2 lines, 2 files

Files

Network/Socks5.hs view
@@ -8,9 +8,12 @@ -- Portability : unknown -- module Network.Socks5-	( socksConnectAddr+	( SocksConf(..)+	, defaultSocksConf+	, socksConnectAddr 	, socksConnectName 	, socksConnectTo+	, socksConnectWith 	) where  import Control.Monad@@ -22,6 +25,19 @@ import Network import System.IO +-- | SOCKS configuration structure.+-- this structure will be extended in future to support authentification.+-- use defaultSocksConf to create new record.+data SocksConf = SocksConf+	{ socksHost    :: String -- ^ SOCKS host.+	, socksPort    :: PortNumber -- ^ SOCKS port.+	, socksVersion :: Int        -- ^ SOCKS version to use, only 5 supported for now.+	}++-- | defaultSocksConf create a new record, making sure+-- API remains compatible when the record is extended.+defaultSocksConf host port = SocksConf host port 5+ withSocks sock sockaddr f = do 	connect sock sockaddr 	r <- socks5Establish sock [SocksMethodNone]@@ -66,3 +82,8 @@ 		resolvePortID (Service serv) = getServicePortNumber serv 		resolvePortID (PortNumber n) = return n 		resolvePortID _              = error "unsupported unix PortID"++-- | like socksConnectTo but specify the socks configuration directly.+socksConnectWith :: SocksConf -> String -> PortID -> IO Handle+socksConnectWith socksConf =+	socksConnectTo (socksHost socksConf) (PortNumber $ socksPort socksConf)
socks.cabal view
@@ -1,5 +1,5 @@ Name:                socks-Version:             0.2.0+Version:             0.3.0 Description:         Socks proxy (version 5) implementation. License:             BSD3 License-file:        LICENSE