summaryrefslogtreecommitdiffhomepage
path: root/CmdLine.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-08-29 19:11:51 -0400
committerJoey Hess <joeyh@joeyh.name>2016-08-29 19:11:51 -0400
commitaead2b77331482ca3af2ea386de00e41c50f7c12 (patch)
tree2dd818c3371d045e123917a4eb82c0baeb4cf563 /CmdLine.hs
parent7ad3536737f30bbd328a4d37f78a72f9600fb4b8 (diff)
downloadkeysafe-aead2b77331482ca3af2ea386de00e41c50f7c12.tar.gz
make server default to only listening to localhost
This way, the tor hidden service using it will be the only way it's exposed.
Diffstat (limited to 'CmdLine.hs')
-rw-r--r--CmdLine.hs32
1 files changed, 26 insertions, 6 deletions
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