Commit 46df86a8 authored by Michael Hanus 's avatar Michael Hanus

Improves localhost check

parent 65a958b2
...@@ -26,7 +26,7 @@ main :: IO HtmlForm ...@@ -26,7 +26,7 @@ main :: IO HtmlForm
main = do main = do
param <- getUrlParameter param <- getUrlParameter
remote <- getEnviron "REMOTE_ADDR" remote <- getEnviron "REMOTE_ADDR"
if remote == "127.0.0.1" if remote `elem` ["127.0.0.1","::1"]
then do result <- execCommand param then do result <- execCommand param
return $ answerText result return $ answerText result
else return $ answerText $ else return $ answerText $
...@@ -36,6 +36,7 @@ execCommand :: String -> IO String ...@@ -36,6 +36,7 @@ execCommand :: String -> IO String
execCommand param = case param of execCommand param = case param of
"status" -> cpnsCmd "status" "status" -> cpnsCmd "status"
"log" -> cpnsCmd "log" "log" -> cpnsCmd "log"
"start" -> cpnsCmd "start"
_ -> return $ unlines $ _ -> return $ unlines $
["ILLEGAL URL PARAMETER: " ++ param, "", cpnsCommands] ["ILLEGAL URL PARAMETER: " ++ param, "", cpnsCommands]
where where
...@@ -43,7 +44,7 @@ execCommand param = case param of ...@@ -43,7 +44,7 @@ execCommand param = case param of
(_,out,err) <- evalCmd "curry-cpnsd" [cmd] "" (_,out,err) <- evalCmd "curry-cpnsd" [cmd] ""
return $ out ++ if null err then "" else "ERROR OUTPUT:\n" ++ err return $ out ++ if null err then "" else "ERROR OUTPUT:\n" ++ err
cpnsCommands = "Allowed arguments: status | log" cpnsCommands = "Allowed arguments: status | log | start"
-- Install the CGI script in user homepage by: -- Install the CGI script in user homepage by:
......
...@@ -28,7 +28,7 @@ main :: IO HtmlForm ...@@ -28,7 +28,7 @@ main :: IO HtmlForm
main = do main = do
param <- getUrlParameter param <- getUrlParameter
remote <- getEnviron "REMOTE_ADDR" remote <- getEnviron "REMOTE_ADDR"
if remote == "127.0.0.1" if remote `elem` ["127.0.0.1","::1"]
then do result <- execCommand param then do result <- execCommand param
return $ answerText result return $ answerText result
else return $ answerText $ else return $ answerText $
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment