2016-11-14 17:26:34 +00:00
|
|
|
{- 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
|
|
|
|
|
2016-11-14 20:35:45 +00:00
|
|
|
-- This runs as root, so avoid making any commits or initializing
|
|
|
|
-- git-annex, as that would create root-owned files.
|
2016-11-14 17:26:34 +00:00
|
|
|
cmd :: Command
|
|
|
|
cmd = noCommit $ dontCheck repoExists $
|
2016-11-20 18:39:26 +00:00
|
|
|
command "enable-tor" SectionSetup ""
|
2016-11-14 20:35:45 +00:00
|
|
|
"userid uuid" (withParams seek)
|
2016-11-14 17:26:34 +00:00
|
|
|
|
|
|
|
seek :: CmdParams -> CommandSeek
|
|
|
|
seek = withWords start
|
|
|
|
|
|
|
|
start :: CmdParams -> CommandStart
|
2016-11-14 20:35:45 +00:00
|
|
|
start (suserid:uuid:[]) = case readish suserid of
|
|
|
|
Nothing -> error "Bad userid"
|
|
|
|
Just userid -> do
|
2016-11-21 21:27:38 +00:00
|
|
|
(OnionAddress onionaddr, onionport) <- liftIO $
|
2016-11-14 20:35:45 +00:00
|
|
|
addHiddenService userid uuid
|
2016-11-21 21:27:38 +00:00
|
|
|
liftIO $ putStrLn $
|
|
|
|
"tor-annex::" ++
|
2016-11-14 20:35:45 +00:00
|
|
|
onionaddr ++ ":" ++
|
2016-11-21 21:27:38 +00:00
|
|
|
show onionport ++ " "
|
2016-11-14 17:26:34 +00:00
|
|
|
stop
|
2016-11-14 20:35:45 +00:00
|
|
|
start _ = error "Bad params"
|