#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Logs {
#[prost(string, tag = "1")]
pub token: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "3")]
pub logs: ::prost::alloc::vec::Vec<Log>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Log {
#[prost(string, tag = "1")]
pub timestamp: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub level: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub message: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AppGuardTcpConnection {
#[prost(string, tag = "1")]
pub token: ::prost::alloc::string::String,
#[prost(string, optional, tag = "2")]
pub source_ip: ::core::option::Option<::prost::alloc::string::String>,
#[prost(uint32, optional, tag = "3")]
pub source_port: ::core::option::Option<u32>,
#[prost(string, optional, tag = "4")]
pub destination_ip: ::core::option::Option<::prost::alloc::string::String>,
#[prost(uint32, optional, tag = "5")]
pub destination_port: ::core::option::Option<u32>,
#[prost(string, tag = "6")]
pub protocol: ::prost::alloc::string::String,
}
#[derive(serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AppGuardIpInfo {
#[prost(string, tag = "1")]
pub ip: ::prost::alloc::string::String,
#[prost(string, optional, tag = "2")]
pub country: ::core::option::Option<::prost::alloc::string::String>,
#[prost(string, optional, tag = "3")]
pub asn: ::core::option::Option<::prost::alloc::string::String>,
#[prost(string, optional, tag = "4")]
pub org: ::core::option::Option<::prost::alloc::string::String>,
#[prost(string, optional, tag = "5")]
pub continent_code: ::core::option::Option<::prost::alloc::string::String>,
#[prost(string, optional, tag = "6")]
pub city: ::core::option::Option<::prost::alloc::string::String>,
#[prost(string, optional, tag = "7")]
pub region: ::core::option::Option<::prost::alloc::string::String>,
#[prost(string, optional, tag = "8")]
pub postal: ::core::option::Option<::prost::alloc::string::String>,
#[prost(string, optional, tag = "9")]
pub timezone: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AppGuardTcpInfo {
#[prost(message, optional, tag = "1")]
pub connection: ::core::option::Option<AppGuardTcpConnection>,
#[prost(message, optional, tag = "2")]
pub ip_info: ::core::option::Option<AppGuardIpInfo>,
#[prost(uint64, tag = "3")]
pub tcp_id: u64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AppGuardHttpRequest {
#[prost(string, tag = "1")]
pub token: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub original_url: ::prost::alloc::string::String,
#[prost(map = "string, string", tag = "3")]
pub headers: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
#[prost(string, tag = "4")]
pub method: ::prost::alloc::string::String,
#[prost(string, optional, tag = "5")]
pub body: ::core::option::Option<::prost::alloc::string::String>,
#[prost(map = "string, string", tag = "6")]
pub query: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
#[prost(message, optional, tag = "100")]
pub tcp_info: ::core::option::Option<AppGuardTcpInfo>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AppGuardHttpResponse {
#[prost(string, tag = "1")]
pub token: ::prost::alloc::string::String,
#[prost(uint32, tag = "2")]
pub code: u32,
#[prost(map = "string, string", tag = "3")]
pub headers: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
#[prost(message, optional, tag = "100")]
pub tcp_info: ::core::option::Option<AppGuardTcpInfo>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AppGuardSmtpRequest {
#[prost(string, tag = "1")]
pub token: ::prost::alloc::string::String,
#[prost(map = "string, string", tag = "2")]
pub headers: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
#[prost(string, optional, tag = "3")]
pub body: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "100")]
pub tcp_info: ::core::option::Option<AppGuardTcpInfo>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AppGuardSmtpResponse {
#[prost(string, tag = "1")]
pub token: ::prost::alloc::string::String,
#[prost(uint32, optional, tag = "2")]
pub code: ::core::option::Option<u32>,
#[prost(message, optional, tag = "100")]
pub tcp_info: ::core::option::Option<AppGuardTcpInfo>,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct AppGuardResponse {
#[prost(enumeration = "super::appguard_commands::FirewallPolicy", tag = "2")]
pub policy: i32,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AppGuardTcpResponse {
#[prost(message, optional, tag = "1")]
pub tcp_info: ::core::option::Option<AppGuardTcpInfo>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Token {
#[prost(string, tag = "1")]
pub token: ::prost::alloc::string::String,
}
pub mod app_guard_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct AppGuardClient<T> {
inner: tonic::client::Grpc<T>,
}
impl AppGuardClient<tonic::transport::Channel> {
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> AppGuardClient<T>
where
T: tonic::client::GrpcService<tonic::body::Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> AppGuardClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::Body>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::Body>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
AppGuardClient::new(InterceptedService::new(inner, interceptor))
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn control_channel(
&mut self,
request: impl tonic::IntoStreamingRequest<
Message = super::super::appguard_commands::ClientMessage,
>,
) -> std::result::Result<
tonic::Response<
tonic::codec::Streaming<super::super::appguard_commands::ServerMessage>,
>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/appguard.AppGuard/ControlChannel",
);
let mut req = request.into_streaming_request();
req.extensions_mut()
.insert(GrpcMethod::new("appguard.AppGuard", "ControlChannel"));
self.inner.streaming(req, path, codec).await
}
pub async fn handle_logs(
&mut self,
request: impl tonic::IntoRequest<super::Logs>,
) -> std::result::Result<tonic::Response<()>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/appguard.AppGuard/HandleLogs",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("appguard.AppGuard", "HandleLogs"));
self.inner.unary(req, path, codec).await
}
pub async fn handle_tcp_connection(
&mut self,
request: impl tonic::IntoRequest<super::AppGuardTcpConnection>,
) -> std::result::Result<
tonic::Response<super::AppGuardTcpResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/appguard.AppGuard/HandleTcpConnection",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("appguard.AppGuard", "HandleTcpConnection"));
self.inner.unary(req, path, codec).await
}
pub async fn handle_http_request(
&mut self,
request: impl tonic::IntoRequest<super::AppGuardHttpRequest>,
) -> std::result::Result<
tonic::Response<super::AppGuardResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/appguard.AppGuard/HandleHttpRequest",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("appguard.AppGuard", "HandleHttpRequest"));
self.inner.unary(req, path, codec).await
}
pub async fn handle_http_response(
&mut self,
request: impl tonic::IntoRequest<super::AppGuardHttpResponse>,
) -> std::result::Result<
tonic::Response<super::AppGuardResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/appguard.AppGuard/HandleHttpResponse",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("appguard.AppGuard", "HandleHttpResponse"));
self.inner.unary(req, path, codec).await
}
pub async fn handle_smtp_request(
&mut self,
request: impl tonic::IntoRequest<super::AppGuardSmtpRequest>,
) -> std::result::Result<
tonic::Response<super::AppGuardResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/appguard.AppGuard/HandleSmtpRequest",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("appguard.AppGuard", "HandleSmtpRequest"));
self.inner.unary(req, path, codec).await
}
pub async fn handle_smtp_response(
&mut self,
request: impl tonic::IntoRequest<super::AppGuardSmtpResponse>,
) -> std::result::Result<
tonic::Response<super::AppGuardResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/appguard.AppGuard/HandleSmtpResponse",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("appguard.AppGuard", "HandleSmtpResponse"));
self.inner.unary(req, path, codec).await
}
pub async fn firewall_defaults_request(
&mut self,
request: impl tonic::IntoRequest<super::Token>,
) -> std::result::Result<
tonic::Response<super::super::appguard_commands::FirewallDefaults>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/appguard.AppGuard/FirewallDefaultsRequest",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("appguard.AppGuard", "FirewallDefaultsRequest"));
self.inner.unary(req, path, codec).await
}
}
}
pub mod app_guard_server {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
#[async_trait]
pub trait AppGuard: std::marker::Send + std::marker::Sync + 'static {
type ControlChannelStream: tonic::codegen::tokio_stream::Stream<
Item = std::result::Result<
super::super::appguard_commands::ServerMessage,
tonic::Status,
>,
>
+ std::marker::Send
+ 'static;
async fn control_channel(
&self,
request: tonic::Request<
tonic::Streaming<super::super::appguard_commands::ClientMessage>,
>,
) -> std::result::Result<
tonic::Response<Self::ControlChannelStream>,
tonic::Status,
>;
async fn handle_logs(
&self,
request: tonic::Request<super::Logs>,
) -> std::result::Result<tonic::Response<()>, tonic::Status>;
async fn handle_tcp_connection(
&self,
request: tonic::Request<super::AppGuardTcpConnection>,
) -> std::result::Result<
tonic::Response<super::AppGuardTcpResponse>,
tonic::Status,
>;
async fn handle_http_request(
&self,
request: tonic::Request<super::AppGuardHttpRequest>,
) -> std::result::Result<
tonic::Response<super::AppGuardResponse>,
tonic::Status,
>;
async fn handle_http_response(
&self,
request: tonic::Request<super::AppGuardHttpResponse>,
) -> std::result::Result<
tonic::Response<super::AppGuardResponse>,
tonic::Status,
>;
async fn handle_smtp_request(
&self,
request: tonic::Request<super::AppGuardSmtpRequest>,
) -> std::result::Result<
tonic::Response<super::AppGuardResponse>,
tonic::Status,
>;
async fn handle_smtp_response(
&self,
request: tonic::Request<super::AppGuardSmtpResponse>,
) -> std::result::Result<
tonic::Response<super::AppGuardResponse>,
tonic::Status,
>;
async fn firewall_defaults_request(
&self,
request: tonic::Request<super::Token>,
) -> std::result::Result<
tonic::Response<super::super::appguard_commands::FirewallDefaults>,
tonic::Status,
>;
}
#[derive(Debug)]
pub struct AppGuardServer<T> {
inner: Arc<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
impl<T> AppGuardServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
max_decoding_message_size: None,
max_encoding_message_size: None,
}
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.accept_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.send_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.max_decoding_message_size = Some(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.max_encoding_message_size = Some(limit);
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for AppGuardServer<T>
where
T: AppGuard,
B: Body + std::marker::Send + 'static,
B::Error: Into<StdError> + std::marker::Send + 'static,
{
type Response = http::Response<tonic::body::Body>;
type Error = std::convert::Infallible;
type Future = BoxFuture<Self::Response, Self::Error>;
fn poll_ready(
&mut self,
_cx: &mut Context<'_>,
) -> Poll<std::result::Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
match req.uri().path() {
"/appguard.AppGuard/ControlChannel" => {
#[allow(non_camel_case_types)]
struct ControlChannelSvc<T: AppGuard>(pub Arc<T>);
impl<
T: AppGuard,
> tonic::server::StreamingService<
super::super::appguard_commands::ClientMessage,
> for ControlChannelSvc<T> {
type Response = super::super::appguard_commands::ServerMessage;
type ResponseStream = T::ControlChannelStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
tonic::Streaming<
super::super::appguard_commands::ClientMessage,
>,
>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as AppGuard>::control_channel(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = ControlChannelSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/appguard.AppGuard/HandleLogs" => {
#[allow(non_camel_case_types)]
struct HandleLogsSvc<T: AppGuard>(pub Arc<T>);
impl<T: AppGuard> tonic::server::UnaryService<super::Logs>
for HandleLogsSvc<T> {
type Response = ();
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::Logs>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as AppGuard>::handle_logs(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = HandleLogsSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/appguard.AppGuard/HandleTcpConnection" => {
#[allow(non_camel_case_types)]
struct HandleTcpConnectionSvc<T: AppGuard>(pub Arc<T>);
impl<
T: AppGuard,
> tonic::server::UnaryService<super::AppGuardTcpConnection>
for HandleTcpConnectionSvc<T> {
type Response = super::AppGuardTcpResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::AppGuardTcpConnection>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as AppGuard>::handle_tcp_connection(&inner, request)
.await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = HandleTcpConnectionSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/appguard.AppGuard/HandleHttpRequest" => {
#[allow(non_camel_case_types)]
struct HandleHttpRequestSvc<T: AppGuard>(pub Arc<T>);
impl<
T: AppGuard,
> tonic::server::UnaryService<super::AppGuardHttpRequest>
for HandleHttpRequestSvc<T> {
type Response = super::AppGuardResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::AppGuardHttpRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as AppGuard>::handle_http_request(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = HandleHttpRequestSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/appguard.AppGuard/HandleHttpResponse" => {
#[allow(non_camel_case_types)]
struct HandleHttpResponseSvc<T: AppGuard>(pub Arc<T>);
impl<
T: AppGuard,
> tonic::server::UnaryService<super::AppGuardHttpResponse>
for HandleHttpResponseSvc<T> {
type Response = super::AppGuardResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::AppGuardHttpResponse>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as AppGuard>::handle_http_response(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = HandleHttpResponseSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/appguard.AppGuard/HandleSmtpRequest" => {
#[allow(non_camel_case_types)]
struct HandleSmtpRequestSvc<T: AppGuard>(pub Arc<T>);
impl<
T: AppGuard,
> tonic::server::UnaryService<super::AppGuardSmtpRequest>
for HandleSmtpRequestSvc<T> {
type Response = super::AppGuardResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::AppGuardSmtpRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as AppGuard>::handle_smtp_request(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = HandleSmtpRequestSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/appguard.AppGuard/HandleSmtpResponse" => {
#[allow(non_camel_case_types)]
struct HandleSmtpResponseSvc<T: AppGuard>(pub Arc<T>);
impl<
T: AppGuard,
> tonic::server::UnaryService<super::AppGuardSmtpResponse>
for HandleSmtpResponseSvc<T> {
type Response = super::AppGuardResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::AppGuardSmtpResponse>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as AppGuard>::handle_smtp_response(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = HandleSmtpResponseSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/appguard.AppGuard/FirewallDefaultsRequest" => {
#[allow(non_camel_case_types)]
struct FirewallDefaultsRequestSvc<T: AppGuard>(pub Arc<T>);
impl<T: AppGuard> tonic::server::UnaryService<super::Token>
for FirewallDefaultsRequestSvc<T> {
type Response = super::super::appguard_commands::FirewallDefaults;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::Token>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as AppGuard>::firewall_defaults_request(&inner, request)
.await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = FirewallDefaultsRequestSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => {
Box::pin(async move {
let mut response = http::Response::new(
tonic::body::Body::default(),
);
let headers = response.headers_mut();
headers
.insert(
tonic::Status::GRPC_STATUS,
(tonic::Code::Unimplemented as i32).into(),
);
headers
.insert(
http::header::CONTENT_TYPE,
tonic::metadata::GRPC_CONTENT_TYPE,
);
Ok(response)
})
}
}
}
}
impl<T> Clone for AppGuardServer<T> {
fn clone(&self) -> Self {
let inner = self.inner.clone();
Self {
inner,
accept_compression_encodings: self.accept_compression_encodings,
send_compression_encodings: self.send_compression_encodings,
max_decoding_message_size: self.max_decoding_message_size,
max_encoding_message_size: self.max_encoding_message_size,
}
}
}
pub const SERVICE_NAME: &str = "appguard.AppGuard";
impl<T> tonic::server::NamedService for AppGuardServer<T> {
const NAME: &'static str = SERVICE_NAME;
}
}