From aead2b77331482ca3af2ea386de00e41c50f7c12 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 29 Aug 2016 19:11:51 -0400 Subject: make server default to only listening to localhost This way, the tor hidden service using it will be the only way it's exposed. --- CmdLine.hs | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'CmdLine.hs') diff --git a/CmdLine.hs b/CmdLine.hs index c15ca83..038a210 100644 --- a/CmdLine.hs +++ b/CmdLine.hs @@ -20,11 +20,17 @@ data CmdLine = CmdLine , gui :: Bool , testMode :: Bool , customShareParams :: Maybe ShareParams + , serverConfig :: ServerConfig } -data Mode = Backup | Restore | UploadQueued | Server Port | Benchmark +data Mode = Backup | Restore | UploadQueued | Server | Benchmark deriving (Show) +data ServerConfig = ServerConfig + { serverPort :: Port + , serverAddress :: String + } + parse :: Parser CmdLine parse = CmdLine <$> optional (backup <|> restore <|> uploadqueued <|> server <|> benchmark) @@ -33,6 +39,7 @@ parse = CmdLine <*> guiswitch <*> testmodeswitch <*> optional (ShareParams <$> totalobjects <*> neededobjects) + <*> serverconfig where backup = flag' Backup ( long "backup" @@ -46,9 +53,8 @@ parse = CmdLine ( long "uploadqueued" <> help "Upload any data to servers that was queued by a previous --backup run." ) - server = Server <$> option auto + server = flag' Server ( long "server" - <> metavar "PORT" <> help "Run as a keysafe server, accepting objects and storing them to ~/.keysafe/objects/local/" ) benchmark = flag' Benchmark @@ -80,14 +86,28 @@ parse = CmdLine totalobjects = option auto ( long "totalshares" <> metavar "M" - <> help ("Configure the number of shares to split encrypted secret key into. Default: " ++ show (totalObjects (shareParams defaultTunables)) ++ " (When this option is used to back up a key, it must also be provided at restore time.)") + <> help ("Configure the number of shares to split encrypted secret key into. (default: " ++ show (totalObjects (shareParams defaultTunables)) ++ ") (When this option is used to back up a key, it must also be provided at restore time.)") ) neededobjects = option auto ( long "neededshares" <> metavar "N" - <> help ("Configure the number of shares needed to restore. Default: " ++ show (neededObjects (shareParams defaultTunables)) ++ " (When this option is used to back up a key, it must also be provided at restore time.)") + <> help ("Configure the number of shares needed to restore. (default: " ++ show (neededObjects (shareParams defaultTunables)) ++ ") (When this option is used to back up a key, it must also be provided at restore time.)") ) - + serverconfig = ServerConfig + <$> option auto + ( long "port" + <> metavar "P" + <> value 80 + <> showDefault + <> help "Port for server to listen on." + ) + <*> option str + ( long "address" + <> metavar "A" + <> value "127.0.0.1" + <> showDefault + <> help "Address for server to bind to." + ) get :: IO CmdLine get = execParser opts where -- cgit v1.2.3