on master help sign in
Merge pull request #619 from LeifW/diagnostic_on_repl_network_deny
98e8963Edwin Brady
src/Idris/REPL.hs+3−1
@@ -133,7 +133,9 @@ startServer orig stvar fn_in = do tid <- runIO $ forkOS serverLoop
133 putMVar stvar ist'
133 putMVar stvar ist'
134 hClose h
134 hClose h
135 loop fn ist' sock
135 loop fn ist' sock
136+ else do
137+ putStrLn $ "Closing connection attempt from non-localhost " ++ host
136− else hClose h
138+ hClose h
137
139
138processNetCmd :: MVar IState ->
140processNetCmd :: MVar IState ->
139 IState -> IState -> Handle -> FilePath -> String ->
141 IState -> IState -> Handle -> FilePath -> String ->
src/Util/System.hs+9−11
@@ -5,6 +5,8 @@ module Util.System(tempfile,withTempdir,getTargetDir,getCC,
5
5
6-- System helper functions.
6-- System helper functions.
7import Control.Monad (when)
7import Control.Monad (when)
8+import Control.Applicative ((<$>))
9+import Data.Maybe (fromMaybe)
8import Distribution.Text (display)
10import Distribution.Text (display)
9import System.Directory (getTemporaryDirectory
11import System.Directory (getTemporaryDirectory
10 , removeFile
12 , removeFile
@@ -26,22 +28,18 @@ throwIO :: IOError -> IO a
26throwIO = CE.throw
28throwIO = CE.throw
27
29
28
30
29−
30getCC :: IO String
31getCC :: IO String
31−getCC = do env <- environment "IDRIS_CC"
32+getCC = fromMaybe "gcc" <$> environment "IDRIS_CC"
32− case env of
33− Nothing -> return "gcc"
34− Just cc -> return cc
35
33
36−getMvn :: IO String
34+mvnCommand :: String
37−getMvn = do env <- environment "IDRIS_MVN"
38− case env of
39#ifdef mingw32_HOST_OS
35#ifdef mingw32_HOST_OS
40− Nothing -> return "mvn.bat"
36+mvnCommand = "mvn.bat"
41#else
37#else
42− Nothing -> return "mvn"
38+mvnCommand = "mvn"
43#endif
39#endif
44− Just mvn -> return mvn
40+
41+getMvn :: IO String
42+getMvn = fromMaybe mvnCommand <$> environment "IDRIS_MVN"
45
43
46tempfile :: IO (FilePath, Handle)
44tempfile :: IO (FilePath, Handle)
47tempfile = do dir <- getTemporaryDirectory
45tempfile = do dir <- getTemporaryDirectory