diff options
Diffstat (limited to 'Command/EnableTor.hs')
-rw-r--r-- | Command/EnableTor.hs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Command/EnableTor.hs b/Command/EnableTor.hs new file mode 100644 index 000000000..8d9dd6f0a --- /dev/null +++ b/Command/EnableTor.hs @@ -0,0 +1,28 @@ +{- git-annex command + - + - Copyright 2016 Joey Hess <id@joeyh.name> + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Command.EnableTor where + +import Command +import Utility.Tor + +cmd :: Command +cmd = noCommit $ dontCheck repoExists $ + command "enable-tor" SectionPlumbing "" + paramNumber (withParams seek) + +seek :: CmdParams -> CommandSeek +seek = withWords start + +start :: CmdParams -> CommandStart +start (localport:[]) = case readish localport of + Nothing -> error "Bad localport" + Just lp -> do + (onionaddr, onionport) <- liftIO $ addHiddenService lp + liftIO $ putStrLn (onionaddr ++ ":" ++ show onionport) + stop +start _ = error "Need 1 localport parameter" |