Rename sq network lookup to fetch, align network commands.

- Fixes #157.
This commit is contained in:
Justus Winter 2024-01-16 13:04:41 +01:00
parent 6a4f32e493
commit 59b0b2a543
No known key found for this signature in database
GPG Key ID: 686F55B4AB2B3386
6 changed files with 33 additions and 33 deletions

View File

@ -4,7 +4,7 @@ use clap::{Parser, Subcommand};
pub mod dane; pub mod dane;
pub mod keyserver; pub mod keyserver;
pub mod lookup; pub mod fetch;
pub mod wkd; pub mod wkd;
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
@ -28,7 +28,7 @@ pub struct Command {
#[derive(Debug, Subcommand)] #[derive(Debug, Subcommand)]
pub enum Subcommands { pub enum Subcommands {
Lookup(lookup::Command), Fetch(fetch::Command),
Keyserver(keyserver::Command), Keyserver(keyserver::Command),
Wkd(wkd::Command), Wkd(wkd::Command),
Dane(dane::Command), Dane(dane::Command),

View File

@ -23,7 +23,7 @@ pub struct Command {
#[derive(Debug, Subcommand)] #[derive(Debug, Subcommand)]
pub enum Subcommands { pub enum Subcommands {
Generate(GenerateCommand), Generate(GenerateCommand),
Get(GetCommand), Fetch(FetchCommand),
} }
#[derive(Debug, Args)] #[derive(Debug, Args)]
@ -91,15 +91,15 @@ pub struct GenerateCommand {
#[derive(Debug, Args)] #[derive(Debug, Args)]
#[clap( #[clap(
about = "Looks up certificates using DANE", about = "Retrieves certificates using DANE",
long_about = long_about =
"Looks up certificates using DANE "Retrieves certificates using DANE
By default, any returned certificates are stored in the local By default, any returned certificates are stored in the local
certificate store. This can be overridden by using `--output` certificate store. This can be overridden by using `--output`
option. option.
When a certificate is downloaded using DANE, and imported into the When a certificate is retrieved using DANE, and imported into the
local certificate store, any User IDs with the email address that was local certificate store, any User IDs with the email address that was
looked up are certificated with a local DANE-specific key. That proxy looked up are certificated with a local DANE-specific key. That proxy
certificate is in turn certified as a minimally trusted CA (trust certificate is in turn certified as a minimally trusted CA (trust
@ -108,7 +108,7 @@ is trusted can be tuned using `sq link add` or `sq link retract`
in the usual way. in the usual way.
" "
)] )]
pub struct GetCommand { pub struct FetchCommand {
#[clap( #[clap(
value_name = "ADDRESS", value_name = "ADDRESS",
required = true, required = true,

View File

@ -7,10 +7,10 @@ use super::keyserver::DEFAULT_KEYSERVERS;
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
#[clap( #[clap(
name = "lookup", name = "fetch",
about = "Searches for certificates using all supported network services.", about = "Retrieves certificates using all supported network services",
long_about = long_about =
"Searches for certificates using all supported network services. "Retrieves certificates using all supported network services
By default, any returned certificates are stored in the local By default, any returned certificates are stored in the local
certificate store. This can be overridden by using `--output` certificate store. This can be overridden by using `--output`

View File

@ -39,21 +39,21 @@ pub struct Command {
#[derive(Debug, Subcommand)] #[derive(Debug, Subcommand)]
pub enum Subcommands { pub enum Subcommands {
Get(GetCommand), Fetch(FetchCommand),
Send(SendCommand), Publish(PublishCommand),
} }
#[derive(Debug, Args)] #[derive(Debug, Args)]
#[clap( #[clap(
about = "Retrieves a certificate", about = "Retrieves certificates from key servers",
long_about = long_about =
"Retrieves a certificate from a keyserver. "Retrieves certificates from key servers
By default, any returned certificates are stored in the local By default, any returned certificates are stored in the local
certificate store. This can be overridden by using `--output` certificate store. This can be overridden by using `--output`
option. option.
When a certificate is downloaded from a verifying keyserver When a certificate is retrieved from a verifying keyserver
(currently, this is limited to a list of known servers: (currently, this is limited to a list of known servers:
keys.openpgp.org, keys.mailvelope.com, and mail-api.proton.me), and keys.openpgp.org, keys.mailvelope.com, and mail-api.proton.me), and
imported into the local certificate store, the User IDs are also imported into the local certificate store, the User IDs are also
@ -64,7 +64,7 @@ trusted can be tuned using `sq link add` or `sq link retract` in
the usual way. the usual way.
" "
)] )]
pub struct GetCommand { pub struct FetchCommand {
#[clap( #[clap(
help = FileOrCertStore::HELP_OPTIONAL, help = FileOrCertStore::HELP_OPTIONAL,
long, long,
@ -90,14 +90,14 @@ pub struct GetCommand {
#[derive(Debug, Args)] #[derive(Debug, Args)]
#[clap( #[clap(
about = "Sends a key", about = "Publishes certificates",
)] )]
pub struct SendCommand { pub struct PublishCommand {
#[clap( #[clap(
long, long,
help = "Requires that all send operations succeed \ help = "Requires that all publish operations succeed \
and return an error otherwise. \ and return an error otherwise. \
By default we only require that one send \ By default we only require that one publish \
operation succeeds.", operation succeeds.",
)] )]
pub require_all: bool, pub require_all: bool,

View File

@ -22,7 +22,7 @@ pub struct Command {
#[derive(Debug, Subcommand)] #[derive(Debug, Subcommand)]
pub enum Subcommands { pub enum Subcommands {
Generate(GenerateCommand), Generate(GenerateCommand),
Get(GetCommand), Fetch(FetchCommand),
DirectUrl(DirectUrlCommand), DirectUrl(DirectUrlCommand),
Url(UrlCommand), Url(UrlCommand),
} }
@ -53,15 +53,15 @@ pub struct DirectUrlCommand {
#[derive(Debug, Args)] #[derive(Debug, Args)]
#[clap( #[clap(
about = "Looks up certificates in a Web Key Directory", about = "Retrieves certificates from a Web Key Directory",
long_about = long_about =
"Looks up certificates in a Web Key Directory "Retrieves certificates from a Web Key Directory
By default, any returned certificates are stored in the local By default, any returned certificates are stored in the local
certificate store. This can be overridden by using `--output` certificate store. This can be overridden by using `--output`
option. option.
When a certificate is downloaded from a WKD, and imported into the When a certificate is retrieved from a WKD, and imported into the
local certificate store, any User IDs with the email address that was local certificate store, any User IDs with the email address that was
looked up are certificated with a local WKD-specific key. That proxy looked up are certificated with a local WKD-specific key. That proxy
certificate is in turn certified as a minimally trusted CA (trust certificate is in turn certified as a minimally trusted CA (trust
@ -70,7 +70,7 @@ is trusted can be tuned using `sq link add` or `sq link retract`
in the usual way. in the usual way.
" "
)] )]
pub struct GetCommand { pub struct FetchCommand {
#[clap( #[clap(
value_name = "ADDRESS", value_name = "ADDRESS",
required = true, required = true,

View File

@ -61,8 +61,8 @@ pub fn dispatch(config: Config, c: cli::network::Command)
{ {
use cli::network::Subcommands; use cli::network::Subcommands;
match c.subcommand { match c.subcommand {
Subcommands::Lookup(command) => Subcommands::Fetch(command) =>
dispatch_lookup(config, command), dispatch_fetch(config, command),
Subcommands::Keyserver(command) => Subcommands::Keyserver(command) =>
dispatch_keyserver(config, command), dispatch_keyserver(config, command),
@ -551,8 +551,8 @@ impl Response {
} }
} }
pub fn dispatch_lookup(config: Config, c: cli::network::lookup::Command) pub fn dispatch_fetch(config: Config, c: cli::network::fetch::Command)
-> Result<()> -> Result<()>
{ {
let default_servers = default_keyservers_p(&c.servers); let default_servers = default_keyservers_p(&c.servers);
let servers = c.servers.iter().map( let servers = c.servers.iter().map(
@ -688,7 +688,7 @@ pub fn dispatch_keyserver(config: Config, c: cli::network::keyserver::Command)
use crate::cli::network::keyserver::Subcommands::*; use crate::cli::network::keyserver::Subcommands::*;
match c.subcommand { match c.subcommand {
Get(c) => rt.block_on(async { Fetch(c) => rt.block_on(async {
let queries = Query::parse(&c.query)?; let queries = Query::parse(&c.query)?;
let mut requests = tokio::task::JoinSet::new(); let mut requests = tokio::task::JoinSet::new();
@ -714,7 +714,7 @@ pub fn dispatch_keyserver(config: Config, c: cli::network::keyserver::Command)
config, c.output, c.binary, requests, default_servers).await?; config, c.output, c.binary, requests, default_servers).await?;
Result::Ok(()) Result::Ok(())
})?, })?,
Send(c) => rt.block_on(async { Publish(c) => rt.block_on(async {
let mut input = c.input.open()?; let mut input = c.input.open()?;
let cert = Arc::new(Cert::from_reader(&mut input). let cert = Arc::new(Cert::from_reader(&mut input).
context("Malformed key")?); context("Malformed key")?);
@ -802,7 +802,7 @@ pub fn dispatch_wkd(config: Config, c: cli::network::wkd::Command) -> Result<()>
WkdUrlVariant::Direct, advanced, direct)?; WkdUrlVariant::Direct, advanced, direct)?;
output.write(config.output_format, &mut std::io::stdout())?; output.write(config.output_format, &mut std::io::stdout())?;
}, },
Get(c) => rt.block_on(async { Fetch(c) => rt.block_on(async {
let queries = Query::parse_addresses(&c.addresses)?; let queries = Query::parse_addresses(&c.addresses)?;
let mut requests = tokio::task::JoinSet::new(); let mut requests = tokio::task::JoinSet::new();
queries.into_iter().for_each(|query| { queries.into_iter().for_each(|query| {
@ -895,7 +895,7 @@ pub fn dispatch_dane(config: Config, c: cli::network::dane::Command) -> Result<(
} }
} }
}, },
Get(c) => rt.block_on(async { Fetch(c) => rt.block_on(async {
let queries = Query::parse_addresses(&c.addresses)?; let queries = Query::parse_addresses(&c.addresses)?;
let mut requests = tokio::task::JoinSet::new(); let mut requests = tokio::task::JoinSet::new();
queries.into_iter().for_each(|query| { queries.into_iter().for_each(|query| {