Add manual signed peer card exchange
This commit is contained in:
parent
20c88af800
commit
1ab24631cd
14 changed files with 360 additions and 25 deletions
|
|
@ -28,6 +28,10 @@ pub enum Command {
|
|||
#[command(subcommand)]
|
||||
command: NodeCommand,
|
||||
},
|
||||
Peer {
|
||||
#[command(subcommand)]
|
||||
command: PeerCommand,
|
||||
},
|
||||
Resource {
|
||||
#[command(subcommand)]
|
||||
command: ResourceCommand,
|
||||
|
|
@ -123,6 +127,18 @@ pub enum NodeCommand {
|
|||
Status,
|
||||
}
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum PeerCommand {
|
||||
Export {
|
||||
#[arg(long)]
|
||||
out: Option<PathBuf>,
|
||||
},
|
||||
Import {
|
||||
path: PathBuf,
|
||||
},
|
||||
List,
|
||||
}
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum ResourceCommand {
|
||||
List,
|
||||
|
|
@ -431,6 +447,11 @@ fn request_for_command(command: Command) -> Result<ControlRequest> {
|
|||
Command::Node {
|
||||
command: NodeCommand::Status,
|
||||
} => ControlRequest::Status,
|
||||
Command::Peer { command } => match command {
|
||||
PeerCommand::Export { out } => ControlRequest::PeerCardExport { out },
|
||||
PeerCommand::Import { path } => ControlRequest::PeerCardImport { path },
|
||||
PeerCommand::List => ControlRequest::PeerCardList,
|
||||
},
|
||||
Command::Resource {
|
||||
command: ResourceCommand::List,
|
||||
} => ControlRequest::ResourceList,
|
||||
|
|
@ -721,6 +742,38 @@ fn print_response(response: ControlResponse, json: bool) -> Result<()> {
|
|||
.unwrap_or("not started in bootstrap")
|
||||
);
|
||||
}
|
||||
ControlResponse::PeerCardExported { card, out, note } => {
|
||||
println!("peer card: {}", card.node_id);
|
||||
println!("agent: {}", card.agent_id);
|
||||
println!("endpoints: {}", card.endpoints.len());
|
||||
if let Some(path) = out {
|
||||
println!("wrote: {}", path.display());
|
||||
} else {
|
||||
println!("{}", serde_json::to_string_pretty(&card)?);
|
||||
}
|
||||
println!("note: {note}");
|
||||
}
|
||||
ControlResponse::PeerCardImported { peer, note } => {
|
||||
println!("imported peer: {}", peer.card.node_id);
|
||||
println!("agent: {}", peer.card.agent_id);
|
||||
println!("trust: candidate-only");
|
||||
println!("note: {note}");
|
||||
}
|
||||
ControlResponse::PeerCardList { peers, note } => {
|
||||
if peers.is_empty() {
|
||||
println!("no peer candidates");
|
||||
} else {
|
||||
for peer in peers {
|
||||
println!(
|
||||
"{}\t{}\t{} endpoints\tcandidate-only",
|
||||
peer.card.node_id,
|
||||
peer.card.agent_id,
|
||||
peer.card.endpoints.len()
|
||||
);
|
||||
}
|
||||
}
|
||||
println!("note: {note}");
|
||||
}
|
||||
ControlResponse::ResourceList { resources } => {
|
||||
if resources.is_empty() {
|
||||
println!("no resources");
|
||||
|
|
|
|||
Loading…
Reference in a new issue