-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Socks proxy (version 5) implementation.
--   
--   Socks proxy (version 5) implementation.
@package socks
@version 0.5.5


module Network.Socks5.Types

-- | Socks Version
data SocksVersion
SocksVer5 :: SocksVersion

-- | Command that can be send and receive on the SOCKS protocol
data SocksCommand
SocksCommandConnect :: SocksCommand
SocksCommandBind :: SocksCommand
SocksCommandUdpAssociate :: SocksCommand
SocksCommandOther :: !Word8 -> SocksCommand

-- | Authentication methods available on the SOCKS protocol.
--   
--   Only SocksMethodNone is effectively implemented, but other value are
--   enumerated for completeness.
data SocksMethod
SocksMethodNone :: SocksMethod
SocksMethodGSSAPI :: SocksMethod
SocksMethodUsernamePassword :: SocksMethod
SocksMethodOther :: !Word8 -> SocksMethod
SocksMethodNotAcceptable :: SocksMethod

-- | A Host address on the SOCKS protocol.
data SocksHostAddress
SocksAddrIPV4 :: !HostAddress -> SocksHostAddress
SocksAddrDomainName :: !ByteString -> SocksHostAddress
SocksAddrIPV6 :: !HostAddress6 -> SocksHostAddress

-- | Describe a Socket address on the SOCKS protocol
data SocksAddress
SocksAddress :: !SocksHostAddress -> !PortNumber -> SocksAddress

-- | Type of reply on the SOCKS protocol
data SocksReply
SocksReplySuccess :: SocksReply
SocksReplyError :: SocksError -> SocksReply

-- | Exception returned when using a SOCKS version that is not supported.
--   
--   This package only implement version 5.
data SocksVersionNotSupported
SocksVersionNotSupported :: SocksVersionNotSupported

-- | SOCKS error that can be received or sent
data SocksError
SocksErrorGeneralServerFailure :: SocksError
SocksErrorConnectionNotAllowedByRule :: SocksError
SocksErrorNetworkUnreachable :: SocksError
SocksErrorHostUnreachable :: SocksError
SocksErrorConnectionRefused :: SocksError
SocksErrorTTLExpired :: SocksError
SocksErrorCommandNotSupported :: SocksError
SocksErrorAddrTypeNotSupported :: SocksError
SocksErrorOther :: Word8 -> SocksError
instance Data.Data.Data Network.Socks5.Types.SocksVersionNotSupported
instance GHC.Show.Show Network.Socks5.Types.SocksVersionNotSupported
instance Data.Data.Data Network.Socks5.Types.SocksReply
instance GHC.Classes.Ord Network.Socks5.Types.SocksReply
instance GHC.Classes.Eq Network.Socks5.Types.SocksReply
instance GHC.Show.Show Network.Socks5.Types.SocksReply
instance Data.Data.Data Network.Socks5.Types.SocksError
instance GHC.Classes.Ord Network.Socks5.Types.SocksError
instance GHC.Classes.Eq Network.Socks5.Types.SocksError
instance GHC.Show.Show Network.Socks5.Types.SocksError
instance GHC.Classes.Ord Network.Socks5.Types.SocksAddress
instance GHC.Classes.Eq Network.Socks5.Types.SocksAddress
instance GHC.Show.Show Network.Socks5.Types.SocksAddress
instance GHC.Classes.Ord Network.Socks5.Types.SocksHostAddress
instance GHC.Classes.Eq Network.Socks5.Types.SocksHostAddress
instance GHC.Classes.Ord Network.Socks5.Types.SocksMethod
instance GHC.Classes.Eq Network.Socks5.Types.SocksMethod
instance GHC.Show.Show Network.Socks5.Types.SocksMethod
instance GHC.Classes.Ord Network.Socks5.Types.SocksCommand
instance GHC.Classes.Eq Network.Socks5.Types.SocksCommand
instance GHC.Show.Show Network.Socks5.Types.SocksCommand
instance GHC.Classes.Ord Network.Socks5.Types.SocksVersion
instance GHC.Classes.Eq Network.Socks5.Types.SocksVersion
instance GHC.Show.Show Network.Socks5.Types.SocksVersion
instance GHC.Show.Show Network.Socks5.Types.SocksHostAddress
instance GHC.Exception.Exception Network.Socks5.Types.SocksError
instance GHC.Exception.Exception Network.Socks5.Types.SocksVersionNotSupported
instance GHC.Enum.Enum Network.Socks5.Types.SocksCommand
instance GHC.Enum.Enum Network.Socks5.Types.SocksMethod
instance GHC.Enum.Enum Network.Socks5.Types.SocksError
instance GHC.Enum.Enum Network.Socks5.Types.SocksReply

module Network.Socks5.Lowlevel
resolveToSockAddr :: SocksAddress -> IO SockAddr
socksListen :: Socket -> IO SocksRequest

-- | Initial message sent by client with the list of authentification
--   methods supported
data SocksHello
SocksHello :: [SocksMethod] -> SocksHello
[getSocksHelloMethods] :: SocksHello -> [SocksMethod]

-- | Initial message send by server in return from Hello, with the server
--   chosen method of authentication
data SocksHelloResponse
SocksHelloResponse :: SocksMethod -> SocksHelloResponse
[getSocksHelloResponseMethod] :: SocksHelloResponse -> SocksMethod

-- | Define a SOCKS requests
data SocksRequest
SocksRequest :: SocksCommand -> SocksHostAddress -> PortNumber -> SocksRequest
[requestCommand] :: SocksRequest -> SocksCommand
[requestDstAddr] :: SocksRequest -> SocksHostAddress
[requestDstPort] :: SocksRequest -> PortNumber

-- | Define a SOCKS response
data SocksResponse
SocksResponse :: SocksReply -> SocksHostAddress -> PortNumber -> SocksResponse
[responseReply] :: SocksResponse -> SocksReply
[responseBindAddr] :: SocksResponse -> SocksHostAddress
[responseBindPort] :: SocksResponse -> PortNumber
establish :: Socket -> [SocksMethod] -> IO SocksMethod
newtype Connect
Connect :: SocksAddress -> Connect
class Command a
toRequest :: Command a => a -> SocksRequest
fromRequest :: Command a => SocksRequest -> Maybe a
connectIPV4 :: Socket -> HostAddress -> PortNumber -> IO (HostAddress, PortNumber)
connectIPV6 :: Socket -> HostAddress6 -> PortNumber -> IO (HostAddress6, PortNumber)
connectDomainName :: Socket -> String -> PortNumber -> IO (SocksHostAddress, PortNumber)
rpc :: Command a => Socket -> a -> IO (Either SocksError (SocksHostAddress, PortNumber))
rpc_ :: Command a => Socket -> a -> IO (SocksHostAddress, PortNumber)
sendSerialized :: Serialize a => Socket -> a -> IO ()
waitSerialized :: Serialize a => Socket -> IO a


-- | This is an implementation of SOCKS5 as defined in RFC 1928
--   
--   In Wikipedia's words:
--   
--   SOCKet Secure (SOCKS) is an Internet protocol that routes network
--   packets between a client and server through a proxy server. SOCKS5
--   additionally provides authentication so only authorized users may
--   access a server. Practically, a SOCKS server will proxy TCP
--   connections to an arbitrary IP address as well as providing a means
--   for UDP packets to be forwarded.
--   
--   BIND and UDP ASSOCIATE messages are not implemented. However main
--   usage of SOCKS is covered in this implementation.
module Network.Socks5

-- | Describe a Socket address on the SOCKS protocol
data SocksAddress
SocksAddress :: !SocksHostAddress -> !PortNumber -> SocksAddress

-- | A Host address on the SOCKS protocol.
data SocksHostAddress
SocksAddrIPV4 :: !HostAddress -> SocksHostAddress
SocksAddrDomainName :: !ByteString -> SocksHostAddress
SocksAddrIPV6 :: !HostAddress6 -> SocksHostAddress

-- | Type of reply on the SOCKS protocol
data SocksReply
SocksReplySuccess :: SocksReply
SocksReplyError :: SocksError -> SocksReply

-- | SOCKS error that can be received or sent
data SocksError
SocksErrorGeneralServerFailure :: SocksError
SocksErrorConnectionNotAllowedByRule :: SocksError
SocksErrorNetworkUnreachable :: SocksError
SocksErrorHostUnreachable :: SocksError
SocksErrorConnectionRefused :: SocksError
SocksErrorTTLExpired :: SocksError
SocksErrorCommandNotSupported :: SocksError
SocksErrorAddrTypeNotSupported :: SocksError
SocksErrorOther :: Word8 -> SocksError

-- | SOCKS configuration structure. this structure will be extended in
--   future to support authentification. use defaultSocksConf to create new
--   record.
data SocksConf
SocksConf :: SocksAddress -> SocksVersion -> SocksConf

-- | SOCKS Address
[socksServer] :: SocksConf -> SocksAddress

-- | SOCKS version to use
[socksVersion] :: SocksConf -> SocksVersion

-- | SOCKS Host
socksHost :: SocksConf -> SocksHostAddress

-- | SOCKS Port
socksPort :: SocksConf -> PortNumber

-- | defaultSocksConf create a new record, making sure API remains
--   compatible when the record is extended.
defaultSocksConf :: String -> PortNumber -> SocksConf

-- | same as defaultSocksConf except the server address is determined from
--   a <a>SockAddr</a>
--   
--   A unix SockAddr will raises an error. Only Inet and Inet6 types
--   supported
defaultSocksConfFromSockAddr :: SockAddr -> SocksConf

-- | connect a user specified new socket to the socks server, and connect
--   the stream on the server side to the <tt>SockAddress</tt> specified.
--   
--   
--   |socket|-----sockServer-----&gt;|server|----destAddr-----&gt;|destination|
socksConnectWithSocket :: Socket -> SocksConf -> SocksAddress -> IO (SocksHostAddress, PortNumber)

-- | connect a new socket to a socks server and connect the stream on the
--   server side to the <a>SocksAddress</a> specified.
socksConnect :: SocksConf -> SocksAddress -> IO (Socket, (SocksHostAddress, PortNumber))

-- | connect a new socket to the socks server, and connect the stream on
--   the server side to the sockaddr specified. the sockaddr need to be
--   SockAddrInet or SockAddrInet6.
--   
--   a unix sockaddr will raises an exception.
--   
--   
--   |socket|-----sockServer-----&gt;|server|----destAddr-----&gt;|destination|

-- | <i>Deprecated: use socksConnectWithSocket</i>
socksConnectAddr :: Socket -> SockAddr -> SockAddr -> IO ()

-- | connect a new socket to the socks server, and connect the stream to a
--   FQDN resolved on the server side.
socksConnectName :: Socket -> SockAddr -> String -> PortNumber -> IO ()

-- | similar to Network connectTo but use a socks proxy with default socks
--   configuration.
socksConnectTo' :: String -> PortID -> String -> PortID -> IO Socket

-- | similar to Network connectTo but use a socks proxy with default socks
--   configuration.
socksConnectTo :: String -> PortID -> String -> PortID -> IO Handle

-- | create a new socket and connect in to a destination through the
--   specified SOCKS configuration.
socksConnectWith :: SocksConf -> String -> PortID -> IO Socket
