Skip to content

Commit

Permalink
write ListenerType in protobuf
Browse files Browse the repository at this point in the history
  • Loading branch information
Keksoj committed Apr 5, 2023
1 parent bd6d535 commit 7617b34
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 94 deletions.
22 changes: 11 additions & 11 deletions bin/src/ctl/request_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ use sozu_command_lib::{
certificate::{calculate_fingerprint, split_certificate_chain, Fingerprint},
config::{Config, ListenerBuilder},
proto::command::{
AddBackend, AddCertificate, CertificateAndKey, Cluster, FrontendFilters,
AddBackend, AddCertificate, CertificateAndKey, Cluster, FrontendFilters, ListenerType,
LoadBalancingParams, MetricsConfiguration, PathRule, ProxyProtocolConfig, RemoveBackend,
RemoveCertificate, ReplaceCertificate, RequestHttpFrontend, RequestTcpFrontend,
RulePosition, TlsVersion,
},
request::{ActivateListener, DeactivateListener, ListenerType, RemoveListener, Request},
request::{ActivateListener, DeactivateListener, RemoveListener, Request},
};

use crate::{
Expand Down Expand Up @@ -310,13 +310,13 @@ impl CommandManager {
self.order_request(Request::AddHttpsListener(https_listener))
}
HttpsListenerCmd::Remove { address } => {
self.remove_listener(address.to_string(), ListenerType::HTTPS)
self.remove_listener(address.to_string(), ListenerType::Https)
}
HttpsListenerCmd::Activate { address } => {
self.activate_listener(address.to_string(), ListenerType::HTTPS)
self.activate_listener(address.to_string(), ListenerType::Https)
}
HttpsListenerCmd::Deactivate { address } => {
self.deactivate_listener(address.to_string(), ListenerType::HTTPS)
self.deactivate_listener(address.to_string(), ListenerType::Https)
}
}
}
Expand Down Expand Up @@ -350,13 +350,13 @@ impl CommandManager {
self.order_request(Request::AddHttpListener(http_listener))
}
HttpListenerCmd::Remove { address } => {
self.remove_listener(address.to_string(), ListenerType::HTTP)
self.remove_listener(address.to_string(), ListenerType::Http)
}
HttpListenerCmd::Activate { address } => {
self.activate_listener(address.to_string(), ListenerType::HTTP)
self.activate_listener(address.to_string(), ListenerType::Http)
}
HttpListenerCmd::Deactivate { address } => {
self.deactivate_listener(address.to_string(), ListenerType::HTTP)
self.deactivate_listener(address.to_string(), ListenerType::Http)
}
}
}
Expand All @@ -377,13 +377,13 @@ impl CommandManager {
self.order_request(Request::AddTcpListener(listener))
}
TcpListenerCmd::Remove { address } => {
self.remove_listener(address.to_string(), ListenerType::TCP)
self.remove_listener(address.to_string(), ListenerType::Tcp)
}
TcpListenerCmd::Activate { address } => {
self.activate_listener(address.to_string(), ListenerType::TCP)
self.activate_listener(address.to_string(), ListenerType::Tcp)
}
TcpListenerCmd::Deactivate { address } => {
self.deactivate_listener(address.to_string(), ListenerType::TCP)
self.deactivate_listener(address.to_string(), ListenerType::Tcp)
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions command/src/command.proto
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ message TcpListenerConfig {
required bool active = 7 [default = false];
}

enum ListenerType {
HTTP = 0;
HTTPS = 1;
TCP = 2;
}

// All listeners, listed
message ListenersList {
// address -> http listener config
Expand Down
14 changes: 7 additions & 7 deletions command/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ use crate::{
certificate::split_certificate_chain,
proto::command::{
AddBackend, AddCertificate, CertificateAndKey, Cluster, HttpListenerConfig,
HttpsListenerConfig, LoadBalancingAlgorithms, LoadBalancingParams, LoadMetric, PathRule,
ProxyProtocolConfig, RequestHttpFrontend, RequestTcpFrontend, RulePosition,
TcpListenerConfig, TlsVersion,
HttpsListenerConfig, ListenerType, LoadBalancingAlgorithms, LoadBalancingParams,
LoadMetric, PathRule, ProxyProtocolConfig, RequestHttpFrontend, RequestTcpFrontend,
RulePosition, TcpListenerConfig, TlsVersion,
},
request::{ActivateListener, ListenerType, Request, WorkerRequest},
request::{ActivateListener, Request, WorkerRequest},
};

/// [`DEFAULT_RUSTLS_CIPHER_LIST`] provides all supported cipher suites exported by Rustls TLS
Expand Down Expand Up @@ -1360,7 +1360,7 @@ impl Config {
id: format!("CONFIG-{count}"),
content: Request::ActivateListener(ActivateListener {
address: listener.address.clone(),
proxy: ListenerType::HTTP,
proxy: ListenerType::Http,
from_scm: false,
}),
});
Expand All @@ -1372,7 +1372,7 @@ impl Config {
id: format!("CONFIG-{count}"),
content: Request::ActivateListener(ActivateListener {
address: listener.address.clone(),
proxy: ListenerType::HTTPS,
proxy: ListenerType::Https,
from_scm: false,
}),
});
Expand All @@ -1384,7 +1384,7 @@ impl Config {
id: format!("CONFIG-{count}"),
content: Request::ActivateListener(ActivateListener {
address: listener.address.clone(),
proxy: ListenerType::TCP,
proxy: ListenerType::Tcp,
from_scm: false,
}),
});
Expand Down
12 changes: 2 additions & 10 deletions command/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use crate::{
certificate::Fingerprint,
proto::command::{
AddBackend, AddCertificate, Cluster, FrontendFilters, HttpListenerConfig,
HttpsListenerConfig, LoadBalancingAlgorithms, MetricsConfiguration, PathRuleKind,
QueryClusterByDomain, QueryMetricsOptions, RemoveBackend, RemoveCertificate,
HttpsListenerConfig, ListenerType, LoadBalancingAlgorithms, MetricsConfiguration,
PathRuleKind, QueryClusterByDomain, QueryMetricsOptions, RemoveBackend, RemoveCertificate,
ReplaceCertificate, RequestHttpFrontend, RequestTcpFrontend, RulePosition,
TcpListenerConfig,
},
Expand Down Expand Up @@ -212,14 +212,6 @@ pub fn default_sticky_name() -> String {
String::from("SOZUBALANCEID")
}

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum ListenerType {
HTTP,
HTTPS,
TCP,
}

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct RemoveListener {
pub address: String,
Expand Down

0 comments on commit 7617b34

Please sign in to comment.