Skip to content

Commit

Permalink
create Request::QueryAllCertificates
Browse files Browse the repository at this point in the history
remove QueryCertificateType::All
  • Loading branch information
Keksoj committed Mar 22, 2023
1 parent a7e16f8 commit f514bce
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
10 changes: 4 additions & 6 deletions bin/src/ctl/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,22 +387,20 @@ impl CommandManager {
fingerprint: Option<String>,
domain: Option<String>,
) -> Result<(), anyhow::Error> {
let query = match (fingerprint, domain) {
(None, None) => QueryCertificateType::All,
let request = match (fingerprint, domain) {
(None, None) => Request::QueryAllCertificates,
(Some(f), None) => match hex::decode(f) {
Err(e) => {
bail!("invalid fingerprint: {:?}", e);
}
Ok(f) => QueryCertificateType::Fingerprint(f),
Ok(f) => Request::QueryCertificates(QueryCertificateType::Fingerprint(f)),
},
(None, Some(d)) => QueryCertificateType::Domain(d),
(None, Some(d)) => Request::QueryCertificates(QueryCertificateType::Domain(d)),
(Some(_), Some(_)) => {
bail!("Error: Either request a fingerprint or a domain name");
}
};

let request = Request::QueryCertificates(query);

self.send_request(request)?;

loop {
Expand Down
3 changes: 2 additions & 1 deletion command/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pub enum Request {
ActivateListener(ActivateListener),
DeactivateListener(DeactivateListener),

QueryAllCertificates,
QueryCertificates(QueryCertificateType),
QueryClusters(QueryClusterType),
QueryClustersHashes,
Expand Down Expand Up @@ -110,6 +111,7 @@ impl Request {
Request::AddHttpsFrontend(_)
| Request::RemoveHttpsFrontend(_)
| Request::AddCertificate(_)
| Request::QueryAllCertificates
| Request::ReplaceCertificate(_)
| Request::RemoveCertificate(_)
| Request::QueryCertificates(_) => proxy_destination.to_https_proxy = true,
Expand Down Expand Up @@ -384,7 +386,6 @@ pub struct QueryClusterDomain {
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(tag = "type", content = "data", rename_all = "SCREAMING_SNAKE_CASE")]
pub enum QueryCertificateType {
All,
Domain(String),
Fingerprint(Vec<u8>),
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/https.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,7 @@ impl ProxyConfiguration for HttpsProxy {
self.logging(logging_filter.clone())
.with_context(|| format!("Could not set logging level to {logging_filter}"))
}
Request::QueryCertificates(QueryCertificateType::All) => {
Request::QueryAllCertificates => {
info!("{} query all certificates", request_id);
self.query_all_certificates()
.with_context(|| "Could not query all certificates")
Expand Down
1 change: 0 additions & 1 deletion lib/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,6 @@ impl Server {
// forward the query to the TLS implementation
QueryCertificateType::Domain(_) => {}
// forward the query to the TLS implementation
QueryCertificateType::All => {}
QueryCertificateType::Fingerprint(f) => {
push_queue(WorkerResponse::ok_with_content(
message.id.clone(),
Expand Down

0 comments on commit f514bce

Please sign in to comment.