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.Lowlevel

Contents

- Low level types and functions

Description

Low level types and functions for interacting with a SOCKS server.

Synopsis

- socksListen :: Socket -> IO SocksRequest
- newtype SocksHello = SocksHello {
  - getSocksHelloMethods :: [SocksMethod]
  }
- newtype SocksHelloResponse = SocksHelloResponse {
  - getSocksHelloResponseMethod :: SocksMethod
  }
- data SocksRequest = SocksRequest {
  - requestCommand :: SocksCommand
  - requestDstAddr :: SocksHostAddress
  - requestDstPort :: PortNumber
  }
- data SocksResponse = SocksResponse {
  - responseReply :: SocksReply
  - responseBindAddr :: SocksHostAddress
  - responseBindPort :: PortNumber
  }
- class Command a where
  - toRequest :: a -> SocksRequest
  - fromRequest :: SocksRequest -> Maybe a
- newtype Connect = Connect SocksAddress
- establish :: SocksVersion -> Socket -> [SocksMethod] -> IO SocksMethod
- rpc_ :: Command a => Socket -> a -> IO (SocksHostAddress, PortNumber)
- 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))
- sendSerialized :: Serialize a => Socket -> a -> IO ()
- waitSerialized :: Serialize a => Socket -> IO a

# Documentation

socksListen Source #

Arguments

:: Socket | The socket to use.
-> IO SocksRequest |

For the specified socket, wait for a SOCKS Hello, send a SOCKS Hello response (specifying no authentification method), and wait for a SOCKS request.

# Low level types and functions

newtype SocksHello Source #

Type representing initial messages sent by a client with the list of authentification methods supported.

Constructors

SocksHello |

Fields

- getSocksHelloMethods :: [SocksMethod]

#### Instances

Instances details

Serialize SocksHello Source # |
Instance details Defined in Network.Socks5.Wire Methods put :: Putter SocksHello Source # get :: Get SocksHello Source #
Show SocksHello Source # |
Instance details Defined in Network.Socks5.Wire Methods showsPrec :: Int -> SocksHello -> ShowS Source # show :: SocksHello -> String Source # showList :: [SocksHello] -> ShowS Source #
Eq SocksHello Source # |
Instance details Defined in Network.Socks5.Wire Methods (==) :: SocksHello -> SocksHello -> Bool Source # (/=) :: SocksHello -> SocksHello -> Bool Source #

newtype SocksHelloResponse Source #

Type representing initial messages sent by a server in response to Hello, with the server's chosen method of authentication.

Constructors

SocksHelloResponse |

Fields

- getSocksHelloResponseMethod :: SocksMethod

#### Instances

Instances details

Serialize SocksHelloResponse Source # |
Instance details Defined in Network.Socks5.Wire Methods put :: Putter SocksHelloResponse Source # get :: Get SocksHelloResponse Source #
Show SocksHelloResponse Source # |
Instance details Defined in Network.Socks5.Wire Methods showsPrec :: Int -> SocksHelloResponse -> ShowS Source # show :: SocksHelloResponse -> String Source # showList :: [SocksHelloResponse] -> ShowS Source #
Eq SocksHelloResponse Source # |
Instance details Defined in Network.Socks5.Wire Methods (==) :: SocksHelloResponse -> SocksHelloResponse -> Bool Source # (/=) :: SocksHelloResponse -> SocksHelloResponse -> Bool Source #

data SocksRequest Source #

Type representing SOCKS requests.

Constructors

SocksRequest |

Fields

- requestCommand :: SocksCommand
- requestDstAddr :: SocksHostAddress
- requestDstPort :: PortNumber

#### Instances

Instances details

Serialize SocksRequest Source # |
Instance details Defined in Network.Socks5.Wire Methods put :: Putter SocksRequest Source # get :: Get SocksRequest Source #
Command SocksRequest Source # |
Instance details Defined in Network.Socks5.Command Methods toRequest :: SocksRequest -> SocksRequest Source # fromRequest :: SocksRequest -> Maybe SocksRequest Source #
Show SocksRequest Source # |
Instance details Defined in Network.Socks5.Wire Methods showsPrec :: Int -> SocksRequest -> ShowS Source # show :: SocksRequest -> String Source # showList :: [SocksRequest] -> ShowS Source #
Eq SocksRequest Source # |
Instance details Defined in Network.Socks5.Wire Methods (==) :: SocksRequest -> SocksRequest -> Bool Source # (/=) :: SocksRequest -> SocksRequest -> Bool Source #

data SocksResponse Source #

Type representing SOCKS responses.

Constructors

SocksResponse |

Fields

- responseReply :: SocksReply
- responseBindAddr :: SocksHostAddress
- responseBindPort :: PortNumber

#### Instances

Instances details

Serialize SocksResponse Source # |
Instance details Defined in Network.Socks5.Wire Methods put :: Putter SocksResponse Source # get :: Get SocksResponse Source #
Show SocksResponse Source # |
Instance details Defined in Network.Socks5.Wire Methods showsPrec :: Int -> SocksResponse -> ShowS Source # show :: SocksResponse -> String Source # showList :: [SocksResponse] -> ShowS Source #
Eq SocksResponse Source # |
Instance details Defined in Network.Socks5.Wire Methods (==) :: SocksResponse -> SocksResponse -> Bool Source # (/=) :: SocksResponse -> SocksResponse -> Bool Source #

class Command a where Source #

A type class for types that can yield a SOCKS request or, optionally, be obtained from a SOCKS request.

Methods

toRequest :: a -> SocksRequest Source #

fromRequest :: SocksRequest -> Maybe a Source #

#### Instances

Instances details

Command Connect Source # |
Instance details Defined in Network.Socks5.Command Methods toRequest :: Connect -> SocksRequest Source # fromRequest :: SocksRequest -> Maybe Connect Source #
Command SocksRequest Source # |
Instance details Defined in Network.Socks5.Command Methods toRequest :: SocksRequest -> SocksRequest Source # fromRequest :: SocksRequest -> Maybe SocksRequest Source #

newtype Connect Source #

Type representing connect commands.

Constructors

Connect SocksAddress |

#### Instances

Instances details

Command Connect Source # |
Instance details Defined in Network.Socks5.Command Methods toRequest :: Connect -> SocksRequest Source # fromRequest :: SocksRequest -> Maybe Connect Source #
Show Connect Source # |
Instance details Defined in Network.Socks5.Command Methods showsPrec :: Int -> Connect -> ShowS Source # show :: Connect -> String Source # showList :: [Connect] -> ShowS Source #
Eq Connect Source # |
Instance details Defined in Network.Socks5.Command Methods (==) :: Connect -> Connect -> Bool Source # (/=) :: Connect -> Connect -> Bool Source #
Ord Connect Source # |
Instance details Defined in Network.Socks5.Command Methods compare :: Connect -> Connect -> Ordering Source # (<) :: Connect -> Connect -> Bool Source # (<=) :: Connect -> Connect -> Bool Source # (>) :: Connect -> Connect -> Bool Source # (>=) :: Connect -> Connect -> Bool Source # max :: Connect -> Connect -> Connect Source # min :: Connect -> Connect -> Connect Source #

establish Source #

Arguments

:: SocksVersion | The SOCKS protocol version to use.
-> Socket | The socket to use.
-> [SocksMethod] | A list of the authentification methods supported.
-> IO SocksMethod |

Establish a connection with a SOCKS server.

rpc_ Source #

Arguments

:: Command a |
=> Socket | The socket to use.
-> a | The command.
-> IO (SocksHostAddress, PortNumber) |

As for `rpc` but throws an exception if it does not succeed.

connectIPV4 Source #

Arguments

:: Socket | The socket to use.
-> HostAddress | The host address.
-> PortNumber | The port number to use.
-> IO (HostAddress, PortNumber) |

Connect using IPv4.

connectIPV6 Source #

Arguments

:: Socket | The socket to use.
-> HostAddress6 | The host address.
-> PortNumber | The port number to use.
-> IO (HostAddress6, PortNumber) |

Connect using IPv6.

connectDomainName Source #

Arguments

:: Socket | The socket to use.
-> 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 (SocksHostAddress, PortNumber) |

Connect using a fully-qualified domain name (FQDN).

rpc Source #

Arguments

:: Command a |
=> Socket | The socket to use.
-> a | The command.
-> IO (Either SocksError (SocksHostAddress, PortNumber)) |

Try to execute the specified command with the specified socket.

sendSerialized Source #

Arguments

:: Serialize a |
=> Socket | The socket to use.
-> a | The data.
-> IO () |

Send data to the specified socket.

waitSerialized Source #

Arguments

:: Serialize a |
=> Socket | The socket to use.
-> IO a |

Wait for data from the specified socket.