1
1
mirror of https://github.com/aelve/guide.git synced 2024-12-25 13:51:45 +03:00

Silly bug

This commit is contained in:
Artyom 2016-04-08 23:43:43 +03:00
parent 2aaeb4711b
commit e04517b374

View File

@ -127,13 +127,13 @@ addEdit ed = do
time <- liftIO $ getCurrentTime time <- liftIO $ getCurrentTime
mbForwardedFor <- liftA2 (<|>) (Spock.header "Forwarded-For") mbForwardedFor <- liftA2 (<|>) (Spock.header "Forwarded-For")
(Spock.header "X-Forwarded-For") (Spock.header "X-Forwarded-For")
ip <- case mbForwardedFor of mbIP <- case mbForwardedFor of
Nothing -> sockAddrToIP . Wai.remoteHost <$> Spock.request Nothing -> sockAddrToIP . Wai.remoteHost <$> Spock.request
Just ff -> case readMaybe (T.unpack ip) of Just ff -> case readMaybe (T.unpack ip) of
Nothing -> error ("couldn't read Forwarded-For address: " ++ Nothing -> error ("couldn't read Forwarded-For address: " ++
show ip ++ " (full header: " ++ show ip ++ " (full header: " ++
show ff ++ ")") show ff ++ ")")
Just i -> return i Just i -> return (Just i)
where where
addr = T.strip . snd . T.breakOnEnd "," $ ff addr = T.strip . snd . T.breakOnEnd "," $ ff
ip -- [IPv6]:port ip -- [IPv6]:port
@ -146,7 +146,7 @@ addEdit ed = do
| otherwise = | otherwise =
addr addr
unless (isVacuousEdit ed) $ unless (isVacuousEdit ed) $
dbUpdate (RegisterEdit ed ip time) dbUpdate (RegisterEdit ed mbIP time)
-- | Do an action that would undo an edit. -- | Do an action that would undo an edit.
-- --