p2p --pair with magic wormhole (untested)

It builds. I have not tried to run it yet. :)

This commit was sponsored by Jake Vosloo on Patreon.
This commit is contained in:
Joey Hess 2016-12-18 16:50:58 -04:00
parent b2b6296f9d
commit ccde0932a5
No known key found for this signature in database
GPG key ID: C910D9222512E3C7
8 changed files with 288 additions and 79 deletions

View file

@ -5,9 +5,11 @@
- License: BSD-2-clause
-}
module Utility.MagicWormHole (
module Utility.MagicWormhole (
Code,
mkCode,
toCode,
fromCode,
validCode,
CodeObserver,
CodeProducer,
@ -32,9 +34,11 @@ import System.Exit
import Control.Concurrent
import Control.Exception
import Data.Char
import Data.List
-- | A Magic Wormhole code.
newtype Code = Code String
deriving (Eq, Show)
-- | Smart constructor for Code
mkCode :: String -> Maybe Code
@ -42,6 +46,13 @@ mkCode s
| validCode s = Just (Code s)
| otherwise = Nothing
-- | Tries to fix up some common mistakes in a homan-entered code.
toCode :: String -> Maybe Code
toCode s = mkCode $ intercalate "-" $ words s
fromCode :: Code -> String
fromCode (Code s) = s
-- | Codes have the form number-word-word and may contain 2 or more words.
validCode :: String -> Bool
validCode s =