remote uuid discovery in p2p --link
This also tests that we can connect to the peer. This commit was sponsored by Jeff Goeke-Smith on Patreon.
This commit is contained in:
parent
729e864ad0
commit
0d9a11625c
2 changed files with 23 additions and 8 deletions
|
@ -10,10 +10,15 @@ module Command.P2P where
|
||||||
import Command
|
import Command
|
||||||
import P2P.Address
|
import P2P.Address
|
||||||
import P2P.Auth
|
import P2P.Auth
|
||||||
|
import P2P.IO
|
||||||
|
import qualified P2P.Protocol as P2P
|
||||||
import Utility.AuthToken
|
import Utility.AuthToken
|
||||||
import Git.Types
|
import Git.Types
|
||||||
import qualified Git.Remote
|
import qualified Git.Remote
|
||||||
import qualified Git.Command
|
import qualified Git.Command
|
||||||
|
import qualified Annex
|
||||||
|
import Annex.UUID
|
||||||
|
import Config
|
||||||
|
|
||||||
cmd :: Command
|
cmd :: Command
|
||||||
cmd = command "p2p" SectionSetup
|
cmd = command "p2p" SectionSetup
|
||||||
|
@ -61,7 +66,7 @@ linkRemote remotename = do
|
||||||
where
|
where
|
||||||
prompt = do
|
prompt = do
|
||||||
liftIO $ putStrLn ""
|
liftIO $ putStrLn ""
|
||||||
liftIO $ putStr "Enter address: "
|
liftIO $ putStr "Enter peer address: "
|
||||||
liftIO $ hFlush stdout
|
liftIO $ hFlush stdout
|
||||||
s <- liftIO getLine
|
s <- liftIO getLine
|
||||||
if null s
|
if null s
|
||||||
|
@ -74,9 +79,20 @@ linkRemote remotename = do
|
||||||
prompt
|
prompt
|
||||||
Just addr -> setup addr
|
Just addr -> setup addr
|
||||||
setup (P2PAddressAuth addr authtoken) = do
|
setup (P2PAddressAuth addr authtoken) = do
|
||||||
storeP2PRemoteAuthToken addr authtoken
|
g <- Annex.gitRepo
|
||||||
inRepo $ Git.Command.runBool
|
conn <- liftIO $ connectPeer g addr
|
||||||
[ Param "remote", Param "add"
|
`catchNonAsync` giveup "Unable to connect with peer. Please check that the peer is connected to the network, and try again."
|
||||||
, Param remotename
|
u <- getUUID
|
||||||
, Param (formatP2PAddress addr)
|
v <- liftIO $ runNetProto conn $ P2P.auth u authtoken
|
||||||
]
|
case v of
|
||||||
|
Just (Just theiruuid) -> do
|
||||||
|
ok <- inRepo $ Git.Command.runBool
|
||||||
|
[ Param "remote", Param "add"
|
||||||
|
, Param remotename
|
||||||
|
, Param (formatP2PAddress addr)
|
||||||
|
]
|
||||||
|
when ok $ do
|
||||||
|
storeUUIDIn (remoteConfig remotename "uuid") theiruuid
|
||||||
|
storeP2PRemoteAuthToken addr authtoken
|
||||||
|
return ok
|
||||||
|
_ -> giveup "Unable to authenticate with peer. Please check the address and try again."
|
||||||
|
|
|
@ -4,7 +4,6 @@ Mostly working!
|
||||||
|
|
||||||
Current todo list:
|
Current todo list:
|
||||||
|
|
||||||
* uuid discovery in p2p link
|
|
||||||
* copy --to peer seems to make the remotedaemon buffer the content in
|
* copy --to peer seems to make the remotedaemon buffer the content in
|
||||||
memory, more than I'd expect.
|
memory, more than I'd expect.
|
||||||
* update progress meters
|
* update progress meters
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue