-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | HAProxy protocol 1.5 support for io-streams
--   
--   HAProxy protocol version 1.5 support (see
--   http://haproxy.1wt.eu/download/1.5/doc/proxy-protocol.txt) for
--   applications using io-streams. The proxy protocol allows information
--   about a networked peer (like remote address and port) to be propagated
--   through a forwarding proxy that is configured to speak this protocol.
@package io-streams-haproxy
@version 1.0.1.0

-- | HAProxy proxying protocol support (see
--   http://haproxy.1wt.eu/download/1.5/doc/proxy-protocol.txt) for
--   applications using io-streams. The proxy protocol allows information
--   about a networked peer (like remote address and port) to be propagated
--   through a forwarding proxy that is configured to speak this protocol.
--   
--   This approach is safer than other alternatives like injecting a
--   special HTTP header (like "X-Forwarded-For") because the data is sent
--   out of band, requests without the proxy header fail, and proxy data
--   cannot be spoofed by the client.
module System.IO.Streams.Network.HAProxy

-- | Parses the proxy headers emitted by HAProxy and runs a user action
--   with the origin/destination socket addresses provided by HAProxy. Will
--   throw a ParseException if the protocol header cannot be parsed
--   properly.
--   
--   We support version 1.5 of the protocol (both the "old" text protocol
--   and the "new" binary protocol.). Typed data fields after the addresses
--   are not (yet) supported.
behindHAProxy :: Socket -> SockAddr -> (ProxyInfo -> InputStream ByteString -> OutputStream ByteString -> IO a) -> IO a

-- | Like behindHAProxy, but allows the socket addresses and
--   input/output streams to be passed in instead of created based on an
--   input Socket. Useful for unit tests.
behindHAProxyWithLocalInfo :: ProxyInfo -> (InputStream ByteString, OutputStream ByteString) -> (ProxyInfo -> InputStream ByteString -> OutputStream ByteString -> IO a) -> IO a
decodeHAProxyHeaders :: ProxyInfo -> InputStream ByteString -> IO ProxyInfo

-- | Stores information about the proxied request.
data ProxyInfo

-- | Make a ProxyInfo from a connected socket.
socketToProxyInfo :: Socket -> SockAddr -> IO ProxyInfo

-- | Makes a ProxyInfo object.
makeProxyInfo :: SockAddr -> SockAddr -> Family -> SocketType -> ProxyInfo

-- | Gets the network address of the source node for this request (i.e. the
--   client).
getSourceAddr :: ProxyInfo -> SockAddr

-- | Gets the network address of the destination node for this request
--   (i.e. the client).
getDestAddr :: ProxyInfo -> SockAddr

-- | Gets the Family of the proxied request (i.e.
--   IPv4IPv6Unix domain sockets).
getFamily :: ProxyInfo -> Family

-- | Gets the SocketType of the proxied request (UDP/TCP).
getSocketType :: ProxyInfo -> SocketType
instance GHC.Internal.Show.Show System.IO.Streams.Network.HAProxy.ProxyInfo
