From 46df86a842111c90306dd6d978135e585d849d03 Mon Sep 17 00:00:00 2001 From: Michael Hanus Date: Thu, 15 Nov 2018 09:34:13 +0100 Subject: [PATCH] Improves localhost check --- helpers/WebCPNSD.curry | 5 +++-- helpers/WebRegistry.curry | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/helpers/WebCPNSD.curry b/helpers/WebCPNSD.curry index b510387..0c5c698 100644 --- a/helpers/WebCPNSD.curry +++ b/helpers/WebCPNSD.curry @@ -26,7 +26,7 @@ main :: IO HtmlForm main = do param <- getUrlParameter remote <- getEnviron "REMOTE_ADDR" - if remote == "127.0.0.1" + if remote `elem` ["127.0.0.1","::1"] then do result <- execCommand param return $ answerText result else return $ answerText $ @@ -36,6 +36,7 @@ execCommand :: String -> IO String execCommand param = case param of "status" -> cpnsCmd "status" "log" -> cpnsCmd "log" + "start" -> cpnsCmd "start" _ -> return $ unlines $ ["ILLEGAL URL PARAMETER: " ++ param, "", cpnsCommands] where @@ -43,7 +44,7 @@ execCommand param = case param of (_,out,err) <- evalCmd "curry-cpnsd" [cmd] "" 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: diff --git a/helpers/WebRegistry.curry b/helpers/WebRegistry.curry index 9a612a6..79a4953 100644 --- a/helpers/WebRegistry.curry +++ b/helpers/WebRegistry.curry @@ -28,7 +28,7 @@ main :: IO HtmlForm main = do param <- getUrlParameter remote <- getEnviron "REMOTE_ADDR" - if remote == "127.0.0.1" + if remote `elem` ["127.0.0.1","::1"] then do result <- execCommand param return $ answerText result else return $ answerText $ -- GitLab