Skip to content

Commit

Permalink
write ProxyProtocolConfig in protobuf
Browse files Browse the repository at this point in the history
  • Loading branch information
Keksoj committed Apr 5, 2023
1 parent f434974 commit 6716f8a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 20 deletions.
6 changes: 3 additions & 3 deletions bin/src/ctl/request_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use anyhow::{bail, Context};

use sozu_command_lib::{
certificate::{calculate_fingerprint, split_certificate_chain, Fingerprint},
config::{Config, ListenerBuilder, ProxyProtocolConfig},
config::{Config, ListenerBuilder},
proto::command::{
AddCertificate, CertificateAndKey, FrontendFilters, PathRule, RemoveCertificate,
ReplaceCertificate, RequestHttpFrontend, RulePosition, TlsVersion,
AddCertificate, CertificateAndKey, FrontendFilters, PathRule, ProxyProtocolConfig,
RemoveCertificate, ReplaceCertificate, RequestHttpFrontend, RulePosition, TlsVersion,
},
request::{
ActivateListener, AddBackend, Cluster, DeactivateListener, ListenerType,
Expand Down
6 changes: 6 additions & 0 deletions command/src/command.proto
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,9 @@ enum LoadBalancingAlgorithms {
LEAST_LOADED = 2;
POWER_OF_TWO = 3;
}

enum ProxyProtocolConfig {
EXPECT_HEADER = 0;
SEND_HEADER = 1;
RELAY_HEADER = 2;
}
13 changes: 2 additions & 11 deletions command/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use toml;
use crate::{
certificate::split_certificate_chain,
proto::command::{
AddCertificate, CertificateAndKey, LoadBalancingAlgorithms, PathRule, RequestHttpFrontend,
RulePosition, TlsVersion,
AddCertificate, CertificateAndKey, LoadBalancingAlgorithms, PathRule, ProxyProtocolConfig,
RequestHttpFrontend, RulePosition, TlsVersion,
},
request::{
ActivateListener, AddBackend, Cluster, ListenerType, LoadBalancingParams, LoadMetric,
Expand Down Expand Up @@ -487,15 +487,6 @@ pub struct MetricsConfig {
pub prefix: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
#[serde(deny_unknown_fields)]
pub enum ProxyProtocolConfig {
ExpectHeader,
SendHeader,
RelayHeader,
}

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
#[serde(deny_unknown_fields)]
Expand Down
11 changes: 6 additions & 5 deletions command/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ use anyhow::Context;

use crate::{
certificate::Fingerprint,
config::ProxyProtocolConfig,
proto::command::{
AddCertificate, FrontendFilters, LoadBalancingAlgorithms, PathRuleKind, RemoveCertificate,
ReplaceCertificate, RequestHttpFrontend, RulePosition,
AddCertificate, FrontendFilters, LoadBalancingAlgorithms, PathRuleKind,
ProxyProtocolConfig, RemoveCertificate, ReplaceCertificate, RequestHttpFrontend,
RulePosition,
},
response::{
HttpFrontend, HttpListenerConfig, HttpsListenerConfig, MessageId, TcpListenerConfig,
Expand Down Expand Up @@ -425,8 +425,9 @@ mod tests {

use super::*;
use crate::certificate::split_certificate_chain;
use crate::config::ProxyProtocolConfig;
use crate::proto::command::{CertificateAndKey, PathRule, RulePosition, TlsVersion};
use crate::proto::command::{
CertificateAndKey, PathRule, ProxyProtocolConfig, RulePosition, TlsVersion,
};
use crate::response::HttpFrontend;
use serde_json;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ use crate::{
},
socket::server_bind,
sozu_command::{
config::ProxyProtocolConfig,
logging,
proto::command::ProxyProtocolConfig,
ready::Ready,
request::{Request, RequestTcpFrontend, WorkerRequest},
response::{Event, TcpListenerConfig, WorkerResponse},
Expand Down

0 comments on commit 6716f8a

Please sign in to comment.