--- you want a SockAddr instead of String, use 'getRemoteAddr'.
-getRemoteAddr' :: Resource String
-getRemoteAddr' = do addr <- getRemoteAddr
- case addr of
- -- Network.Socket は IPv6 を考慮してゐないやうだ…
- (SockAddrInet _ v4addr)
- -> let b1 = (v4addr `shiftR` 24) .&. 0xFF
- b2 = (v4addr `shiftR` 16) .&. 0xFF
- b3 = (v4addr `shiftR` 8) .&. 0xFF
- b4 = v4addr .&. 0xFF
- in
- return $ concat $ intersperse "." $ map show [b1, b2, b3, b4]
- (SockAddrUnix path)
- -> return path
-
-
--- |Get the 'Network.HTTP.Lucu.Request.Request' value which represents
--- the request header. In general you don't have to use this action.
-getRequest :: Resource Request
-getRequest = do itr <- ask
- req <- liftIO $! atomically $! readItr itr itrRequest fromJust
- return req
-
--- |Get the 'Network.HTTP.Lucu.Request.Method' value of the request.
-getMethod :: Resource Method
-getMethod = do req <- getRequest
- return $! reqMethod req
+-- you want a 'SockAddr' instead of 'String', use 'getRemoteAddr'.
+getRemoteAddr' ∷ Resource HostName
+getRemoteAddr'
+ = do sa ← getRemoteAddr
+ (Just a, _) ← liftIO $ getNameInfo [NI_NUMERICHOST] False False sa
+ return a
+
+-- |Resolve an address to the remote host.
+getRemoteHost ∷ Resource (Maybe HostName)
+getRemoteHost
+ = do sa ← getRemoteAddr
+ fst <$> (liftIO $ getNameInfo [] True False sa)
+
+-- | Return the X.509 certificate of the client, or 'Nothing' if:
+--
+-- * This request didn't came through an SSL stream.
+--
+-- * The client didn't send us its certificate.
+--
+-- * The 'OpenSSL.Session.VerificationMode' of
+-- 'OpenSSL.Session.SSLContext' in 'SSLConfig' has not been set to
+-- 'OpenSSL.Session.VerifyPeer'.
+getRemoteCertificate ∷ Resource (Maybe X509)
+getRemoteCertificate = itrRemoteCert <$> getInteraction
+
+-- |Get the 'Request' value which represents the request header. In
+-- general you don't have to use this action.
+getRequest ∷ Resource Request
+getRequest
+ = do itr ← getInteraction
+ liftIO $ atomically $ readItr itrRequest fromJust itr
+
+-- |Get the 'Method' value of the request.
+getMethod ∷ Resource Method
+getMethod = reqMethod <$> getRequest