diff --git a/radicle-node/src/control.rs b/radicle-node/src/control.rs index 2fb2542c..7ed48c7c 100644 --- a/radicle-node/src/control.rs +++ b/radicle-node/src/control.rs @@ -90,7 +90,12 @@ fn command>( match cmd.name { CommandName::Connect => { - todo!(); + let (nid, addr) = parse::args(cmd)?; + if let Err(e) = handle.connect(nid, addr) { + return Err(CommandError::Runtime(e)); + } else { + CommandResult::Okay { updated: true }.to_writer(writer)?; + } } CommandName::Fetch => { let (rid, nid): (Id, NodeId) = parse::args(cmd)?; diff --git a/radicle/src/node.rs b/radicle/src/node.rs index 495cab54..95809eed 100644 --- a/radicle/src/node.rs +++ b/radicle/src/node.rs @@ -479,8 +479,13 @@ impl Handle for Node { matches!(result, CommandResult::Okay { .. }) } - fn connect(&mut self, _node: NodeId, _addr: Address) -> Result<(), Error> { - todo!() + fn connect(&mut self, nid: NodeId, addr: Address) -> Result<(), Error> { + self.call::<_, CommandResult>(CommandName::Connect, [nid.to_human(), addr.to_string()])? + .next() + .ok_or(Error::EmptyResponse { + cmd: CommandName::Connect, + })??; + Ok(()) } fn seeds(&mut self, id: Id) -> Result {