Skip to content

Commit

Permalink
edition 2021
Browse files Browse the repository at this point in the history
  • Loading branch information
Geal authored and FlorentinDUBOIS committed Jul 13, 2022
1 parent 627dd0e commit 2e723bc
Show file tree
Hide file tree
Showing 42 changed files with 225 additions and 247 deletions.
2 changes: 1 addition & 1 deletion bin/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use sozu_command::command::{
CommandRequestData, CommandResponse, CommandResponseData, CommandStatus, Event, RunState,
};
use sozu_command::config::Config;
use sozu_command::proxy::Route;

use sozu_command::proxy::{ProxyRequest, ProxyRequestData, ProxyResponseData, ProxyResponseStatus};
use sozu_command::scm_socket::{Listeners, ScmSocket};
use sozu_command::state::ConfigState;
Expand Down
8 changes: 3 additions & 5 deletions bin/src/command/orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ use std::time::Duration;

use async_io::Async;

use sozu::metrics::METRICS;
use sozu_command::buffer::fixed::Buffer;
use sozu_command::command::{
CommandRequest, CommandRequestData, CommandResponse, CommandResponseData, CommandStatus,
RunState, WorkerInfo,
};
use sozu_command::logging;
use sozu_command::proxy::{
AggregatedMetricsData, HttpFrontend, MetricsConfiguration, MetricsData, ProxyRequest,
ProxyRequestData, ProxyResponseData, ProxyResponseStatus, Query, QueryAnswer,
QueryApplicationType, Route, TcpFrontend,
MetricsConfiguration, ProxyRequest, ProxyRequestData, ProxyResponseData, ProxyResponseStatus,
Query, QueryAnswer, QueryApplicationType, Route, TcpFrontend,
};
use sozu_command::scm_socket::Listeners;
use sozu_command::state::get_application_ids_by_domain;
Expand Down Expand Up @@ -1053,7 +1051,7 @@ impl CommandServer {
}
&Query::Metrics(_) => {
debug!("metrics query received: {:?}", data);
let res = client_tx
let _res = client_tx
.send(CommandResponse::new(
request_id.clone(),
CommandStatus::Ok,
Expand Down
2 changes: 1 addition & 1 deletion bin/src/ctl/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,7 @@ pub fn query_metrics(
refresh: Option<u32>,
names: Vec<String>,
clusters: Vec<String>,
mut backends: Vec<(String, String)>,
backends: Vec<(String, String)>,
) -> Result<(), anyhow::Error> {
let query = if list {
QueryMetricsType::List
Expand Down
16 changes: 0 additions & 16 deletions command/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
extern crate log;
#[macro_use]
extern crate serde_derive;

extern crate hex;
extern crate mio;
extern crate pem;
#[macro_use]
extern crate nix;
extern crate libc;
extern crate pool;
extern crate poule;
extern crate regex;
extern crate serde;
extern crate serde_json;
extern crate sha2;
extern crate time;
extern crate toml;

#[macro_use]
pub mod logging;
pub mod buffer;
Expand Down
1 change: 0 additions & 1 deletion command/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,6 @@ macro_rules! fixme {
};
}

use crate::log;
pub struct CompatLogger;

impl From<log::Level> for LogLevel {
Expand Down
2 changes: 1 addition & 1 deletion command/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ impl ProxyRequestData {
.iter()
.cloned()
.collect(),
ProxyRequestData::RemoveCluster { ref cluster_id } => [
ProxyRequestData::RemoveCluster { cluster_id: _ } => [
Topic::HttpProxyConfig,
Topic::HttpsProxyConfig,
Topic::TcpProxyConfig,
Expand Down
4 changes: 2 additions & 2 deletions command/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ impl ConfigState {
http_frontends: self
.http_fronts
.iter()
.filter_map(|(k, v)| match &v.route {
.filter_map(|(_k, v)| match &v.route {
Route::Deny => None,
Route::ClusterId(id) => {
if id == cluster_id {
Expand All @@ -899,7 +899,7 @@ impl ConfigState {
https_frontends: self
.https_fronts
.iter()
.filter_map(|(k, v)| match &v.route {
.filter_map(|(_k, v)| match &v.route {
Route::Deny => None,
Route::ClusterId(id) => {
if id == cluster_id {
Expand Down
1 change: 1 addition & 0 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ version = "0.13.6"
license = "AGPL-3.0"
authors = ["Clément Delafargue <clement@delafargue.name>", "Geoffroy Couprie <geo.couprie@gmail.com>"]
categories = ["network-programming"]
edition = "2018"

include = [
"./README.md",
Expand Down
8 changes: 4 additions & 4 deletions lib/examples/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ extern crate sozu_lib as sozu;
extern crate sozu_command_lib as sozu_command;
extern crate time;

use sozu_command::channel::Channel;
use sozu_command::logging::{Logger, LoggerBackend};
use sozu_command::proxy;
use sozu_command::proxy::{LoadBalancingParams, PathRule, Route, RulePosition};
use crate::sozu_command::channel::Channel;
use crate::sozu_command::logging::{Logger, LoggerBackend};
use crate::sozu_command::proxy;
use crate::sozu_command::proxy::{LoadBalancingParams, PathRule, Route, RulePosition};
use std::env;
use std::io::stdout;
use std::thread;
Expand Down
8 changes: 4 additions & 4 deletions lib/examples/minimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ extern crate sozu_lib as sozu;
extern crate sozu_command_lib as sozu_command;
extern crate time;

use sozu_command::channel::Channel;
use sozu_command::logging::{Logger, LoggerBackend};
use sozu_command::proxy;
use sozu_command::proxy::{LoadBalancingParams, PathRule, Route, RulePosition};
use crate::sozu_command::channel::Channel;
use crate::sozu_command::logging::{Logger, LoggerBackend};
use crate::sozu_command::proxy;
use crate::sozu_command::proxy::{LoadBalancingParams, PathRule, Route, RulePosition};
use std::env;
use std::io::stdout;
use std::thread;
Expand Down
6 changes: 3 additions & 3 deletions lib/examples/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ extern crate sozu_lib as sozu;
extern crate sozu_command_lib as sozu_command;
extern crate time;

use sozu_command::channel::Channel;
use sozu_command::logging::{Logger, LoggerBackend};
use sozu_command::proxy::{self, LoadBalancingParams, TcpListener};
use crate::sozu_command::channel::Channel;
use crate::sozu_command::logging::{Logger, LoggerBackend};
use crate::sozu_command::proxy::{self, LoadBalancingParams, TcpListener};
use std::io::stdout;
use std::thread;

Expand Down
4 changes: 2 additions & 2 deletions lib/src/backends.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use std::collections::HashMap;
use std::net::SocketAddr;
use std::rc::Rc;

use sozu_command::proxy::{self, LoadBalancingAlgorithms};
use crate::sozu_command::proxy::{self, LoadBalancingAlgorithms};

use super::{load_balancing::*, Backend, ClusterId, ConnectionError};
use server::push_event;
use crate::server::push_event;

#[derive(Debug)]
pub struct BackendMap {
Expand Down
6 changes: 3 additions & 3 deletions lib/src/buffer_queue.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pool::{Checkout, Pool};
use pool_crate::Reset;
use crate::pool::{Checkout, Pool};
use crate::pool_crate::Reset;
use std::cmp::{max, min};
use std::io::{self, Write};
use std::{fmt, str};
Expand Down Expand Up @@ -506,8 +506,8 @@ pub fn buf_with_capacity(capacity: usize) -> (Pool, BufferQueue) {
#[cfg(test)]
mod tests {
use super::*;
use crate::sozu_command::buffer::fixed::Buffer;
use nom::HexDisplay;
use sozu_command::buffer::fixed::Buffer;
use std::io::Write;

#[test]
Expand Down
20 changes: 10 additions & 10 deletions lib/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ use std::rc::{Rc, Weak};
use std::str::from_utf8_unchecked;
use time::{Duration, Instant};

use sozu_command::logging;
use sozu_command::proxy::{
use crate::sozu_command::logging;
use crate::sozu_command::proxy::{
Cluster, HttpFrontend, HttpListener, ProxyEvent, ProxyRequest, ProxyRequestData, ProxyResponse,
ProxyResponseStatus, RemoveListener, Route,
ProxyResponseStatus, Route,
};
use sozu_command::scm_socket::{Listeners, ScmSocket};
use crate::sozu_command::scm_socket::{Listeners, ScmSocket};

use super::backends::BackendMap;
use super::pool::Pool;
Expand All @@ -32,10 +32,10 @@ use super::{
ConnectionError, Protocol, ProxyConfiguration, ProxySession, Readiness, SessionMetrics,
SessionResult,
};
use router::Router;
use sozu_command::ready::Ready;
use timer::TimeoutContainer;
use util::UnwrapLog;
use crate::router::Router;
use crate::sozu_command::ready::Ready;
use crate::timer::TimeoutContainer;
use crate::util::UnwrapLog;

#[derive(PartialEq)]
pub enum SessionStatus {
Expand Down Expand Up @@ -1717,8 +1717,8 @@ pub fn start(config: HttpListener, channel: ProxyChannel, max_buffers: usize, bu
mod tests {
extern crate tiny_http;
use super::*;
use sozu_command::channel::Channel;
use sozu_command::proxy::{
use crate::sozu_command::channel::Channel;
use crate::sozu_command::proxy::{
Backend, HttpFrontend, HttpListener, LoadBalancingAlgorithms, LoadBalancingParams,
PathRule, ProxyRequest, ProxyRequestData, Route, RulePosition,
};
Expand Down
50 changes: 25 additions & 25 deletions lib/src/https_openssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,35 @@ use std::str::from_utf8_unchecked;
use std::sync::{Arc, Mutex};
use time::{Duration, Instant};

use sozu_command::logging;
use sozu_command::proxy::{
use crate::sozu_command::logging;
use crate::sozu_command::proxy::{
CertificateAndKey, CertificateFingerprint, Cluster, HttpFrontend, HttpsListener, ProxyEvent,
ProxyRequest, ProxyRequestData, ProxyResponse, ProxyResponseData, ProxyResponseStatus, Query,
QueryAnswer, QueryAnswerCertificate, QueryCertificateType, RemoveListener, Route, TlsVersion,
QueryAnswer, QueryAnswerCertificate, QueryCertificateType, Route, TlsVersion,
};
use sozu_command::ready::Ready;
use sozu_command::scm_socket::ScmSocket;

use backends::BackendMap;
use pool::Pool;
use protocol::h2::Http2;
use protocol::http::DefaultAnswerStatus;
use protocol::http::{
use crate::sozu_command::ready::Ready;
use crate::sozu_command::scm_socket::ScmSocket;

use crate::backends::BackendMap;
use crate::pool::Pool;
use crate::protocol::h2::Http2;
use crate::protocol::http::DefaultAnswerStatus;
use crate::protocol::http::{
answers::HttpAnswers,
parser::{hostname_and_port, Method, RRequestLine, RequestState},
};
use protocol::openssl::TlsHandshake;
use protocol::proxy_protocol::expect::ExpectProxyProtocol;
use protocol::{Http, Pipe, ProtocolResult, StickySession};
use retry::RetryPolicy;
use router::{trie::*, Router};
use server::{
use crate::protocol::openssl::TlsHandshake;
use crate::protocol::proxy_protocol::expect::ExpectProxyProtocol;
use crate::protocol::{Http, Pipe, ProtocolResult, StickySession};
use crate::retry::RetryPolicy;
use crate::router::{trie::*, Router};
use crate::server::{
push_event, ListenSession, ListenToken, ProxyChannel, Server, SessionToken, CONN_RETRIES,
};
use socket::server_bind;
use timer::TimeoutContainer;
use util::UnwrapLog;
use {
use crate::socket::server_bind;
use crate::timer::TimeoutContainer;
use crate::util::UnwrapLog;
use crate::{
AcceptError, Backend, BackendConnectAction, BackendConnectionStatus, CloseResult, ClusterId,
ConnectionError, Protocol, ProxyConfiguration, ProxySession, Readiness, SessionMetrics,
SessionResult,
Expand Down Expand Up @@ -2325,9 +2325,9 @@ yD0TrUjkXyjV/zczIYiYSROg9OE5UgYqswIBAg==
ctx.set_tmp_dh(&dh)
}

use server::HttpsProvider;
use crate::server::HttpsProvider;
pub fn start(config: HttpsListener, channel: ProxyChannel, max_buffers: usize, buffer_size: usize) {
use server::{self, ProxySessionCast};
use crate::server::{self, ProxySessionCast};

let mut event_loop = Poll::new().expect("could not create event loop");

Expand Down Expand Up @@ -2406,9 +2406,9 @@ pub fn start(config: HttpsListener, channel: ProxyChannel, max_buffers: usize, b
mod tests {
extern crate tiny_http;
use super::*;
use crate::router::{trie::TrieNode, MethodRule, PathRule, Router};
use crate::sozu_command::proxy::Route;
use openssl::ssl::{SslContext, SslMethod};
use router::{trie::TrieNode, MethodRule, PathRule, Router};
use sozu_command::proxy::Route;
use std::collections::HashMap;
use std::net::SocketAddr;
use std::rc::Rc;
Expand Down
36 changes: 18 additions & 18 deletions lib/src/https_rustls/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,29 @@ use std::str::from_utf8_unchecked;
use std::sync::Arc;
use time::{Duration, Instant};

use sozu_command::logging;
use sozu_command::proxy::{
use crate::sozu_command::logging;
use crate::sozu_command::proxy::{
AddCertificate, Cluster, HttpFrontend, HttpsListener, ProxyRequest, ProxyRequestData,
ProxyResponse, ProxyResponseData, ProxyResponseStatus, Query, QueryAnswer,
QueryAnswerCertificate, QueryCertificateType, RemoveCertificate, RemoveListener,
ReplaceCertificate, Route, TlsVersion,
QueryAnswerCertificate, QueryCertificateType, RemoveCertificate, ReplaceCertificate, Route,
TlsVersion,
};
use sozu_command::ready::Ready;
use sozu_command::scm_socket::ScmSocket;
use crate::sozu_command::ready::Ready;
use crate::sozu_command::scm_socket::ScmSocket;

use backends::BackendMap;
use pool::Pool;
use protocol::http::DefaultAnswerStatus;
use protocol::http::{
use crate::backends::BackendMap;
use crate::pool::Pool;
use crate::protocol::http::DefaultAnswerStatus;
use crate::protocol::http::{
answers::HttpAnswers,
parser::{hostname_and_port, Method, RRequestLine},
};
use protocol::StickySession;
use router::Router;
use server::{ListenSession, ListenToken, ProxyChannel, Server, SessionToken, CONN_RETRIES};
use socket::server_bind;
use util::UnwrapLog;
use {
use crate::protocol::StickySession;
use crate::router::Router;
use crate::server::{ListenSession, ListenToken, ProxyChannel, Server, SessionToken, CONN_RETRIES};
use crate::socket::server_bind;
use crate::util::UnwrapLog;
use crate::{
AcceptError, BackendConnectAction, BackendConnectionStatus, ClusterId, ConnectionError,
Protocol, ProxyConfiguration, ProxySession,
};
Expand Down Expand Up @@ -903,9 +903,9 @@ impl ProxyConfiguration<Session> for Proxy {
}
}

use server::HttpsProvider;
use crate::server::HttpsProvider;
pub fn start(config: HttpsListener, channel: ProxyChannel, max_buffers: usize, buffer_size: usize) {
use server::{self, ProxySessionCast};
use crate::server::{self, ProxySessionCast};

let mut event_loop = Poll::new().expect("could not create event loop");

Expand Down
6 changes: 3 additions & 3 deletions lib/src/https_rustls/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ use std::collections::HashMap;
use std::io::BufReader;
use std::sync::{Arc, Mutex};

use sozu_command::certificate::calculate_fingerprint_from_der;
use sozu_command::proxy::{
use crate::sozu_command::certificate::calculate_fingerprint_from_der;
use crate::sozu_command::proxy::{
AddCertificate, CertificateAndKey, CertificateFingerprint, RemoveCertificate,
};

use router::trie::TrieNode;
use crate::router::trie::TrieNode;

struct TlsData {
pub cert: CertifiedKey,
Expand Down

0 comments on commit 2e723bc

Please sign in to comment.