crypton-socks-0.6.2: SOCKS Protocol Version 5

Copyright | (c) 2010-2019 Vincent Hanquez <vincent@snarc.org>
License | BSD-style
Stability | experimental
Portability | unknown
Safe Haskell | None
Language | Haskell2010

Network.Socks5

Contents

- Types
- Configuration
- Methods
- Variants

Description

This is an implementation of the SOCKS Protocol Version 5 as defined in RFC 1928.

In Wikipedia's words:

SOCKS is an Internet protocol that exchanges network packets between a client and server through a proxy server. SOCKS5 optionally provides authentication so only authorized users may access a server. Practically, a SOCKS server proxies TCP connections to an arbitrary IP address, and provides a means for UDP packets to be forwarded. A SOCKS server accepts incoming client connection on TCP port 1080.

BIND and UDP ASSOCIATE messages are not implemented. However the main usage of SOCKS is implemented.

Synopsis

- data SocksAddress = SocksAddress !SocksHostAddress !PortNumber
- data SocksHostAddress
  - = SocksAddrIPV4 !HostAddress
  - | SocksAddrDomainName !SocksFQDN
  - | SocksAddrIPV6 !HostAddress6
- data SocksReply
  - = SocksReplySuccess
  - | SocksReplyError SocksError
- data SocksError
  - = SocksErrorGeneralServerFailure
  - | SocksErrorConnectionNotAllowedByRule
  - | SocksErrorNetworkUnreachable
  - | SocksErrorHostUnreachable
  - | SocksErrorConnectionRefused
  - | SocksErrorTTLExpired
  - | SocksErrorCommandNotSupported
  - | SocksErrorAddrTypeNotSupported
  - | SocksErrorOther Word8
- data SocksConf = SocksConf {
  - socksServer :: SockAddr
  - socksVersion :: SocksVersion
  }
- socksHost :: SocksConf -> SockAddr
- defaultSocksConf :: SockAddr -> SocksConf
- defaultSocksConfFromSockAddr :: SockAddr -> SocksConf
- socksConnectWithSocket :: Socket -> SocksConf -> SocksAddress -> IO (SocksHostAddress, PortNumber)
- socksConnect :: SocksConf -> SocksAddress -> IO (Socket, (SocksHostAddress, PortNumber))
- socksConnectName :: Socket -> SocksConf -> String -> PortNumber -> IO ()

# Types

data SocksAddress Source #

Type representing socket addresses under the SOCKS protocol.

Constructors

SocksAddress !SocksHostAddress !PortNumber |

#### Instances

Instances details

Show SocksAddress Source # |
Instance details Defined in Network.Socks5.Types Methods showsPrec :: Int -> SocksAddress -> ShowS Source # show :: SocksAddress -> String Source # showList :: [SocksAddress] -> ShowS Source #
Eq SocksAddress Source # |
Instance details Defined in Network.Socks5.Types Methods (==) :: SocksAddress -> SocksAddress -> Bool Source # (/=) :: SocksAddress -> SocksAddress -> Bool Source #
Ord SocksAddress Source # |

Instance details

Defined in Network.Socks5.Types

Methods

compare :: SocksAddress -> SocksAddress -> Ordering Source #

(<) :: SocksAddress -> SocksAddress -> Bool Source #

(<=) :: SocksAddress -> SocksAddress -> Bool Source #

(>) :: SocksAddress -> SocksAddress -> Bool Source #

(>=) :: SocksAddress -> SocksAddress -> Bool Source #

max :: SocksAddress -> SocksAddress -> SocksAddress Source #

min :: SocksAddress -> SocksAddress -> SocksAddress Source #

data SocksHostAddress Source #

Type representing host addresses under the SOCKS protocol.

Constructors

SocksAddrIPV4 !HostAddress | A version-4 IP address.
SocksAddrDomainName !SocksFQDN | A fully-qualified domain name (FQDN).
SocksAddrIPV6 !HostAddress6 | A version-6 IP address.

#### Instances

Instances details

Show SocksHostAddress Source # |
Instance details Defined in Network.Socks5.Types Methods showsPrec :: Int -> SocksHostAddress -> ShowS Source # show :: SocksHostAddress -> String Source # showList :: [SocksHostAddress] -> ShowS Source #
Eq SocksHostAddress Source # |
Instance details Defined in Network.Socks5.Types Methods (==) :: SocksHostAddress -> SocksHostAddress -> Bool Source # (/=) :: SocksHostAddress -> SocksHostAddress -> Bool Source #
Ord SocksHostAddress Source # |

Instance details

Defined in Network.Socks5.Types

Methods

compare :: SocksHostAddress -> SocksHostAddress -> Ordering Source #

(<) :: SocksHostAddress -> SocksHostAddress -> Bool Source #

(<=) :: SocksHostAddress -> SocksHostAddress -> Bool Source #

(>) :: SocksHostAddress -> SocksHostAddress -> Bool Source #

(>=) :: SocksHostAddress -> SocksHostAddress -> Bool Source #

max :: SocksHostAddress -> SocksHostAddress -> SocksHostAddress Source #

min :: SocksHostAddress -> SocksHostAddress -> SocksHostAddress Source #

data SocksReply Source #

Type representing replies under the SOCKS protocol.

Constructors

SocksReplySuccess | The server reports that the request succeeded.
SocksReplyError SocksError | The server reports that the request did not succeed.

#### Instances

Instances details

Data SocksReply Source # |

Instance details

Defined in Network.Socks5.Types

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SocksReply -> c SocksReply Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SocksReply Source #

toConstr :: SocksReply -> Constr Source #

dataTypeOf :: SocksReply -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SocksReply) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SocksReply) Source #

gmapT :: (forall b. Data b => b -> b) -> SocksReply -> SocksReply Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SocksReply -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SocksReply -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> SocksReply -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> SocksReply -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> SocksReply -> m SocksReply Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SocksReply -> m SocksReply Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SocksReply -> m SocksReply Source #

Enum SocksReply Source # |

Instance details

Defined in Network.Socks5.Types

Methods

succ :: SocksReply -> SocksReply Source #

pred :: SocksReply -> SocksReply Source #

toEnum :: Int -> SocksReply Source #

fromEnum :: SocksReply -> Int Source #

enumFrom :: SocksReply -> [SocksReply] Source #

enumFromThen :: SocksReply -> SocksReply -> [SocksReply] Source #

enumFromTo :: SocksReply -> SocksReply -> [SocksReply] Source #

enumFromThenTo :: SocksReply -> SocksReply -> SocksReply -> [SocksReply] Source #

Show SocksReply Source # |
Instance details Defined in Network.Socks5.Types Methods showsPrec :: Int -> SocksReply -> ShowS Source # show :: SocksReply -> String Source # showList :: [SocksReply] -> ShowS Source #
Eq SocksReply Source # |
Instance details Defined in Network.Socks5.Types Methods (==) :: SocksReply -> SocksReply -> Bool Source # (/=) :: SocksReply -> SocksReply -> Bool Source #
Ord SocksReply Source # |

Instance details

Defined in Network.Socks5.Types

Methods

compare :: SocksReply -> SocksReply -> Ordering Source #

(<) :: SocksReply -> SocksReply -> Bool Source #

(<=) :: SocksReply -> SocksReply -> Bool Source #

(>) :: SocksReply -> SocksReply -> Bool Source #

(>=) :: SocksReply -> SocksReply -> Bool Source #

max :: SocksReply -> SocksReply -> SocksReply Source #

min :: SocksReply -> SocksReply -> SocksReply Source #

data SocksError Source #

Type representing SOCKS errors that can be part of a SOCKS reply.

Constructors

SocksErrorGeneralServerFailure | General SOCKS server failure.
SocksErrorConnectionNotAllowedByRule | Connection not allowed by ruleset.
SocksErrorNetworkUnreachable | Network unreachable.
SocksErrorHostUnreachable | Host unreachable.
SocksErrorConnectionRefused | Connection refused.
SocksErrorTTLExpired | TTL expired.
SocksErrorCommandNotSupported | Command not supported.
SocksErrorAddrTypeNotSupported | Address type not supported.
SocksErrorOther Word8 | Other error. Unassigned in SOCKS Protocol Version 5.

#### Instances

Instances details

Data SocksError Source # |

Instance details

Defined in Network.Socks5.Types

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SocksError -> c SocksError Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SocksError Source #

toConstr :: SocksError -> Constr Source #

dataTypeOf :: SocksError -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SocksError) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SocksError) Source #

gmapT :: (forall b. Data b => b -> b) -> SocksError -> SocksError Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SocksError -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SocksError -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> SocksError -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> SocksError -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> SocksError -> m SocksError Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SocksError -> m SocksError Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SocksError -> m SocksError Source #

Enum SocksError Source # |

Instance details

Defined in Network.Socks5.Types

Methods

succ :: SocksError -> SocksError Source #

pred :: SocksError -> SocksError Source #

toEnum :: Int -> SocksError Source #

fromEnum :: SocksError -> Int Source #

enumFrom :: SocksError -> [SocksError] Source #

enumFromThen :: SocksError -> SocksError -> [SocksError] Source #

enumFromTo :: SocksError -> SocksError -> [SocksError] Source #

enumFromThenTo :: SocksError -> SocksError -> SocksError -> [SocksError] Source #

Exception SocksError Source # |
Instance details Defined in Network.Socks5.Types Methods toException :: SocksError -> SomeException Source # fromException :: SomeException -> Maybe SocksError Source # displayException :: SocksError -> String Source # backtraceDesired :: SocksError -> Bool Source #
Show SocksError Source # |
Instance details Defined in Network.Socks5.Types Methods showsPrec :: Int -> SocksError -> ShowS Source # show :: SocksError -> String Source # showList :: [SocksError] -> ShowS Source #
Eq SocksError Source # |
Instance details Defined in Network.Socks5.Types Methods (==) :: SocksError -> SocksError -> Bool Source # (/=) :: SocksError -> SocksError -> Bool Source #
Ord SocksError Source # |

Instance details

Defined in Network.Socks5.Types

Methods

compare :: SocksError -> SocksError -> Ordering Source #

(<) :: SocksError -> SocksError -> Bool Source #

(<=) :: SocksError -> SocksError -> Bool Source #

(>) :: SocksError -> SocksError -> Bool Source #

(>=) :: SocksError -> SocksError -> Bool Source #

max :: SocksError -> SocksError -> SocksError Source #

min :: SocksError -> SocksError -> SocksError Source #

# Configuration

data SocksConf Source #

Type representing SOCKS identification and configuration structures.

The data constructors may be extended in the future to support authentification. Use the smart constructor `defaultSocksConf` and `socksHost`.

Constructors

SocksConf |

Fields

- socksServer :: SockAddr

  The address of the server.

- socksVersion :: SocksVersion

  The SOCKS protocol version to use.

socksHost Source #

Arguments

:: SocksConf | The configuration.
-> SockAddr |

Yield the socket address of the server from the specified configuration.

defaultSocksConf Source #

Arguments

:: SockAddr | The address of the server.
-> SocksConf |

Yield a configuration given the specified socket addresss.

defaultSocksConfFromSockAddr :: SockAddr -> SocksConf Source #

Deprecated: Will be removed from future package versions. Use defaultSocksConf instead.

Same as `defaultSocksConf`.

# Methods

socksConnectWithSocket Source #

Arguments

:: Socket | The socket to use.
-> SocksConf | The SOCKS configuration for the server.
-> SocksAddress | The SOCKS address to connect to.
-> IO (SocksHostAddress, PortNumber) |

Connect a user-specified new socket on the SOCKS server to a destination.

The specified socket needs to be connected to the SOCKS server already.

|socket|-----sockServer----->|server|----destAddr----->|destination|

socksConnect Source #

Arguments

:: SocksConf | The SOCKS configuration for the server.
-> SocksAddress | The SOCKS address to connect to.
-> IO (Socket, (SocksHostAddress, PortNumber)) |

Connect a new socket to a SOCKS server and connect the stream on the server side to the specified SOCKS address.

# Variants

socksConnectName Source #

Arguments

:: Socket | The socket to use. The socket must *not* be connected already.
-> SocksConf | The SOCKS configuration for the server.
-> String | Destination FQDN. Should comprise only ASCII characters, otherwise unexpected behaviour will ensure. For FQDN including other Unicode code points, Punycode encoding should be used.
-> PortNumber | The port number to use.
-> IO () |

Connect a new socket to the SOCKS server, and connect the stream to a fully-qualified domain name (FQDN) resolved on the server side.