Permalink
Browse files

Moved ip lookup function to Gitit.HAppS.

  • Loading branch information...
1 parent a3d9f20 commit 0395cff339854253fbfacd4f1d3ec3967b72f16f @jgm committed Jan 31, 2009
Showing with 14 additions and 10 deletions.
  1. +0 −8 Gitit.hs
  2. +14 −2 Gitit/HAppS.hs
View
@@ -53,7 +53,6 @@ import Network.HTTP (urlEncodeVars)
import Text.Highlighting.Kate
import qualified Text.StringTemplate as T
import Data.DateTime (getCurrentTime, addMinutes, formatDateTime)
-import Network.Socket
import Network.Captcha.ReCaptcha (captchaFields, validateCaptcha)
import Data.FileStore
@@ -798,13 +797,6 @@ registerUser _ params = do
formattedPage (defaultPageLayout { pgShowPageTools = False, pgTabs = [], pgTitle = "Register for an account" })
"_register" (params { pMessages = errors })
-lookupIPAddr :: String -> IO (Maybe String)
-lookupIPAddr hostname = do
- addrs <- getAddrInfo (Just defaultHints) (Just hostname) Nothing
- if null addrs
- then return Nothing
- else return $ Just $ takeWhile (/=':') $ show $ addrAddress $ head addrs
-
showHighlightedSource :: String -> Params -> Web Response
showHighlightedSource file params = do
mbCached <- lookupCache file (pRevision params)
View
@@ -18,8 +18,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-}
{- Replacements for HAppS functions that don't handle UTF-8 properly,
- functions for setting headers and zipping contents,
- and a fix for broken HAppS cookie parsing.
+ functions for setting headers and zipping contents, looking up IP
+ addresses, and a fix for broken HAppS cookie parsing.
-}
module Gitit.HAppS
@@ -33,13 +33,15 @@ module Gitit.HAppS
, withExpiresHeaders
, setContentType
, setFilename
+ , lookupIPAddr
, readMimeTypesFile
, cookieFixer
)
where
import HAppS.Server hiding (look, lookRead, lookCookieValue, mkCookie, getCookies)
import qualified HAppS.Server (lookCookieValue, mkCookie)
import HAppS.Server.Cookie (Cookie(..))
+import Network.Socket (getAddrInfo, defaultHints, addrAddress)
import System.IO (stderr, hPutStrLn)
import Text.Pandoc.CharacterReferences (decodeCharacterReferences)
import Control.Monad (liftM)
@@ -102,6 +104,16 @@ setContentType = setHeader "Content-Type"
setFilename :: String -> Response -> Response
setFilename = setHeader "Content-Disposition" . \fname -> "attachment: filename=\"" ++ fname ++ "\""
+-- IP lookup
+
+lookupIPAddr :: String -> IO (Maybe String)
+lookupIPAddr hostname = do
+ addrs <- getAddrInfo (Just defaultHints) (Just hostname) Nothing
+ if null addrs
+ then return Nothing
+ else return $ Just $ takeWhile (/=':') $ show $ addrAddress $ head addrs
+
+
-- mime types
-- | Read a file associating mime types with extensions, and return a

0 comments on commit 0395cff

Please sign in to comment.