Skip to content

Commit

Permalink
move QueryAnswerCertificate::All to ResponseContent::AllCertificates
Browse files Browse the repository at this point in the history
  • Loading branch information
Keksoj committed Mar 22, 2023
1 parent eb9b18e commit 3387628
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 25 deletions.
1 change: 1 addition & 0 deletions bin/src/ctl/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ impl CommandManager {
| ResponseContent::ClustersHashes(_)
| ResponseContent::Clusters(_)
| ResponseContent::Certificates(_)
| ResponseContent::AllCertificates(_)
| ResponseContent::AvailableMetrics(_)
| ResponseContent::Event(_) => {}
ResponseContent::State(state) => match json {
Expand Down
27 changes: 7 additions & 20 deletions bin/src/ctl/display.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use std::{
collections::{BTreeMap, HashMap, HashSet},
process::exit,
};
use std::collections::{BTreeMap, HashMap, HashSet};

use anyhow::{self, Context};
use prettytable::{Row, Table};
Expand Down Expand Up @@ -621,20 +618,9 @@ pub fn print_certificates(
return Ok(());
}

//println!("received: {:?}", data);
let it = response_contents.iter().map(|(k, v)| match v {
ResponseContent::Certificates(c) => (k, c),
v => {
eprintln!("unexpected certificates query answer: {v:?}");
exit(1);
}
});

for (k, v) in it {
println!("process '{k}':");

match v {
QueryAnswerCertificate::All(h) => {
for (_worker_id, response_content) in response_contents.iter() {
match response_content {
ResponseContent::AllCertificates(h) => {
for (addr, h2) in h.iter() {
println!("\t{addr}:");

Expand All @@ -645,7 +631,7 @@ pub fn print_certificates(
println!();
}
}
QueryAnswerCertificate::Domain(h) => {
ResponseContent::Certificates(QueryAnswerCertificate::Domain(h)) => {
for (addr, opt) in h.iter() {
println!("\t{addr}:");
if let Some((key, fingerprint)) = opt {
Expand All @@ -657,13 +643,14 @@ pub fn print_certificates(
println!();
}
}
QueryAnswerCertificate::Fingerprint(opt) => {
ResponseContent::Certificates(QueryAnswerCertificate::Fingerprint(opt)) => {
if let Some((s, v)) = opt {
println!("\tfrontends: {v:?}\ncertificate:\n{s}");
} else {
println!("\tnot found");
}
}
_ => {}
}
println!();
}
Expand Down
5 changes: 3 additions & 2 deletions command/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ pub enum ResponseContent {
/// cluster id -> hash of cluster information
ClustersHashes(BTreeMap<String, u64>),
Certificates(QueryAnswerCertificate),

/// returns a list of certificates: domain -> fingerprint
AllCertificates(HashMap<SocketAddr, BTreeMap<String, Vec<u8>>>),
}

#[derive(Default, Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
Expand All @@ -94,8 +97,6 @@ pub struct QueryAnswerCluster {

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum QueryAnswerCertificate {
/// returns a list of certificates: domain -> fingerprint
All(HashMap<SocketAddr, BTreeMap<String, Vec<u8>>>),
/// returns a fingerprint
Domain(HashMap<SocketAddr, Option<(String, Vec<u8>)>>),
/// returns the certificate
Expand Down
4 changes: 1 addition & 3 deletions lib/src/https.rs
Original file line number Diff line number Diff line change
Expand Up @@ -960,9 +960,7 @@ impl HttpsProxy {
certificates
);

Ok(Some(ResponseContent::Certificates(
QueryAnswerCertificate::All(certificates),
)))
Ok(Some(ResponseContent::AllCertificates(certificates)))
}

pub fn query_certificate_for_domain(
Expand Down

0 comments on commit 3387628

Please sign in to comment.