Rename `transparency` to `proxy` (#89)

This change clarifies the naming and role of the `proxy` (née transparency)
module. There are no functional changes.

`proxy::tcp::Proxy` has been renamed to `proxy::tcp::Forward` to help
disambiguate terminology: TCP connections may be _forwarded_
by the proxy server.
This commit is contained in:
Oliver Gould 2018-09-10 16:21:05 -07:00 committed by GitHub
parent 216fe16523
commit 9f9518a98f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 47 additions and 32 deletions

View File

@ -13,7 +13,7 @@ use control::destination::Endpoint;
use ctx;
use svc::{NewClient, Reconnect};
use telemetry;
use transparency::{self, HttpBody, h1, orig_proto};
use proxy::{self, HttpBody, h1, orig_proto};
use transport;
use tls;
use ctx::transport::TlsStatus;
@ -30,7 +30,7 @@ pub type TlsStack<B> = telemetry::http::service::Http<HttpService<B>, B, HttpBod
type HttpService<B> = Reconnect<
Arc<ctx::transport::Client>,
transparency::Client<
proxy::Client<
transport::metrics::Connect<transport::Connect>,
::logging::ClientExecutor<&'static str, SocketAddr>,
telemetry::http::service::RequestBody<B>,
@ -263,7 +263,7 @@ where
client_ctx.clone(),
Reconnect::new(
client_ctx.clone(),
transparency::Client::new(protocol, connect, log.executor())
proxy::Client::new(protocol, connect, log.executor())
)
)
}
@ -292,7 +292,7 @@ where
// Rewrite the HTTP/1 URI, if the authorities in the Host header
// and request URI are not in agreement, or are not present.
//
// TODO move this into transparency::Client?
// TODO move this into proxy::Client?
let normalize_uri = NormalizeUri::new(watch_tls, protocol.was_absolute_form());
// Upgrade HTTP/1.1 requests to be HTTP/2 if the endpoint supports HTTP/2.

View File

@ -9,7 +9,7 @@ use linkerd2_proxy_router::Recognize;
use bind;
use ctx;
use transparency::orig_proto;
use proxy::orig_proto;
type Bind<B> = bind::Bind<ctx::Proxy, B>;

View File

@ -91,7 +91,7 @@ pub mod stream;
mod svc;
pub mod task;
pub mod telemetry;
mod transparency;
mod proxy;
mod transport;
pub mod timeout;
mod tower_fn; // TODO: move to tower-fn
@ -102,7 +102,7 @@ use conditional::Conditional;
use inbound::Inbound;
use map_err::MapErr;
use task::MainRuntime;
use transparency::{HttpBody, Server};
use proxy::{HttpBody, Server};
use transport::{BoundPort, Connection};
pub use transport::{AddrInfo, GetOriginalDst, SoOriginalDst, tls};
use outbound::Outbound;

View File

@ -20,7 +20,7 @@ use svc::NewClient;
use ctx;
use telemetry::http::service::{ResponseBody as SensorBody};
use timeout::Timeout;
use transparency::{h1, HttpBody};
use proxy::{h1, HttpBody};
use transport::{DnsNameAndPort, Host, HostAndPort};
type BindProtocol<B> = bind::BindProtocol<ctx::Proxy, B>;

27
src/proxy/mod.rs Normal file
View File

@ -0,0 +1,27 @@
//! Reponsible for proxying traffic from a server interface.
//!
//! As the `Server` is invoked with transports, it may terminate a TLS session
//! and determine the peer's identity and determine whether the connection is
//! transporting HTTP. If the transport does not contain HTTP traffic, then the
//! TCP stream is blindly forwarded (according to the original socket's
//! `SO_ORIGINAL_DST` option). Otherwise, an HTTP service established for the
//! connection through which requests are dispatched.
//!
//! Once a request is routed, the `Client` type can be used to establish a
//! `Service` that hides the type differences between HTTP/1 and HTTP/2 clients.
//!
//! This module is intended only to store the infrastructure for building a
//! proxy. The specific logic implemented by a proxy should live elsewhere.
mod client;
mod glue;
pub mod h1;
mod upgrade;
pub mod orig_proto;
mod protocol;
mod server;
mod tcp;
pub use self::client::{Client, Error as ClientError};
pub use self::glue::HttpBody;
pub use self::server::Server;

View File

@ -46,7 +46,7 @@ where
new_service: S,
proxy_ctx: ProxyCtx,
transport_registry: transport::metrics::Registry,
tcp: tcp::Proxy,
tcp: tcp::Forward,
log: ::logging::Server,
}
@ -82,7 +82,7 @@ where
drain_signal: drain::Watch,
) -> Self {
let recv_body_svc = HttpBodyNewSvc::new(stack.clone());
let tcp = tcp::Proxy::new(tcp_connect_timeout, transport_registry.clone());
let tcp = tcp::Forward::new(tcp_connect_timeout, transport_registry.clone());
let log = ::logging::Server::proxy(proxy_ctx, listen_addr);
Server {
disable_protocol_detection_ports,
@ -164,7 +164,7 @@ where
.map_err(|e| debug!("peek error: {}", e))
.and_then(move |io| match Protocol::detect(io.peeked()) {
Some(Protocol::Http1) => Either::A({
trace!("transparency detected HTTP/1");
trace!("detected HTTP/1");
let fut = new_service.new_service()
.map_err(|e| trace!("h1 new_service error: {:?}", e))
@ -191,7 +191,7 @@ where
Either::A(fut)
}),
Some(Protocol::Http2) => Either::A({
trace!("transparency detected HTTP/2");
trace!("detected HTTP/2");
let set_ctx = move |request: &mut http::Request<()>| {
request.extensions_mut().insert(srv_ctx.clone());
};
@ -205,7 +205,7 @@ where
Either::B(fut)
}),
None => {
trace!("transparency did not detect protocol, treating as TCP");
trace!("did not detect protocol, treating as TCP");
Either::B(tcp_serve(
&tcp,
io,
@ -220,7 +220,7 @@ where
}
fn tcp_serve<T: AsyncRead + AsyncWrite + Send + 'static>(
tcp: &tcp::Proxy,
tcp: &tcp::Forward,
io: T,
srv_ctx: Arc<ServerCtx>,
drain_signal: drain::Watch,

View File

@ -17,15 +17,15 @@ use timeout::Timeout;
use transport::{self, tls};
use ctx::transport::TlsStatus;
/// TCP Server Proxy
/// Forwards a stream of bytes to the socket's `SO_ORIGINAL_DST`
#[derive(Debug, Clone)]
pub struct Proxy {
pub struct Forward {
connect_timeout: Duration,
transport_registry: transport::metrics::Registry,
}
impl Proxy {
/// Create a new TCP `Proxy`.
impl Forward {
/// Create a new TCP `Forward`.
pub fn new(
connect_timeout: Duration,
transport_registry: transport::metrics::Registry

View File

@ -6,7 +6,7 @@ use tower_h2::Body;
use ctx;
use telemetry::{http::event, tap};
use transparency::ClientError;
use proxy::ClientError;
use super::record::Record;
use super::service::{Http, RequestBody};

View File

@ -10,7 +10,7 @@ use tower_service::{NewService, Service};
use tower_h2::Body;
use ctx;
use transparency::ClientError;
use proxy::ClientError;
use super::event::{self, Event};
use super::sensors::Handle;

View File

@ -1,12 +0,0 @@
mod client;
mod glue;
pub mod h1;
mod upgrade;
pub mod orig_proto;
mod protocol;
mod server;
mod tcp;
pub use self::client::{Client, Error as ClientError};
pub use self::glue::HttpBody;
pub use self::server::Server;