Skip to content

Commit

Permalink
rename HttpFront to HttpFrontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Geal authored and FlorentinDUBOIS committed Jul 13, 2022
1 parent 5dc5c00 commit 270bfee
Show file tree
Hide file tree
Showing 19 changed files with 166 additions and 168 deletions.
20 changes: 10 additions & 10 deletions bin/src/command/orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use sozu_command::command::{
use sozu_command::proxy::Route;
use sozu_command::logging;
use sozu_command::proxy::{
AggregatedMetricsData, MetricsData, ProxyRequestData, ProxyResponseData,
ProxyResponseStatus, Query, QueryAnswer, QueryApplicationType, TcpFront,
AggregatedMetricsData, HttpFrontend, MetricsData, ProxyRequestData, ProxyResponseData,
ProxyResponseStatus, Query, QueryAnswer, QueryApplicationType, TcpFrontend,
ProxyRequest,
};
use sozu_command::scm_socket::Listeners;
Expand Down Expand Up @@ -1061,7 +1061,7 @@ impl CommandServer {
self.answer_error(client_id, request_id, msg, None).await;
return;
}
ProxyRequestData::RemoveHttpFront(h) | ProxyRequestData::RemoveHttpsFront(h) => {
ProxyRequestData::RemoveHttpFrontend(h) | ProxyRequestData::RemoveHttpsFrontend(h) => {
let msg = match h.route {
Route::AppId(app_id) => format!("No such frontend at {} for the application {}", h.address, app_id),
Route::Deny => format!("No such frontend at {}", h.address),
Expand All @@ -1070,7 +1070,7 @@ impl CommandServer {
self.answer_error(client_id, request_id, msg, None).await;
return;
}
ProxyRequestData::RemoveTcpFront(TcpFront {
ProxyRequestData::RemoveTcpFrontend(TcpFrontend {
ref app_id,
ref address,
}) => {
Expand Down Expand Up @@ -1217,12 +1217,12 @@ impl CommandServer {
ProxyRequestData::AddBackend(_) | ProxyRequestData::RemoveBackend(_) => {
self.backends_count = self.state.count_backends()
}
ProxyRequestData::AddHttpFront(_)
| ProxyRequestData::AddHttpsFront(_)
| ProxyRequestData::AddTcpFront(_)
| ProxyRequestData::RemoveHttpFront(_)
| ProxyRequestData::RemoveHttpsFront(_)
| ProxyRequestData::RemoveTcpFront(_) => {
ProxyRequestData::AddHttpFrontend(_)
| ProxyRequestData::AddHttpsFrontend(_)
| ProxyRequestData::AddTcpFrontend(_)
| ProxyRequestData::RemoveHttpFrontend(_)
| ProxyRequestData::RemoveHttpsFrontend(_)
| ProxyRequestData::RemoveTcpFrontend(_) => {
self.frontends_count = self.state.count_frontends()
}
_ => {}
Expand Down
20 changes: 10 additions & 10 deletions bin/src/ctl/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use sozu_command::config::{Config, ProxyProtocolConfig, Listener, FileListenerPr
use sozu_command::channel::Channel;
use sozu_command::certificate::{calculate_fingerprint,split_certificate_chain};
use sozu_command::command::{CommandResponseData,CommandRequestData,CommandRequest,CommandResponse,CommandStatus,RunState,WorkerInfo};
use sozu_command::proxy::{Application, ProxyRequestData, Backend, HttpFront,
TcpFront, CertificateAndKey, CertFingerprint, Query, QueryAnswer,
use sozu_command::proxy::{Application, ProxyRequestData, Backend, HttpFrontend,
TcpFrontend, CertificateAndKey, CertFingerprint, Query, QueryAnswer,
QueryApplicationType, QueryApplicationDomain, FilteredData, AddCertificate,
RemoveCertificate, ReplaceCertificate, LoadBalancingParams, RemoveBackend,
TcpListener, ListenerType, TlsVersion, QueryCertificateType,
Expand Down Expand Up @@ -1012,15 +1012,15 @@ pub fn add_http_frontend(channel: Channel<CommandRequest,CommandResponse>,
https: bool)
-> Result<(), anyhow::Error> {
if https {
order_command(channel, timeout, ProxyRequestData::AddHttpsFront(HttpFront {
order_command(channel, timeout, ProxyRequestData::AddHttpsFrontend(HttpFrontend {
route,
address,
hostname: String::from(hostname),
path: PathRule::Prefix(String::from(path)),
position: RulePosition::Tree,
}))
} else {
order_command(channel, timeout, ProxyRequestData::AddHttpFront(HttpFront {
order_command(channel, timeout, ProxyRequestData::AddHttpFrontend(HttpFrontend {
route,
address,
hostname: String::from(hostname),
Expand All @@ -1035,15 +1035,15 @@ pub fn remove_http_frontend(channel: Channel<CommandRequest,CommandResponse>,
https: bool)
-> Result<(), anyhow::Error> {
if https {
order_command(channel, timeout, ProxyRequestData::RemoveHttpsFront(HttpFront {
order_command(channel, timeout, ProxyRequestData::RemoveHttpsFrontend(HttpFrontend {
route,
address,
hostname: String::from(hostname),
path: PathRule::Prefix(String::from(path)),
position: RulePosition::Tree,
}))
} else {
order_command(channel, timeout, ProxyRequestData::RemoveHttpFront(HttpFront {
order_command(channel, timeout, ProxyRequestData::RemoveHttpFrontend(HttpFrontend {
route,
address,
hostname: String::from(hostname),
Expand Down Expand Up @@ -1160,15 +1160,15 @@ pub fn replace_certificate(channel: Channel<CommandRequest,CommandResponse>, tim

pub fn add_tcp_frontend(channel: Channel<CommandRequest,CommandResponse>, timeout: u64, app_id: &str,
address: SocketAddr) -> Result<(), anyhow::Error> {
order_command(channel, timeout, ProxyRequestData::AddTcpFront(TcpFront {
order_command(channel, timeout, ProxyRequestData::AddTcpFrontend(TcpFrontend {
app_id: String::from(app_id),
address,
}))
}

pub fn remove_tcp_frontend(channel: Channel<CommandRequest,CommandResponse>, timeout: u64, app_id: &str,
address: SocketAddr) -> Result<(), anyhow::Error> {
order_command(channel, timeout, ProxyRequestData::RemoveTcpFront(TcpFront {
order_command(channel, timeout, ProxyRequestData::RemoveTcpFrontend(TcpFrontend {
app_id: String::from(app_id),
address,
}))
Expand Down Expand Up @@ -1722,8 +1722,8 @@ fn order_command(mut channel: Channel<CommandRequest,CommandResponse>, timeout:
ProxyRequestData::RemoveBackend(_) => println!("backend removed : {} ", message.message),
ProxyRequestData::AddCertificate(_) => println!("certificate added: {}", message.message),
ProxyRequestData::RemoveCertificate(_) => println!("certificate removed: {}", message.message),
ProxyRequestData::AddHttpFront(_) => println!("front added: {}", message.message),
ProxyRequestData::RemoveHttpFront(_) => println!("front removed: {}", message.message),
ProxyRequestData::AddHttpFrontend(_) => println!("front added: {}", message.message),
ProxyRequestData::RemoveHttpFrontend(_) => println!("front removed: {}", message.message),
_ => {
// do nothing for now
}
Expand Down
2 changes: 1 addition & 1 deletion command/assets/add_http_front.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": 0,
"type": "PROXY",
"data": {
"type": "ADD_HTTP_FRONT",
"type": "ADD_HTTP_FRONTEND",
"data": {
"route": {
"APP_ID": "xxx"
Expand Down
2 changes: 1 addition & 1 deletion command/assets/add_https_front.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": 0,
"type": "PROXY",
"data": {
"type": "ADD_HTTPS_FRONT",
"type": "ADD_HTTPS_FRONTEND",
"data": {
"route": {
"APP_ID": "xxx"
Expand Down
2 changes: 1 addition & 1 deletion command/assets/remove_http_front.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": 0,
"type": "PROXY",
"data": {
"type": "REMOVE_HTTP_FRONT",
"type": "REMOVE_HTTP_FRONTEND",
"data": {
"route": {
"APP_ID": "xxx"
Expand Down
2 changes: 1 addition & 1 deletion command/assets/remove_https_front.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": 0,
"type": "PROXY",
"data": {
"type": "REMOVE_HTTPS_FRONT",
"type": "REMOVE_HTTPS_FRONTEND",
"data": {
"route": {
"APP_ID": "xxx"
Expand Down
14 changes: 7 additions & 7 deletions command/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,18 @@ mod tests {
use serde_json;
use hex::FromHex;
use crate::certificate::split_certificate_chain;
use crate::proxy::{Application,CertificateAndKey,CertFingerprint,ProxyRequestData,HttpFront,Backend,
use crate::proxy::{Application,CertificateAndKey,CertFingerprint,ProxyRequestData,HttpFrontend,Backend,
AppMetricsData,MetricsData,FilteredData,Percentiles,RemoveBackend,
AddCertificate,RemoveCertificate,LoadBalancingParams,TlsVersion,
LoadBalancingAlgorithms, RulePosition,PathRule, Route};
use crate::config::ProxyProtocolConfig;

#[test]
fn config_message_test() {
let raw_json = r#"{ "id": "ID_TEST", "version": 0, "type": "PROXY", "data":{"type": "ADD_HTTP_FRONT", "data": { "route": {"APP_ID": "xxx"}, "hostname": "yyy", "path": {"PREFIX": "xxx"}, "address": "0.0.0.0:8080"}} }"#;
let raw_json = r#"{ "id": "ID_TEST", "version": 0, "type": "PROXY", "data":{"type": "ADD_HTTP_FRONTEND", "data": { "route": {"APP_ID": "xxx"}, "hostname": "yyy", "path": {"PREFIX": "xxx"}, "address": "0.0.0.0:8080"}} }"#;
let message: CommandRequest = serde_json::from_str(raw_json).unwrap();
println!("{:?}", message);
assert_eq!(message.data, CommandRequestData::Proxy(ProxyRequestData::AddHttpFront(HttpFront{
assert_eq!(message.data, CommandRequestData::Proxy(ProxyRequestData::AddHttpFrontend(HttpFrontend{
route: Route::AppId(String::from("xxx")),
hostname: String::from("yyy"),
path: PathRule::Prefix(String::from("xxx")),
Expand Down Expand Up @@ -209,7 +209,7 @@ mod tests {
test_message!(add_http_front, "../assets/add_http_front.json", CommandRequest {
id: "ID_TEST".to_string(),
version: 0,
data: CommandRequestData::Proxy(ProxyRequestData::AddHttpFront(HttpFront{
data: CommandRequestData::Proxy(ProxyRequestData::AddHttpFrontend(HttpFrontend{
route: Route::AppId(String::from("xxx")),
hostname: String::from("yyy"),
path: PathRule::Prefix(String::from("xxx")),
Expand All @@ -222,7 +222,7 @@ mod tests {
test_message!(remove_http_front, "../assets/remove_http_front.json", CommandRequest {
id: "ID_TEST".to_string(),
version: 0,
data: CommandRequestData::Proxy(ProxyRequestData::RemoveHttpFront(HttpFront{
data: CommandRequestData::Proxy(ProxyRequestData::RemoveHttpFrontend(HttpFrontend{
route: Route::AppId(String::from("xxx")),
hostname: String::from("yyy"),
path: PathRule::Prefix(String::from("xxx")),
Expand All @@ -235,7 +235,7 @@ mod tests {
test_message!(add_https_front, "../assets/add_https_front.json", CommandRequest {
id: "ID_TEST".to_string(),
version: 0,
data: CommandRequestData::Proxy(ProxyRequestData::AddHttpsFront(HttpFront{
data: CommandRequestData::Proxy(ProxyRequestData::AddHttpsFrontend(HttpFrontend{
route: Route::AppId(String::from("xxx")),
hostname: String::from("yyy"),
path: PathRule::Prefix(String::from("xxx")),
Expand All @@ -248,7 +248,7 @@ mod tests {
test_message!(remove_https_front, "../assets/remove_https_front.json", CommandRequest {
id: "ID_TEST".to_string(),
version: 0,
data: CommandRequestData::Proxy(ProxyRequestData::RemoveHttpsFront(HttpFront{
data: CommandRequestData::Proxy(ProxyRequestData::RemoveHttpsFrontend(HttpFrontend{
route: Route::AppId(String::from("xxx")),
hostname: String::from("yyy"),
path: PathRule::Prefix(String::from("xxx")),
Expand Down
8 changes: 4 additions & 4 deletions command/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::io::{self,Error,ErrorKind,Read};
use crate::certificate::split_certificate_chain;
use toml;

use crate::proxy::{CertificateAndKey,ProxyRequestData,HttpFront,TcpFront,Backend,
use crate::proxy::{CertificateAndKey,ProxyRequestData,HttpFrontend,TcpFrontend,Backend,
HttpListener,HttpsListener,TcpListener,AddCertificate,TlsProvider,LoadBalancingParams,
LoadMetric, Application, TlsVersion,ActivateListener,ListenerType,RulePosition,PathRule,
LoadBalancingAlgorithms, Route};
Expand Down Expand Up @@ -510,7 +510,7 @@ impl HttpFrontendConfig {
names: vec!(self.hostname.clone()),
}));

v.push(ProxyRequestData::AddHttpsFront(HttpFront {
v.push(ProxyRequestData::AddHttpsFrontend(HttpFrontend {
route: Route::AppId(app_id.to_string()),
address: self.address,
hostname: self.hostname.clone(),
Expand All @@ -519,7 +519,7 @@ impl HttpFrontendConfig {
}));
} else {
//create the front both for HTTP and HTTPS if possible
v.push(ProxyRequestData::AddHttpFront(HttpFront {
v.push(ProxyRequestData::AddHttpFrontend(HttpFrontend {
route: Route::AppId(app_id.to_string()),
address: self.address,
hostname: self.hostname.clone(),
Expand Down Expand Up @@ -617,7 +617,7 @@ impl TcpAppConfig {
}));

for frontend in &self.frontends {
v.push(ProxyRequestData::AddTcpFront(TcpFront {
v.push(ProxyRequestData::AddTcpFrontend(TcpFrontend {
app_id: self.app_id.clone(),
address: frontend.address,
}));
Expand Down

0 comments on commit 270bfee

Please sign in to comment.