    {-# LANGUAGE DeriveDataTypeable #-}
    -- |
    -- Module      : Network.Socks5.Types
    -- License     : BSD-style
    -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
    -- Stability   : experimental
    -- Portability : unknown
    module Network.Socks5.Types
        ( SocksVersion(..)
        , SocksCommand(..)
        , SocksMethod(..)
        , SocksHostAddress(..)
        , SocksAddress(..)
        , SocksReply(..)
        , SocksVersionNotSupported(..)
        , SocksError(..)
        ) where

    import qualified Basement.String as UTF8
    import           Basement.Compat.IsList
    import Data.ByteString (ByteString)
    import Data.Word
    import Data.Data
    import Network.Socket (HostAddress, HostAddress6, PortNumber)
    import Control.Exception
    import qualified Data.ByteString as B
    import Numeric (showHex)
    import Data.List (intersperse)

    -- | Socks Version
    data SocksVersion = SocksVer5
                      deriving (Int -> SocksVersion -> ShowS
    [SocksVersion] -> ShowS
    SocksVersion -> String
    (Int -> SocksVersion -> ShowS)
    -> (SocksVersion -> String)
    -> ([SocksVersion] -> ShowS)
    -> Show SocksVersion
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [SocksVersion] -> ShowS
    $cshowList :: [SocksVersion] -> ShowS
    show :: SocksVersion -> String
    $cshow :: SocksVersion -> String
    showsPrec :: Int -> SocksVersion -> ShowS
    $cshowsPrec :: Int -> SocksVersion -> ShowS
    Show,SocksVersion -> SocksVersion -> Bool
    (SocksVersion -> SocksVersion -> Bool)
    -> (SocksVersion -> SocksVersion -> Bool) -> Eq SocksVersion
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: SocksVersion -> SocksVersion -> Bool
    $c/= :: SocksVersion -> SocksVersion -> Bool
    == :: SocksVersion -> SocksVersion -> Bool
    $c== :: SocksVersion -> SocksVersion -> Bool
    Eq,Eq SocksVersion
    Eq SocksVersion =>
    (SocksVersion -> SocksVersion -> Ordering)
    -> (SocksVersion -> SocksVersion -> Bool)
    -> (SocksVersion -> SocksVersion -> Bool)
    -> (SocksVersion -> SocksVersion -> Bool)
    -> (SocksVersion -> SocksVersion -> Bool)
    -> (SocksVersion -> SocksVersion -> SocksVersion)
    -> (SocksVersion -> SocksVersion -> SocksVersion)
    -> Ord SocksVersion
    SocksVersion -> SocksVersion -> Bool
    SocksVersion -> SocksVersion -> Ordering
    SocksVersion -> SocksVersion -> SocksVersion
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    min :: SocksVersion -> SocksVersion -> SocksVersion
    $cmin :: SocksVersion -> SocksVersion -> SocksVersion
    max :: SocksVersion -> SocksVersion -> SocksVersion
    $cmax :: SocksVersion -> SocksVersion -> SocksVersion
    >= :: SocksVersion -> SocksVersion -> Bool
    $c>= :: SocksVersion -> SocksVersion -> Bool
    > :: SocksVersion -> SocksVersion -> Bool
    $c> :: SocksVersion -> SocksVersion -> Bool
    <= :: SocksVersion -> SocksVersion -> Bool
    $c<= :: SocksVersion -> SocksVersion -> Bool
    < :: SocksVersion -> SocksVersion -> Bool
    $c< :: SocksVersion -> SocksVersion -> Bool
    compare :: SocksVersion -> SocksVersion -> Ordering
    $ccompare :: SocksVersion -> SocksVersion -> Ordering
    $cp1Ord :: Eq SocksVersion
    Ord)

    -- | Command that can be send and receive on the SOCKS protocol
    data SocksCommand =
          SocksCommandConnect
        | SocksCommandBind
        | SocksCommandUdpAssociate
        | SocksCommandOther !Word8
        deriving (Int -> SocksCommand -> ShowS
    [SocksCommand] -> ShowS
    SocksCommand -> String
    (Int -> SocksCommand -> ShowS)
    -> (SocksCommand -> String)
    -> ([SocksCommand] -> ShowS)
    -> Show SocksCommand
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [SocksCommand] -> ShowS
    $cshowList :: [SocksCommand] -> ShowS
    show :: SocksCommand -> String
    $cshow :: SocksCommand -> String
    showsPrec :: Int -> SocksCommand -> ShowS
    $cshowsPrec :: Int -> SocksCommand -> ShowS
    Show,SocksCommand -> SocksCommand -> Bool
    (SocksCommand -> SocksCommand -> Bool)
    -> (SocksCommand -> SocksCommand -> Bool) -> Eq SocksCommand
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: SocksCommand -> SocksCommand -> Bool
    $c/= :: SocksCommand -> SocksCommand -> Bool
    == :: SocksCommand -> SocksCommand -> Bool
    $c== :: SocksCommand -> SocksCommand -> Bool
    Eq,Eq SocksCommand
    Eq SocksCommand =>
    (SocksCommand -> SocksCommand -> Ordering)
    -> (SocksCommand -> SocksCommand -> Bool)
    -> (SocksCommand -> SocksCommand -> Bool)
    -> (SocksCommand -> SocksCommand -> Bool)
    -> (SocksCommand -> SocksCommand -> Bool)
    -> (SocksCommand -> SocksCommand -> SocksCommand)
    -> (SocksCommand -> SocksCommand -> SocksCommand)
    -> Ord SocksCommand
    SocksCommand -> SocksCommand -> Bool
    SocksCommand -> SocksCommand -> Ordering
    SocksCommand -> SocksCommand -> SocksCommand
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    min :: SocksCommand -> SocksCommand -> SocksCommand
    $cmin :: SocksCommand -> SocksCommand -> SocksCommand
    max :: SocksCommand -> SocksCommand -> SocksCommand
    $cmax :: SocksCommand -> SocksCommand -> SocksCommand
    >= :: SocksCommand -> SocksCommand -> Bool
    $c>= :: SocksCommand -> SocksCommand -> Bool
    > :: SocksCommand -> SocksCommand -> Bool
    $c> :: SocksCommand -> SocksCommand -> Bool
    <= :: SocksCommand -> SocksCommand -> Bool
    $c<= :: SocksCommand -> SocksCommand -> Bool
    < :: SocksCommand -> SocksCommand -> Bool
    $c< :: SocksCommand -> SocksCommand -> Bool
    compare :: SocksCommand -> SocksCommand -> Ordering
    $ccompare :: SocksCommand -> SocksCommand -> Ordering
    $cp1Ord :: Eq SocksCommand
    Ord)

    -- | Authentication methods available on the SOCKS protocol.
    --
    -- Only SocksMethodNone is effectively implemented, but
    -- other value are enumerated for completeness.
    data SocksMethod =
          SocksMethodNone
        | SocksMethodGSSAPI
        | SocksMethodUsernamePassword
        | SocksMethodOther !Word8
        | SocksMethodNotAcceptable
        deriving (Int -> SocksMethod -> ShowS
    [SocksMethod] -> ShowS
    SocksMethod -> String
    (Int -> SocksMethod -> ShowS)
    -> (SocksMethod -> String)
    -> ([SocksMethod] -> ShowS)
    -> Show SocksMethod
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [SocksMethod] -> ShowS
    $cshowList :: [SocksMethod] -> ShowS
    show :: SocksMethod -> String
    $cshow :: SocksMethod -> String
    showsPrec :: Int -> SocksMethod -> ShowS
    $cshowsPrec :: Int -> SocksMethod -> ShowS
    Show,SocksMethod -> SocksMethod -> Bool
    (SocksMethod -> SocksMethod -> Bool)
    -> (SocksMethod -> SocksMethod -> Bool) -> Eq SocksMethod
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: SocksMethod -> SocksMethod -> Bool
    $c/= :: SocksMethod -> SocksMethod -> Bool
    == :: SocksMethod -> SocksMethod -> Bool
    $c== :: SocksMethod -> SocksMethod -> Bool
    Eq,Eq SocksMethod
    Eq SocksMethod =>
    (SocksMethod -> SocksMethod -> Ordering)
    -> (SocksMethod -> SocksMethod -> Bool)
    -> (SocksMethod -> SocksMethod -> Bool)
    -> (SocksMethod -> SocksMethod -> Bool)
    -> (SocksMethod -> SocksMethod -> Bool)
    -> (SocksMethod -> SocksMethod -> SocksMethod)
    -> (SocksMethod -> SocksMethod -> SocksMethod)
    -> Ord SocksMethod
    SocksMethod -> SocksMethod -> Bool
    SocksMethod -> SocksMethod -> Ordering
    SocksMethod -> SocksMethod -> SocksMethod
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    min :: SocksMethod -> SocksMethod -> SocksMethod
    $cmin :: SocksMethod -> SocksMethod -> SocksMethod
    max :: SocksMethod -> SocksMethod -> SocksMethod
    $cmax :: SocksMethod -> SocksMethod -> SocksMethod
    >= :: SocksMethod -> SocksMethod -> Bool
    $c>= :: SocksMethod -> SocksMethod -> Bool
    > :: SocksMethod -> SocksMethod -> Bool
    $c> :: SocksMethod -> SocksMethod -> Bool
    <= :: SocksMethod -> SocksMethod -> Bool
    $c<= :: SocksMethod -> SocksMethod -> Bool
    < :: SocksMethod -> SocksMethod -> Bool
    $c< :: SocksMethod -> SocksMethod -> Bool
    compare :: SocksMethod -> SocksMethod -> Ordering
    $ccompare :: SocksMethod -> SocksMethod -> Ordering
    $cp1Ord :: Eq SocksMethod
    Ord)

    -- | A Host address on the SOCKS protocol.
    data SocksHostAddress =
          SocksAddrIPV4 !HostAddress
        | SocksAddrDomainName !FQDN
        | SocksAddrIPV6 !HostAddress6
        deriving (SocksHostAddress -> SocksHostAddress -> Bool
    (SocksHostAddress -> SocksHostAddress -> Bool)
    -> (SocksHostAddress -> SocksHostAddress -> Bool)
    -> Eq SocksHostAddress
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: SocksHostAddress -> SocksHostAddress -> Bool
    $c/= :: SocksHostAddress -> SocksHostAddress -> Bool
    == :: SocksHostAddress -> SocksHostAddress -> Bool
    $c== :: SocksHostAddress -> SocksHostAddress -> Bool
    Eq,Eq SocksHostAddress
    Eq SocksHostAddress =>
    (SocksHostAddress -> SocksHostAddress -> Ordering)
    -> (SocksHostAddress -> SocksHostAddress -> Bool)
    -> (SocksHostAddress -> SocksHostAddress -> Bool)
    -> (SocksHostAddress -> SocksHostAddress -> Bool)
    -> (SocksHostAddress -> SocksHostAddress -> Bool)
    -> (SocksHostAddress -> SocksHostAddress -> SocksHostAddress)
    -> (SocksHostAddress -> SocksHostAddress -> SocksHostAddress)
    -> Ord SocksHostAddress
    SocksHostAddress -> SocksHostAddress -> Bool
    SocksHostAddress -> SocksHostAddress -> Ordering
    SocksHostAddress -> SocksHostAddress -> SocksHostAddress
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    min :: SocksHostAddress -> SocksHostAddress -> SocksHostAddress
    $cmin :: SocksHostAddress -> SocksHostAddress -> SocksHostAddress
    max :: SocksHostAddress -> SocksHostAddress -> SocksHostAddress
    $cmax :: SocksHostAddress -> SocksHostAddress -> SocksHostAddress
    >= :: SocksHostAddress -> SocksHostAddress -> Bool
    $c>= :: SocksHostAddress -> SocksHostAddress -> Bool
    > :: SocksHostAddress -> SocksHostAddress -> Bool
    $c> :: SocksHostAddress -> SocksHostAddress -> Bool
    <= :: SocksHostAddress -> SocksHostAddress -> Bool
    $c<= :: SocksHostAddress -> SocksHostAddress -> Bool
    < :: SocksHostAddress -> SocksHostAddress -> Bool
    $c< :: SocksHostAddress -> SocksHostAddress -> Bool
    compare :: SocksHostAddress -> SocksHostAddress -> Ordering
    $ccompare :: SocksHostAddress -> SocksHostAddress -> Ordering
    $cp1Ord :: Eq SocksHostAddress
    Ord)

    type FQDN = ByteString

    instance Show SocksHostAddress where
        show :: SocksHostAddress -> String
    show (SocksAddrIPV4 ha :: HostAddress
    ha)       = "SocksAddrIPV4(" String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ HostAddress -> String
    showHostAddress HostAddress
    ha String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ ")"
        show (SocksAddrIPV6 ha6 :: HostAddress6
    ha6)      = "SocksAddrIPV6(" String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ HostAddress6 -> String
    showHostAddress6 HostAddress6
    ha6 String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ ")"
        show (SocksAddrDomainName dn :: FQDN
    dn) = "SocksAddrDomainName(" String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ FQDN -> String
    showFQDN FQDN
    dn String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ ")"

    -- | Converts a FQDN to a String
    showFQDN :: FQDN -> String
    showFQDN :: FQDN -> String
    showFQDN bs :: FQDN
    bs = String -> String
    forall l. IsList l => l -> [Item l]
    toList (String -> String) -> String -> String
    forall a b. (a -> b) -> a -> b
    $ (String, UArray Word8) -> String
    forall a b. (a, b) -> a
    fst ((String, UArray Word8) -> String)
    -> (String, UArray Word8) -> String
    forall a b. (a -> b) -> a -> b
    $ UArray Word8 -> (String, UArray Word8)
    UTF8.fromBytesLenient (UArray Word8 -> (String, UArray Word8))
    -> UArray Word8 -> (String, UArray Word8)
    forall a b. (a -> b) -> a -> b
    $ [Item (UArray Word8)] -> UArray Word8
    forall l. IsList l => [Item l] -> l
    fromList ([Item (UArray Word8)] -> UArray Word8)
    -> [Item (UArray Word8)] -> UArray Word8
    forall a b. (a -> b) -> a -> b
    $ FQDN -> [Word8]
    B.unpack FQDN
    bs

    -- | Converts a HostAddress to a String in dot-decimal notation
    showHostAddress :: HostAddress -> String
    showHostAddress :: HostAddress -> String
    showHostAddress num :: HostAddress
    num = [String] -> String
    forall (t :: * -> *) a. Foldable t => t [a] -> [a]
    concat [HostAddress -> String
    forall a. Show a => a -> String
    show HostAddress
    q1, ".", HostAddress -> String
    forall a. Show a => a -> String
    show HostAddress
    q2, ".", HostAddress -> String
    forall a. Show a => a -> String
    show HostAddress
    q3, ".", HostAddress -> String
    forall a. Show a => a -> String
    show HostAddress
    q4]
      where (num' :: HostAddress
    num',q1 :: HostAddress
    q1)   = HostAddress
    num HostAddress -> HostAddress -> (HostAddress, HostAddress)
    forall a. Integral a => a -> a -> (a, a)
    `quotRem` 256
            (num'' :: HostAddress
    num'',q2 :: HostAddress
    q2)  = HostAddress
    num' HostAddress -> HostAddress -> (HostAddress, HostAddress)
    forall a. Integral a => a -> a -> (a, a)
    `quotRem` 256
            (num''' :: HostAddress
    num''',q3 :: HostAddress
    q3) = HostAddress
    num'' HostAddress -> HostAddress -> (HostAddress, HostAddress)
    forall a. Integral a => a -> a -> (a, a)
    `quotRem` 256
            (_,q4 :: HostAddress
    q4)      = HostAddress
    num''' HostAddress -> HostAddress -> (HostAddress, HostAddress)
    forall a. Integral a => a -> a -> (a, a)
    `quotRem` 256

    -- | Converts a IPv6 HostAddress6 to standard hex notation
    showHostAddress6 :: HostAddress6 -> String
    showHostAddress6 :: HostAddress6 -> String
    showHostAddress6 (a :: HostAddress
    a,b :: HostAddress
    b,c :: HostAddress
    c,d :: HostAddress
    d) =
        ([String] -> String
    forall (t :: * -> *) a. Foldable t => t [a] -> [a]
    concat ([String] -> String)
    -> ([HostAddress] -> [String]) -> [HostAddress] -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    intersperse ":" ([String] -> [String])
    -> ([HostAddress] -> [String]) -> [HostAddress] -> [String]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (HostAddress -> String) -> [HostAddress] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map ((HostAddress -> ShowS) -> String -> HostAddress -> String
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip HostAddress -> ShowS
    forall a. (Integral a, Show a) => a -> ShowS
    showHex ""))
            [HostAddress
    p1,HostAddress
    p2,HostAddress
    p3,HostAddress
    p4,HostAddress
    p5,HostAddress
    p6,HostAddress
    p7,HostAddress
    p8]
        where (a' :: HostAddress
    a',p2 :: HostAddress
    p2) = HostAddress
    a HostAddress -> HostAddress -> (HostAddress, HostAddress)
    forall a. Integral a => a -> a -> (a, a)
    `quotRem` 65536
              (_,p1 :: HostAddress
    p1)  = HostAddress
    a' HostAddress -> HostAddress -> (HostAddress, HostAddress)
    forall a. Integral a => a -> a -> (a, a)
    `quotRem` 65536
              (b' :: HostAddress
    b',p4 :: HostAddress
    p4) = HostAddress
    b HostAddress -> HostAddress -> (HostAddress, HostAddress)
    forall a. Integral a => a -> a -> (a, a)
    `quotRem` 65536
              (_,p3 :: HostAddress
    p3)  = HostAddress
    b' HostAddress -> HostAddress -> (HostAddress, HostAddress)
    forall a. Integral a => a -> a -> (a, a)
    `quotRem` 65536
              (c' :: HostAddress
    c',p6 :: HostAddress
    p6) = HostAddress
    c HostAddress -> HostAddress -> (HostAddress, HostAddress)
    forall a. Integral a => a -> a -> (a, a)
    `quotRem` 65536
              (_,p5 :: HostAddress
    p5)  = HostAddress
    c' HostAddress -> HostAddress -> (HostAddress, HostAddress)
    forall a. Integral a => a -> a -> (a, a)
    `quotRem` 65536
              (d' :: HostAddress
    d',p8 :: HostAddress
    p8) = HostAddress
    d HostAddress -> HostAddress -> (HostAddress, HostAddress)
    forall a. Integral a => a -> a -> (a, a)
    `quotRem` 65536
              (_,p7 :: HostAddress
    p7)  = HostAddress
    d' HostAddress -> HostAddress -> (HostAddress, HostAddress)
    forall a. Integral a => a -> a -> (a, a)
    `quotRem` 65536

    -- | Describe a Socket address on the SOCKS protocol
    data SocksAddress = SocksAddress !SocksHostAddress !PortNumber
        deriving (Int -> SocksAddress -> ShowS
    [SocksAddress] -> ShowS
    SocksAddress -> String
    (Int -> SocksAddress -> ShowS)
    -> (SocksAddress -> String)
    -> ([SocksAddress] -> ShowS)
    -> Show SocksAddress
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [SocksAddress] -> ShowS
    $cshowList :: [SocksAddress] -> ShowS
    show :: SocksAddress -> String
    $cshow :: SocksAddress -> String
    showsPrec :: Int -> SocksAddress -> ShowS
    $cshowsPrec :: Int -> SocksAddress -> ShowS
    Show,SocksAddress -> SocksAddress -> Bool
    (SocksAddress -> SocksAddress -> Bool)
    -> (SocksAddress -> SocksAddress -> Bool) -> Eq SocksAddress
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: SocksAddress -> SocksAddress -> Bool
    $c/= :: SocksAddress -> SocksAddress -> Bool
    == :: SocksAddress -> SocksAddress -> Bool
    $c== :: SocksAddress -> SocksAddress -> Bool
    Eq,Eq SocksAddress
    Eq SocksAddress =>
    (SocksAddress -> SocksAddress -> Ordering)
    -> (SocksAddress -> SocksAddress -> Bool)
    -> (SocksAddress -> SocksAddress -> Bool)
    -> (SocksAddress -> SocksAddress -> Bool)
    -> (SocksAddress -> SocksAddress -> Bool)
    -> (SocksAddress -> SocksAddress -> SocksAddress)
    -> (SocksAddress -> SocksAddress -> SocksAddress)
    -> Ord SocksAddress
    SocksAddress -> SocksAddress -> Bool
    SocksAddress -> SocksAddress -> Ordering
    SocksAddress -> SocksAddress -> SocksAddress
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    min :: SocksAddress -> SocksAddress -> SocksAddress
    $cmin :: SocksAddress -> SocksAddress -> SocksAddress
    max :: SocksAddress -> SocksAddress -> SocksAddress
    $cmax :: SocksAddress -> SocksAddress -> SocksAddress
    >= :: SocksAddress -> SocksAddress -> Bool
    $c>= :: SocksAddress -> SocksAddress -> Bool
    > :: SocksAddress -> SocksAddress -> Bool
    $c> :: SocksAddress -> SocksAddress -> Bool
    <= :: SocksAddress -> SocksAddress -> Bool
    $c<= :: SocksAddress -> SocksAddress -> Bool
    < :: SocksAddress -> SocksAddress -> Bool
    $c< :: SocksAddress -> SocksAddress -> Bool
    compare :: SocksAddress -> SocksAddress -> Ordering
    $ccompare :: SocksAddress -> SocksAddress -> Ordering
    $cp1Ord :: Eq SocksAddress
    Ord)

    -- | Type of reply on the SOCKS protocol
    data SocksReply =
          SocksReplySuccess
        | SocksReplyError SocksError
        deriving (Int -> SocksReply -> ShowS
    [SocksReply] -> ShowS
    SocksReply -> String
    (Int -> SocksReply -> ShowS)
    -> (SocksReply -> String)
    -> ([SocksReply] -> ShowS)
    -> Show SocksReply
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [SocksReply] -> ShowS
    $cshowList :: [SocksReply] -> ShowS
    show :: SocksReply -> String
    $cshow :: SocksReply -> String
    showsPrec :: Int -> SocksReply -> ShowS
    $cshowsPrec :: Int -> SocksReply -> ShowS
    Show,SocksReply -> SocksReply -> Bool
    (SocksReply -> SocksReply -> Bool)
    -> (SocksReply -> SocksReply -> Bool) -> Eq SocksReply
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: SocksReply -> SocksReply -> Bool
    $c/= :: SocksReply -> SocksReply -> Bool
    == :: SocksReply -> SocksReply -> Bool
    $c== :: SocksReply -> SocksReply -> Bool
    Eq,Eq SocksReply
    Eq SocksReply =>
    (SocksReply -> SocksReply -> Ordering)
    -> (SocksReply -> SocksReply -> Bool)
    -> (SocksReply -> SocksReply -> Bool)
    -> (SocksReply -> SocksReply -> Bool)
    -> (SocksReply -> SocksReply -> Bool)
    -> (SocksReply -> SocksReply -> SocksReply)
    -> (SocksReply -> SocksReply -> SocksReply)
    -> Ord SocksReply
    SocksReply -> SocksReply -> Bool
    SocksReply -> SocksReply -> Ordering
    SocksReply -> SocksReply -> SocksReply
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    min :: SocksReply -> SocksReply -> SocksReply
    $cmin :: SocksReply -> SocksReply -> SocksReply
    max :: SocksReply -> SocksReply -> SocksReply
    $cmax :: SocksReply -> SocksReply -> SocksReply
    >= :: SocksReply -> SocksReply -> Bool
    $c>= :: SocksReply -> SocksReply -> Bool
    > :: SocksReply -> SocksReply -> Bool
    $c> :: SocksReply -> SocksReply -> Bool
    <= :: SocksReply -> SocksReply -> Bool
    $c<= :: SocksReply -> SocksReply -> Bool
    < :: SocksReply -> SocksReply -> Bool
    $c< :: SocksReply -> SocksReply -> Bool
    compare :: SocksReply -> SocksReply -> Ordering
    $ccompare :: SocksReply -> SocksReply -> Ordering
    $cp1Ord :: Eq SocksReply
    Ord,Typeable SocksReply
    DataType
    Constr
    Typeable SocksReply =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> SocksReply -> c SocksReply)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c SocksReply)
    -> (SocksReply -> Constr)
    -> (SocksReply -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c SocksReply))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c SocksReply))
    -> ((forall b. Data b => b -> b) -> SocksReply -> SocksReply)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> SocksReply -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> SocksReply -> r)
    -> (forall u. (forall d. Data d => d -> u) -> SocksReply -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> SocksReply -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> SocksReply -> m SocksReply)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> SocksReply -> m SocksReply)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> SocksReply -> m SocksReply)
    -> Data SocksReply
    SocksReply -> DataType
    SocksReply -> Constr
    (forall b. Data b => b -> b) -> SocksReply -> SocksReply
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> SocksReply -> c SocksReply
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SocksReply
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> SocksReply -> u
    forall u. (forall d. Data d => d -> u) -> SocksReply -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> SocksReply -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> SocksReply -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> SocksReply -> m SocksReply
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SocksReply -> m SocksReply
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SocksReply
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> SocksReply -> c SocksReply
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c SocksReply)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SocksReply)
    $cSocksReplyError :: Constr
    $cSocksReplySuccess :: Constr
    $tSocksReply :: DataType
    gmapMo :: (forall d. Data d => d -> m d) -> SocksReply -> m SocksReply
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SocksReply -> m SocksReply
    gmapMp :: (forall d. Data d => d -> m d) -> SocksReply -> m SocksReply
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SocksReply -> m SocksReply
    gmapM :: (forall d. Data d => d -> m d) -> SocksReply -> m SocksReply
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> SocksReply -> m SocksReply
    gmapQi :: Int -> (forall d. Data d => d -> u) -> SocksReply -> u
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SocksReply -> u
    gmapQ :: (forall d. Data d => d -> u) -> SocksReply -> [u]
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> SocksReply -> [u]
    gmapQr :: (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> SocksReply -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> SocksReply -> r
    gmapQl :: (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> SocksReply -> r
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> SocksReply -> r
    gmapT :: (forall b. Data b => b -> b) -> SocksReply -> SocksReply
    $cgmapT :: (forall b. Data b => b -> b) -> SocksReply -> SocksReply
    dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SocksReply)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SocksReply)
    dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c SocksReply)
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c SocksReply)
    dataTypeOf :: SocksReply -> DataType
    $cdataTypeOf :: SocksReply -> DataType
    toConstr :: SocksReply -> Constr
    $ctoConstr :: SocksReply -> Constr
    gunfold :: (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SocksReply
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SocksReply
    gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> SocksReply -> c SocksReply
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> SocksReply -> c SocksReply
    $cp1Data :: Typeable SocksReply
    Data,Typeable)

    -- | SOCKS error that can be received or sent
    data SocksError =
          SocksErrorGeneralServerFailure
        | SocksErrorConnectionNotAllowedByRule
        | SocksErrorNetworkUnreachable
        | SocksErrorHostUnreachable
        | SocksErrorConnectionRefused
        | SocksErrorTTLExpired
        | SocksErrorCommandNotSupported
        | SocksErrorAddrTypeNotSupported
        | SocksErrorOther Word8
        deriving (Int -> SocksError -> ShowS
    [SocksError] -> ShowS
    SocksError -> String
    (Int -> SocksError -> ShowS)
    -> (SocksError -> String)
    -> ([SocksError] -> ShowS)
    -> Show SocksError
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [SocksError] -> ShowS
    $cshowList :: [SocksError] -> ShowS
    show :: SocksError -> String
    $cshow :: SocksError -> String
    showsPrec :: Int -> SocksError -> ShowS
    $cshowsPrec :: Int -> SocksError -> ShowS
    Show,SocksError -> SocksError -> Bool
    (SocksError -> SocksError -> Bool)
    -> (SocksError -> SocksError -> Bool) -> Eq SocksError
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: SocksError -> SocksError -> Bool
    $c/= :: SocksError -> SocksError -> Bool
    == :: SocksError -> SocksError -> Bool
    $c== :: SocksError -> SocksError -> Bool
    Eq,Eq SocksError
    Eq SocksError =>
    (SocksError -> SocksError -> Ordering)
    -> (SocksError -> SocksError -> Bool)
    -> (SocksError -> SocksError -> Bool)
    -> (SocksError -> SocksError -> Bool)
    -> (SocksError -> SocksError -> Bool)
    -> (SocksError -> SocksError -> SocksError)
    -> (SocksError -> SocksError -> SocksError)
    -> Ord SocksError
    SocksError -> SocksError -> Bool
    SocksError -> SocksError -> Ordering
    SocksError -> SocksError -> SocksError
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    min :: SocksError -> SocksError -> SocksError
    $cmin :: SocksError -> SocksError -> SocksError
    max :: SocksError -> SocksError -> SocksError
    $cmax :: SocksError -> SocksError -> SocksError
    >= :: SocksError -> SocksError -> Bool
    $c>= :: SocksError -> SocksError -> Bool
    > :: SocksError -> SocksError -> Bool
    $c> :: SocksError -> SocksError -> Bool
    <= :: SocksError -> SocksError -> Bool
    $c<= :: SocksError -> SocksError -> Bool
    < :: SocksError -> SocksError -> Bool
    $c< :: SocksError -> SocksError -> Bool
    compare :: SocksError -> SocksError -> Ordering
    $ccompare :: SocksError -> SocksError -> Ordering
    $cp1Ord :: Eq SocksError
    Ord,Typeable SocksError
    DataType
    Constr
    Typeable SocksError =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> SocksError -> c SocksError)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c SocksError)
    -> (SocksError -> Constr)
    -> (SocksError -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c SocksError))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c SocksError))
    -> ((forall b. Data b => b -> b) -> SocksError -> SocksError)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> SocksError -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> SocksError -> r)
    -> (forall u. (forall d. Data d => d -> u) -> SocksError -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> SocksError -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> SocksError -> m SocksError)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> SocksError -> m SocksError)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> SocksError -> m SocksError)
    -> Data SocksError
    SocksError -> DataType
    SocksError -> Constr
    (forall b. Data b => b -> b) -> SocksError -> SocksError
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> SocksError -> c SocksError
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SocksError
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> SocksError -> u
    forall u. (forall d. Data d => d -> u) -> SocksError -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> SocksError -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> SocksError -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> SocksError -> m SocksError
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SocksError -> m SocksError
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SocksError
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> SocksError -> c SocksError
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c SocksError)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SocksError)
    $cSocksErrorOther :: Constr
    $cSocksErrorAddrTypeNotSupported :: Constr
    $cSocksErrorCommandNotSupported :: Constr
    $cSocksErrorTTLExpired :: Constr
    $cSocksErrorConnectionRefused :: Constr
    $cSocksErrorHostUnreachable :: Constr
    $cSocksErrorNetworkUnreachable :: Constr
    $cSocksErrorConnectionNotAllowedByRule :: Constr
    $cSocksErrorGeneralServerFailure :: Constr
    $tSocksError :: DataType
    gmapMo :: (forall d. Data d => d -> m d) -> SocksError -> m SocksError
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SocksError -> m SocksError
    gmapMp :: (forall d. Data d => d -> m d) -> SocksError -> m SocksError
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SocksError -> m SocksError
    gmapM :: (forall d. Data d => d -> m d) -> SocksError -> m SocksError
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> SocksError -> m SocksError
    gmapQi :: Int -> (forall d. Data d => d -> u) -> SocksError -> u
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SocksError -> u
    gmapQ :: (forall d. Data d => d -> u) -> SocksError -> [u]
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> SocksError -> [u]
    gmapQr :: (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> SocksError -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> SocksError -> r
    gmapQl :: (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> SocksError -> r
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> SocksError -> r
    gmapT :: (forall b. Data b => b -> b) -> SocksError -> SocksError
    $cgmapT :: (forall b. Data b => b -> b) -> SocksError -> SocksError
    dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SocksError)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SocksError)
    dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c SocksError)
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c SocksError)
    dataTypeOf :: SocksError -> DataType
    $cdataTypeOf :: SocksError -> DataType
    toConstr :: SocksError -> Constr
    $ctoConstr :: SocksError -> Constr
    gunfold :: (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SocksError
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SocksError
    gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> SocksError -> c SocksError
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> SocksError -> c SocksError
    $cp1Data :: Typeable SocksError
    Data,Typeable)

    -- | Exception returned when using a SOCKS version that is not supported.
    --
    -- This package only implement version 5.
    data SocksVersionNotSupported = SocksVersionNotSupported
        deriving (Int -> SocksVersionNotSupported -> ShowS
    [SocksVersionNotSupported] -> ShowS
    SocksVersionNotSupported -> String
    (Int -> SocksVersionNotSupported -> ShowS)
    -> (SocksVersionNotSupported -> String)
    -> ([SocksVersionNotSupported] -> ShowS)
    -> Show SocksVersionNotSupported
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [SocksVersionNotSupported] -> ShowS
    $cshowList :: [SocksVersionNotSupported] -> ShowS
    show :: SocksVersionNotSupported -> String
    $cshow :: SocksVersionNotSupported -> String
    showsPrec :: Int -> SocksVersionNotSupported -> ShowS
    $cshowsPrec :: Int -> SocksVersionNotSupported -> ShowS
    Show,Typeable SocksVersionNotSupported
    DataType
    Constr
    Typeable SocksVersionNotSupported =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g)
     -> SocksVersionNotSupported
     -> c SocksVersionNotSupported)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c SocksVersionNotSupported)
    -> (SocksVersionNotSupported -> Constr)
    -> (SocksVersionNotSupported -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d))
        -> Maybe (c SocksVersionNotSupported))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c SocksVersionNotSupported))
    -> ((forall b. Data b => b -> b)
        -> SocksVersionNotSupported -> SocksVersionNotSupported)
    -> (forall r r'.
        (r -> r' -> r)
        -> r
        -> (forall d. Data d => d -> r')
        -> SocksVersionNotSupported
        -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r
        -> (forall d. Data d => d -> r')
        -> SocksVersionNotSupported
        -> r)
    -> (forall u.
        (forall d. Data d => d -> u) -> SocksVersionNotSupported -> [u])
    -> (forall u.
        Int
        -> (forall d. Data d => d -> u) -> SocksVersionNotSupported -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d)
        -> SocksVersionNotSupported -> m SocksVersionNotSupported)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d)
        -> SocksVersionNotSupported -> m SocksVersionNotSupported)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d)
        -> SocksVersionNotSupported -> m SocksVersionNotSupported)
    -> Data SocksVersionNotSupported
    SocksVersionNotSupported -> DataType
    SocksVersionNotSupported -> Constr
    (forall b. Data b => b -> b)
    -> SocksVersionNotSupported -> SocksVersionNotSupported
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g)
    -> SocksVersionNotSupported
    -> c SocksVersionNotSupported
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SocksVersionNotSupported
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u.
    Int
    -> (forall d. Data d => d -> u) -> SocksVersionNotSupported -> u
    forall u.
    (forall d. Data d => d -> u) -> SocksVersionNotSupported -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> SocksVersionNotSupported
    -> r
    forall r r'.
    (r' -> r -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> SocksVersionNotSupported
    -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> SocksVersionNotSupported -> m SocksVersionNotSupported
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> SocksVersionNotSupported -> m SocksVersionNotSupported
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SocksVersionNotSupported
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g)
    -> SocksVersionNotSupported
    -> c SocksVersionNotSupported
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c SocksVersionNotSupported)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c SocksVersionNotSupported)
    $cSocksVersionNotSupported :: Constr
    $tSocksVersionNotSupported :: DataType
    gmapMo :: (forall d. Data d => d -> m d)
    -> SocksVersionNotSupported -> m SocksVersionNotSupported
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> SocksVersionNotSupported -> m SocksVersionNotSupported
    gmapMp :: (forall d. Data d => d -> m d)
    -> SocksVersionNotSupported -> m SocksVersionNotSupported
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> SocksVersionNotSupported -> m SocksVersionNotSupported
    gmapM :: (forall d. Data d => d -> m d)
    -> SocksVersionNotSupported -> m SocksVersionNotSupported
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> SocksVersionNotSupported -> m SocksVersionNotSupported
    gmapQi :: Int
    -> (forall d. Data d => d -> u) -> SocksVersionNotSupported -> u
    $cgmapQi :: forall u.
    Int
    -> (forall d. Data d => d -> u) -> SocksVersionNotSupported -> u
    gmapQ :: (forall d. Data d => d -> u) -> SocksVersionNotSupported -> [u]
    $cgmapQ :: forall u.
    (forall d. Data d => d -> u) -> SocksVersionNotSupported -> [u]
    gmapQr :: (r' -> r -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> SocksVersionNotSupported
    -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> SocksVersionNotSupported
    -> r
    gmapQl :: (r -> r' -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> SocksVersionNotSupported
    -> r
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> SocksVersionNotSupported
    -> r
    gmapT :: (forall b. Data b => b -> b)
    -> SocksVersionNotSupported -> SocksVersionNotSupported
    $cgmapT :: (forall b. Data b => b -> b)
    -> SocksVersionNotSupported -> SocksVersionNotSupported
    dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c SocksVersionNotSupported)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c SocksVersionNotSupported)
    dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c SocksVersionNotSupported)
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c SocksVersionNotSupported)
    dataTypeOf :: SocksVersionNotSupported -> DataType
    $cdataTypeOf :: SocksVersionNotSupported -> DataType
    toConstr :: SocksVersionNotSupported -> Constr
    $ctoConstr :: SocksVersionNotSupported -> Constr
    gunfold :: (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SocksVersionNotSupported
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SocksVersionNotSupported
    gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g)
    -> SocksVersionNotSupported
    -> c SocksVersionNotSupported
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g)
    -> SocksVersionNotSupported
    -> c SocksVersionNotSupported
    $cp1Data :: Typeable SocksVersionNotSupported
    Data,Typeable)

    instance Exception SocksError
    instance Exception SocksVersionNotSupported

    instance Enum SocksCommand where
        toEnum :: Int -> SocksCommand
    toEnum 1 = SocksCommand
    SocksCommandConnect
        toEnum 2 = SocksCommand
    SocksCommandBind
        toEnum 3 = SocksCommand
    SocksCommandUdpAssociate
        toEnum w :: Int
    w
            | Int
    w Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    < 256   = Word8 -> SocksCommand
    SocksCommandOther (Word8 -> SocksCommand) -> Word8 -> SocksCommand
    forall a b. (a -> b) -> a -> b
    $ Int -> Word8
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Int
    w
            | Bool
    otherwise = String -> SocksCommand
    forall a. HasCallStack => String -> a
    error "socks command is only 8 bits"
        fromEnum :: SocksCommand -> Int
    fromEnum SocksCommandConnect      = 1
        fromEnum SocksCommandBind         = 2
        fromEnum SocksCommandUdpAssociate = 3
        fromEnum (SocksCommandOther w :: Word8
    w)    = Word8 -> Int
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Word8
    w

    instance Enum SocksMethod where
        toEnum :: Int -> SocksMethod
    toEnum 0    = SocksMethod
    SocksMethodNone
        toEnum 1    = SocksMethod
    SocksMethodGSSAPI
        toEnum 2    = SocksMethod
    SocksMethodUsernamePassword
        toEnum 0xff = SocksMethod
    SocksMethodNotAcceptable
        toEnum w :: Int
    w
            | Int
    w Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    < 256   = Word8 -> SocksMethod
    SocksMethodOther (Word8 -> SocksMethod) -> Word8 -> SocksMethod
    forall a b. (a -> b) -> a -> b
    $ Int -> Word8
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Int
    w
            | Bool
    otherwise = String -> SocksMethod
    forall a. HasCallStack => String -> a
    error "socks method is only 8 bits"
        fromEnum :: SocksMethod -> Int
    fromEnum SocksMethodNone             = 0
        fromEnum SocksMethodGSSAPI           = 1
        fromEnum SocksMethodUsernamePassword = 2
        fromEnum (SocksMethodOther w :: Word8
    w)        = Word8 -> Int
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Word8
    w
        fromEnum SocksMethodNotAcceptable    = 0xff

    instance Enum SocksError where
        fromEnum :: SocksError -> Int
    fromEnum SocksErrorGeneralServerFailure       = 1
        fromEnum SocksErrorConnectionNotAllowedByRule = 2
        fromEnum SocksErrorNetworkUnreachable         = 3
        fromEnum SocksErrorHostUnreachable            = 4
        fromEnum SocksErrorConnectionRefused          = 5
        fromEnum SocksErrorTTLExpired                 = 6
        fromEnum SocksErrorCommandNotSupported        = 7
        fromEnum SocksErrorAddrTypeNotSupported       = 8
        fromEnum (SocksErrorOther w :: Word8
    w)                  = Word8 -> Int
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Word8
    w
        toEnum :: Int -> SocksError
    toEnum 1 = SocksError
    SocksErrorGeneralServerFailure
        toEnum 2 = SocksError
    SocksErrorConnectionNotAllowedByRule
        toEnum 3 = SocksError
    SocksErrorNetworkUnreachable
        toEnum 4 = SocksError
    SocksErrorHostUnreachable
        toEnum 5 = SocksError
    SocksErrorConnectionRefused
        toEnum 6 = SocksError
    SocksErrorTTLExpired
        toEnum 7 = SocksError
    SocksErrorCommandNotSupported
        toEnum 8 = SocksError
    SocksErrorAddrTypeNotSupported
        toEnum w :: Int
    w = Word8 -> SocksError
    SocksErrorOther (Word8 -> SocksError) -> Word8 -> SocksError
    forall a b. (a -> b) -> a -> b
    $ Int -> Word8
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Int
    w

    instance Enum SocksReply where
        fromEnum :: SocksReply -> Int
    fromEnum SocksReplySuccess                    = 0
        fromEnum (SocksReplyError e :: SocksError
    e)                  = SocksError -> Int
    forall a. Enum a => a -> Int
    fromEnum SocksError
    e
        toEnum :: Int -> SocksReply
    toEnum 0 = SocksReply
    SocksReplySuccess
        toEnum n :: Int
    n = SocksError -> SocksReply
    SocksReplyError (Int -> SocksError
    forall a. Enum a => Int -> a
    toEnum Int
    n)