Copyright | (c) 2010-2019 Vincent Hanquez <vincent@snarc.org> |
---|---|
License | BSD-style |
Stability | experimental |
Portability | unknown |
Safe Haskell | None |
Language | Haskell2010 |
Network.Socks5
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
- data SocksReply
- data SocksError
- data SocksConf = SocksConf {}
- 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
Show SocksAddress Source # | |
Defined in Network.Socks5.Types Methods showsPrec :: Int -> SocksAddress -> ShowS # show :: SocksAddress -> String # showList :: [SocksAddress] -> ShowS # | |
Eq SocksAddress Source # | |
Defined in Network.Socks5.Types | |
Ord SocksAddress Source # | |
Defined in Network.Socks5.Types Methods compare :: SocksAddress -> SocksAddress -> Ordering # (<) :: SocksAddress -> SocksAddress -> Bool # (<=) :: SocksAddress -> SocksAddress -> Bool # (>) :: SocksAddress -> SocksAddress -> Bool # (>=) :: SocksAddress -> SocksAddress -> Bool # max :: SocksAddress -> SocksAddress -> SocksAddress # min :: SocksAddress -> SocksAddress -> SocksAddress # |
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
Show SocksHostAddress Source # | |
Defined in Network.Socks5.Types Methods showsPrec :: Int -> SocksHostAddress -> ShowS # show :: SocksHostAddress -> String # showList :: [SocksHostAddress] -> ShowS # | |
Eq SocksHostAddress Source # | |
Defined in Network.Socks5.Types Methods (==) :: SocksHostAddress -> SocksHostAddress -> Bool # (/=) :: SocksHostAddress -> SocksHostAddress -> Bool # | |
Ord SocksHostAddress Source # | |
Defined in Network.Socks5.Types Methods compare :: SocksHostAddress -> SocksHostAddress -> Ordering # (<) :: SocksHostAddress -> SocksHostAddress -> Bool # (<=) :: SocksHostAddress -> SocksHostAddress -> Bool # (>) :: SocksHostAddress -> SocksHostAddress -> Bool # (>=) :: SocksHostAddress -> SocksHostAddress -> Bool # max :: SocksHostAddress -> SocksHostAddress -> SocksHostAddress # min :: SocksHostAddress -> SocksHostAddress -> SocksHostAddress # |
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
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
Configuration
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
|
Yield the socket address of the server from the specified configuration.
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|
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
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.