summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-09-01 11:43:01 -0400
committerJoey Hess <joeyh@joeyh.name>2016-09-01 11:43:01 -0400
commit3100ed23049f264e2fc43a02b8b65e7ce4578609 (patch)
treeab2cf2ce36b83893debc25ceffc769805c12c708
parentf6931d56b182c0cac2e3551c4baec4352c5185da (diff)
downloadkeysafe-3100ed23049f264e2fc43a02b8b65e7ce4578609.tar.gz
Fix bug that prevented keysafe --server from running when there was no controlling terminal and zenity was not installed.
-rw-r--r--CHANGELOG7
-rw-r--r--Storage/Network.hs2
-rw-r--r--TODO2
-rw-r--r--UI.hs3
-rw-r--r--UI/NonInteractive.hs42
-rw-r--r--keysafe.cabal1
6 files changed, 55 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index ef6780f..c9cbc1f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,10 @@
+keysafe (0.20160832) UNRELEASED; urgency=medium
+
+ * Fix bug that prevented keysafe --server from running when there was no
+ controlling terminal and zenity was not installed.
+
+ -- Joey Hess <id@joeyh.name> Thu, 01 Sep 2016 11:42:27 -0400
+
keysafe (0.20160831) unstable; urgency=medium
* Server implementation is ready for initial deployment.
diff --git a/Storage/Network.hs b/Storage/Network.hs
index d16d693..ef6d86e 100644
--- a/Storage/Network.hs
+++ b/Storage/Network.hs
@@ -42,7 +42,7 @@ serverUrl srv = BaseUrl Http (serverName srv) (serverPort srv) ""
-- Using tor is highly recommended, to avoid correlation attacks.
networkServers :: IO [Server]
networkServers = return
- [ Server "localhost" 4242
+ [ Server "vzgrspuxbtnlrtup.onion" 4242 -- keysafe.joeyh.name
, Server "localhost" 4242
, Server "localhost" 4242
]
diff --git a/TODO b/TODO
index bc24016..14efa10 100644
--- a/TODO
+++ b/TODO
@@ -2,6 +2,8 @@ Soon:
* Run a key restore and make sure it takes 35 to 50 minutes.
* client/server Proof Of Work
+* Add some random padding to http requests and responses, to make it
+ harder for traffic analysis to tell that it's keysafe traffic.
* Implement the different categories of servers in the server list.
* Include an example tor hidden service config
* Get some keysafe servers set up.
diff --git a/UI.hs b/UI.hs
index c025bb3..4212468 100644
--- a/UI.hs
+++ b/UI.hs
@@ -11,6 +11,7 @@ import Types.UI
import Control.Monad
import UI.Zenity
import UI.Readline
+import UI.NonInteractive
import Control.Concurrent.MVar
availableUIs :: IO [UI]
@@ -27,7 +28,7 @@ selectUI needgui
l <- availableUIs
case l of
(u:_) -> return u
- [] -> error "Neither zenity nor the readline UI are available"
+ [] -> return noninteractiveUI
-- Adds a percent to whatever amount the progress bar is at.
type AddPercent = Percent -> IO ()
diff --git a/UI/NonInteractive.hs b/UI/NonInteractive.hs
new file mode 100644
index 0000000..f0010eb
--- /dev/null
+++ b/UI/NonInteractive.hs
@@ -0,0 +1,42 @@
+{- Copyright 2016 Joey Hess <id@joeyh.name>
+ -
+ - Licensed under the GNU AGPL version 3 or higher.
+ -}
+
+module UI.NonInteractive (noninteractiveUI) where
+
+import Types.UI
+import System.IO
+import Control.Exception
+
+noninteractiveUI :: UI
+noninteractiveUI = UI
+ { isAvailable = return True
+ , showError = myShowError
+ , showInfo = myShowInfo
+ , promptQuestion = myPrompt
+ , promptName = \t d _ -> myPrompt t d
+ , promptPassword = \b t d -> myPrompt t d b
+ , promptKeyId = myPrompt
+ , withProgress = myWithProgress
+ }
+
+myShowError :: Desc -> IO ()
+myShowError desc = hPutStrLn stderr $ "Error: " ++ desc
+
+myShowInfo :: Title -> Desc -> IO ()
+myShowInfo _title desc = putStrLn desc
+
+myPrompt :: Title -> Desc -> x -> IO a
+myPrompt _title desc _ = do
+ putStrLn desc
+ error "Not running at a terminal and zenity is not installed; cannot interact with user."
+
+myWithProgress :: Title -> Desc -> ((Percent -> IO ()) -> IO a) -> IO a
+myWithProgress _title desc a = bracket_ setup cleanup (a sendpercent)
+ where
+ setup = putStrLn desc
+ sendpercent p = do
+ putStr (show p ++ "% ")
+ hFlush stdout
+ cleanup = putStrLn "done"
diff --git a/keysafe.cabal b/keysafe.cabal
index bffd362..9c0b1a6 100644
--- a/keysafe.cabal
+++ b/keysafe.cabal
@@ -89,6 +89,7 @@ Executable keysafe
Types.UI
UI
UI.Readline
+ UI.NonInteractive
UI.Zenity
source-repository head