-- |
-- Module      : Network.Socks5.Conf
-- License     : BSD-style
-- Maintainer  : Vincent Hanquez <vincent@snarc.org>
-- Stability   : experimental
-- Portability : unknown
--
-- typical SOCKS configuration
module Network.Socks5.Conf
    ( SocksConf(..)
    , socksHost
    , defaultSocksConf 
    , defaultSocksConfFromSockAddr
    ) where

import Network.Socket
import Network.Socks5.Types (SocksVersion(..))

-- | SOCKS identification and configuration structure.
--
-- this structure will be extended in future to support authentification.
-- use defaultSocksConf to create new record.
data SocksConf = SocksConf
    { SocksConf -> SockAddr
socksServer  :: SockAddr     -- ^ Address of server
    , SocksConf -> SocksVersion
socksVersion :: SocksVersion -- ^ SOCKS version to use
    }

-- | SOCKS Host
socksHost :: SocksConf -> SockAddr
socksHost :: SocksConf -> SockAddr
socksHost SocksConf
conf = SocksConf -> SockAddr
socksServer SocksConf
conf

-- | defaultSocksConf create a new record, making sure
-- API remains compatible when the record is extended.
defaultSocksConf :: SockAddr -> SocksConf
defaultSocksConf :: SockAddr -> SocksConf
defaultSocksConf SockAddr
host = SockAddr -> SocksVersion -> SocksConf
SocksConf SockAddr
host SocksVersion
SocksVer5

-- | same as defaultSocksConf.
--
-- soft deprecation: use 'defaultSocksConf"
defaultSocksConfFromSockAddr :: SockAddr -> SocksConf
defaultSocksConfFromSockAddr = SockAddr -> SocksConf
defaultSocksConf