module Network.Socks5.Lowlevel
    ( socksListen
    -- * lowlevel types
    , module Network.Socks5.Wire
    , module Network.Socks5.Command
    ) where

import Network.Socket
import Network.Socks5.Command
import Network.Socks5.Wire
import Network.Socks5.Types

socksListen :: Socket -> IO SocksRequest
socksListen :: Socket -> IO SocksRequest
socksListen Socket
sock = do
    SocksHello
hello <- Socket -> IO SocksHello
forall a. Serialize a => Socket -> IO a
waitSerialized Socket
sock
    case SocksHello -> [SocksMethod]
getSocksHelloMethods SocksHello
hello of
        [SocksMethod]
_ -> do Socket -> SocksHelloResponse -> IO ()
forall a. Serialize a => Socket -> a -> IO ()
sendSerialized Socket
sock (SocksMethod -> SocksHelloResponse
SocksHelloResponse SocksMethod
SocksMethodNone)
                Socket -> IO SocksRequest
forall a. Serialize a => Socket -> IO a
waitSerialized Socket
sock