1#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct Logs {
5 #[prost(string, tag = "1")]
6 pub token: ::prost::alloc::string::String,
7 #[prost(message, repeated, tag = "3")]
8 pub logs: ::prost::alloc::vec::Vec<Log>,
9}
10#[derive(serde::Serialize, serde::Deserialize)]
11#[derive(Clone, PartialEq, ::prost::Message)]
12pub struct Log {
13 #[prost(string, tag = "1")]
14 pub timestamp: ::prost::alloc::string::String,
15 #[prost(string, tag = "2")]
16 pub level: ::prost::alloc::string::String,
17 #[prost(string, tag = "3")]
18 pub message: ::prost::alloc::string::String,
19}
20#[derive(Clone, PartialEq, ::prost::Message)]
21pub struct AppGuardTcpConnection {
22 #[prost(string, tag = "1")]
23 pub token: ::prost::alloc::string::String,
24 #[prost(string, optional, tag = "2")]
25 pub source_ip: ::core::option::Option<::prost::alloc::string::String>,
26 #[prost(uint32, optional, tag = "3")]
27 pub source_port: ::core::option::Option<u32>,
28 #[prost(string, optional, tag = "4")]
29 pub destination_ip: ::core::option::Option<::prost::alloc::string::String>,
30 #[prost(uint32, optional, tag = "5")]
31 pub destination_port: ::core::option::Option<u32>,
32 #[prost(string, tag = "6")]
33 pub protocol: ::prost::alloc::string::String,
34}
35#[derive(serde::Deserialize)]
36#[derive(Clone, PartialEq, ::prost::Message)]
37pub struct AppGuardIpInfo {
38 #[prost(string, tag = "1")]
39 pub ip: ::prost::alloc::string::String,
40 #[prost(string, optional, tag = "2")]
41 pub country: ::core::option::Option<::prost::alloc::string::String>,
42 #[prost(string, optional, tag = "3")]
43 pub asn: ::core::option::Option<::prost::alloc::string::String>,
44 #[prost(string, optional, tag = "4")]
45 pub org: ::core::option::Option<::prost::alloc::string::String>,
46 #[prost(string, optional, tag = "5")]
47 pub continent_code: ::core::option::Option<::prost::alloc::string::String>,
48 #[prost(string, optional, tag = "6")]
49 pub city: ::core::option::Option<::prost::alloc::string::String>,
50 #[prost(string, optional, tag = "7")]
51 pub region: ::core::option::Option<::prost::alloc::string::String>,
52 #[prost(string, optional, tag = "8")]
53 pub postal: ::core::option::Option<::prost::alloc::string::String>,
54 #[prost(string, optional, tag = "9")]
55 pub timezone: ::core::option::Option<::prost::alloc::string::String>,
56 #[prost(bool, tag = "100")]
57 pub blacklist: bool,
58}
59#[derive(Clone, PartialEq, ::prost::Message)]
60pub struct AppGuardTcpInfo {
61 #[prost(message, optional, tag = "1")]
62 pub connection: ::core::option::Option<AppGuardTcpConnection>,
63 #[prost(message, optional, tag = "2")]
64 pub ip_info: ::core::option::Option<AppGuardIpInfo>,
65 #[prost(uint64, tag = "3")]
66 pub tcp_id: u64,
67}
68#[derive(Clone, PartialEq, ::prost::Message)]
69pub struct AppGuardHttpRequest {
70 #[prost(string, tag = "1")]
71 pub token: ::prost::alloc::string::String,
72 #[prost(string, tag = "2")]
73 pub original_url: ::prost::alloc::string::String,
74 #[prost(map = "string, string", tag = "3")]
75 pub headers: ::std::collections::HashMap<
76 ::prost::alloc::string::String,
77 ::prost::alloc::string::String,
78 >,
79 #[prost(string, tag = "4")]
80 pub method: ::prost::alloc::string::String,
81 #[prost(string, optional, tag = "5")]
82 pub body: ::core::option::Option<::prost::alloc::string::String>,
83 #[prost(map = "string, string", tag = "6")]
84 pub query: ::std::collections::HashMap<
85 ::prost::alloc::string::String,
86 ::prost::alloc::string::String,
87 >,
88 #[prost(message, optional, tag = "100")]
89 pub tcp_info: ::core::option::Option<AppGuardTcpInfo>,
90}
91#[derive(Clone, PartialEq, ::prost::Message)]
92pub struct AppGuardHttpResponse {
93 #[prost(string, tag = "1")]
94 pub token: ::prost::alloc::string::String,
95 #[prost(uint32, tag = "2")]
96 pub code: u32,
97 #[prost(map = "string, string", tag = "3")]
98 pub headers: ::std::collections::HashMap<
99 ::prost::alloc::string::String,
100 ::prost::alloc::string::String,
101 >,
102 #[prost(message, optional, tag = "100")]
103 pub tcp_info: ::core::option::Option<AppGuardTcpInfo>,
104}
105#[derive(Clone, PartialEq, ::prost::Message)]
106pub struct AppGuardSmtpRequest {
107 #[prost(string, tag = "1")]
108 pub token: ::prost::alloc::string::String,
109 #[prost(map = "string, string", tag = "2")]
110 pub headers: ::std::collections::HashMap<
111 ::prost::alloc::string::String,
112 ::prost::alloc::string::String,
113 >,
114 #[prost(string, optional, tag = "3")]
115 pub body: ::core::option::Option<::prost::alloc::string::String>,
116 #[prost(message, optional, tag = "100")]
117 pub tcp_info: ::core::option::Option<AppGuardTcpInfo>,
118}
119#[derive(Clone, PartialEq, ::prost::Message)]
120pub struct AppGuardSmtpResponse {
121 #[prost(string, tag = "1")]
122 pub token: ::prost::alloc::string::String,
123 #[prost(uint32, optional, tag = "2")]
124 pub code: ::core::option::Option<u32>,
125 #[prost(message, optional, tag = "100")]
126 pub tcp_info: ::core::option::Option<AppGuardTcpInfo>,
127}
128#[derive(Clone, Copy, PartialEq, ::prost::Message)]
129pub struct AppGuardResponse {
130 #[prost(enumeration = "super::appguard_commands::FirewallPolicy", tag = "2")]
131 pub policy: i32,
132}
133#[derive(Clone, PartialEq, ::prost::Message)]
134pub struct AppGuardTcpResponse {
135 #[prost(message, optional, tag = "1")]
136 pub tcp_info: ::core::option::Option<AppGuardTcpInfo>,
137}
138pub mod app_guard_client {
140 #![allow(
141 unused_variables,
142 dead_code,
143 missing_docs,
144 clippy::wildcard_imports,
145 clippy::let_unit_value,
146 )]
147 use tonic::codegen::*;
148 use tonic::codegen::http::Uri;
149 #[derive(Debug, Clone)]
150 pub struct AppGuardClient<T> {
151 inner: tonic::client::Grpc<T>,
152 }
153 impl AppGuardClient<tonic::transport::Channel> {
154 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
156 where
157 D: TryInto<tonic::transport::Endpoint>,
158 D::Error: Into<StdError>,
159 {
160 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
161 Ok(Self::new(conn))
162 }
163 }
164 impl<T> AppGuardClient<T>
165 where
166 T: tonic::client::GrpcService<tonic::body::Body>,
167 T::Error: Into<StdError>,
168 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
169 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
170 {
171 pub fn new(inner: T) -> Self {
172 let inner = tonic::client::Grpc::new(inner);
173 Self { inner }
174 }
175 pub fn with_origin(inner: T, origin: Uri) -> Self {
176 let inner = tonic::client::Grpc::with_origin(inner, origin);
177 Self { inner }
178 }
179 pub fn with_interceptor<F>(
180 inner: T,
181 interceptor: F,
182 ) -> AppGuardClient<InterceptedService<T, F>>
183 where
184 F: tonic::service::Interceptor,
185 T::ResponseBody: Default,
186 T: tonic::codegen::Service<
187 http::Request<tonic::body::Body>,
188 Response = http::Response<
189 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
190 >,
191 >,
192 <T as tonic::codegen::Service<
193 http::Request<tonic::body::Body>,
194 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
195 {
196 AppGuardClient::new(InterceptedService::new(inner, interceptor))
197 }
198 #[must_use]
203 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
204 self.inner = self.inner.send_compressed(encoding);
205 self
206 }
207 #[must_use]
209 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
210 self.inner = self.inner.accept_compressed(encoding);
211 self
212 }
213 #[must_use]
217 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
218 self.inner = self.inner.max_decoding_message_size(limit);
219 self
220 }
221 #[must_use]
225 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
226 self.inner = self.inner.max_encoding_message_size(limit);
227 self
228 }
229 pub async fn control_channel(
231 &mut self,
232 request: impl tonic::IntoStreamingRequest<
233 Message = super::super::appguard_commands::ClientMessage,
234 >,
235 ) -> std::result::Result<
236 tonic::Response<
237 tonic::codec::Streaming<super::super::appguard_commands::ServerMessage>,
238 >,
239 tonic::Status,
240 > {
241 self.inner
242 .ready()
243 .await
244 .map_err(|e| {
245 tonic::Status::unknown(
246 format!("Service was not ready: {}", e.into()),
247 )
248 })?;
249 let codec = tonic::codec::ProstCodec::default();
250 let path = http::uri::PathAndQuery::from_static(
251 "/appguard.AppGuard/ControlChannel",
252 );
253 let mut req = request.into_streaming_request();
254 req.extensions_mut()
255 .insert(GrpcMethod::new("appguard.AppGuard", "ControlChannel"));
256 self.inner.streaming(req, path, codec).await
257 }
258 pub async fn handle_logs(
260 &mut self,
261 request: impl tonic::IntoRequest<super::Logs>,
262 ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
263 self.inner
264 .ready()
265 .await
266 .map_err(|e| {
267 tonic::Status::unknown(
268 format!("Service was not ready: {}", e.into()),
269 )
270 })?;
271 let codec = tonic::codec::ProstCodec::default();
272 let path = http::uri::PathAndQuery::from_static(
273 "/appguard.AppGuard/HandleLogs",
274 );
275 let mut req = request.into_request();
276 req.extensions_mut()
277 .insert(GrpcMethod::new("appguard.AppGuard", "HandleLogs"));
278 self.inner.unary(req, path, codec).await
279 }
280 pub async fn handle_tcp_connection(
282 &mut self,
283 request: impl tonic::IntoRequest<super::AppGuardTcpConnection>,
284 ) -> std::result::Result<
285 tonic::Response<super::AppGuardTcpResponse>,
286 tonic::Status,
287 > {
288 self.inner
289 .ready()
290 .await
291 .map_err(|e| {
292 tonic::Status::unknown(
293 format!("Service was not ready: {}", e.into()),
294 )
295 })?;
296 let codec = tonic::codec::ProstCodec::default();
297 let path = http::uri::PathAndQuery::from_static(
298 "/appguard.AppGuard/HandleTcpConnection",
299 );
300 let mut req = request.into_request();
301 req.extensions_mut()
302 .insert(GrpcMethod::new("appguard.AppGuard", "HandleTcpConnection"));
303 self.inner.unary(req, path, codec).await
304 }
305 pub async fn handle_http_request(
307 &mut self,
308 request: impl tonic::IntoRequest<super::AppGuardHttpRequest>,
309 ) -> std::result::Result<
310 tonic::Response<super::AppGuardResponse>,
311 tonic::Status,
312 > {
313 self.inner
314 .ready()
315 .await
316 .map_err(|e| {
317 tonic::Status::unknown(
318 format!("Service was not ready: {}", e.into()),
319 )
320 })?;
321 let codec = tonic::codec::ProstCodec::default();
322 let path = http::uri::PathAndQuery::from_static(
323 "/appguard.AppGuard/HandleHttpRequest",
324 );
325 let mut req = request.into_request();
326 req.extensions_mut()
327 .insert(GrpcMethod::new("appguard.AppGuard", "HandleHttpRequest"));
328 self.inner.unary(req, path, codec).await
329 }
330 pub async fn handle_http_response(
331 &mut self,
332 request: impl tonic::IntoRequest<super::AppGuardHttpResponse>,
333 ) -> std::result::Result<
334 tonic::Response<super::AppGuardResponse>,
335 tonic::Status,
336 > {
337 self.inner
338 .ready()
339 .await
340 .map_err(|e| {
341 tonic::Status::unknown(
342 format!("Service was not ready: {}", e.into()),
343 )
344 })?;
345 let codec = tonic::codec::ProstCodec::default();
346 let path = http::uri::PathAndQuery::from_static(
347 "/appguard.AppGuard/HandleHttpResponse",
348 );
349 let mut req = request.into_request();
350 req.extensions_mut()
351 .insert(GrpcMethod::new("appguard.AppGuard", "HandleHttpResponse"));
352 self.inner.unary(req, path, codec).await
353 }
354 pub async fn handle_smtp_request(
356 &mut self,
357 request: impl tonic::IntoRequest<super::AppGuardSmtpRequest>,
358 ) -> std::result::Result<
359 tonic::Response<super::AppGuardResponse>,
360 tonic::Status,
361 > {
362 self.inner
363 .ready()
364 .await
365 .map_err(|e| {
366 tonic::Status::unknown(
367 format!("Service was not ready: {}", e.into()),
368 )
369 })?;
370 let codec = tonic::codec::ProstCodec::default();
371 let path = http::uri::PathAndQuery::from_static(
372 "/appguard.AppGuard/HandleSmtpRequest",
373 );
374 let mut req = request.into_request();
375 req.extensions_mut()
376 .insert(GrpcMethod::new("appguard.AppGuard", "HandleSmtpRequest"));
377 self.inner.unary(req, path, codec).await
378 }
379 pub async fn handle_smtp_response(
380 &mut self,
381 request: impl tonic::IntoRequest<super::AppGuardSmtpResponse>,
382 ) -> std::result::Result<
383 tonic::Response<super::AppGuardResponse>,
384 tonic::Status,
385 > {
386 self.inner
387 .ready()
388 .await
389 .map_err(|e| {
390 tonic::Status::unknown(
391 format!("Service was not ready: {}", e.into()),
392 )
393 })?;
394 let codec = tonic::codec::ProstCodec::default();
395 let path = http::uri::PathAndQuery::from_static(
396 "/appguard.AppGuard/HandleSmtpResponse",
397 );
398 let mut req = request.into_request();
399 req.extensions_mut()
400 .insert(GrpcMethod::new("appguard.AppGuard", "HandleSmtpResponse"));
401 self.inner.unary(req, path, codec).await
402 }
403 }
404}
405pub mod app_guard_server {
407 #![allow(
408 unused_variables,
409 dead_code,
410 missing_docs,
411 clippy::wildcard_imports,
412 clippy::let_unit_value,
413 )]
414 use tonic::codegen::*;
415 #[async_trait]
417 pub trait AppGuard: std::marker::Send + std::marker::Sync + 'static {
418 type ControlChannelStream: tonic::codegen::tokio_stream::Stream<
420 Item = std::result::Result<
421 super::super::appguard_commands::ServerMessage,
422 tonic::Status,
423 >,
424 >
425 + std::marker::Send
426 + 'static;
427 async fn control_channel(
429 &self,
430 request: tonic::Request<
431 tonic::Streaming<super::super::appguard_commands::ClientMessage>,
432 >,
433 ) -> std::result::Result<
434 tonic::Response<Self::ControlChannelStream>,
435 tonic::Status,
436 >;
437 async fn handle_logs(
439 &self,
440 request: tonic::Request<super::Logs>,
441 ) -> std::result::Result<tonic::Response<()>, tonic::Status>;
442 async fn handle_tcp_connection(
444 &self,
445 request: tonic::Request<super::AppGuardTcpConnection>,
446 ) -> std::result::Result<
447 tonic::Response<super::AppGuardTcpResponse>,
448 tonic::Status,
449 >;
450 async fn handle_http_request(
452 &self,
453 request: tonic::Request<super::AppGuardHttpRequest>,
454 ) -> std::result::Result<
455 tonic::Response<super::AppGuardResponse>,
456 tonic::Status,
457 >;
458 async fn handle_http_response(
459 &self,
460 request: tonic::Request<super::AppGuardHttpResponse>,
461 ) -> std::result::Result<
462 tonic::Response<super::AppGuardResponse>,
463 tonic::Status,
464 >;
465 async fn handle_smtp_request(
467 &self,
468 request: tonic::Request<super::AppGuardSmtpRequest>,
469 ) -> std::result::Result<
470 tonic::Response<super::AppGuardResponse>,
471 tonic::Status,
472 >;
473 async fn handle_smtp_response(
474 &self,
475 request: tonic::Request<super::AppGuardSmtpResponse>,
476 ) -> std::result::Result<
477 tonic::Response<super::AppGuardResponse>,
478 tonic::Status,
479 >;
480 }
481 #[derive(Debug)]
482 pub struct AppGuardServer<T> {
483 inner: Arc<T>,
484 accept_compression_encodings: EnabledCompressionEncodings,
485 send_compression_encodings: EnabledCompressionEncodings,
486 max_decoding_message_size: Option<usize>,
487 max_encoding_message_size: Option<usize>,
488 }
489 impl<T> AppGuardServer<T> {
490 pub fn new(inner: T) -> Self {
491 Self::from_arc(Arc::new(inner))
492 }
493 pub fn from_arc(inner: Arc<T>) -> Self {
494 Self {
495 inner,
496 accept_compression_encodings: Default::default(),
497 send_compression_encodings: Default::default(),
498 max_decoding_message_size: None,
499 max_encoding_message_size: None,
500 }
501 }
502 pub fn with_interceptor<F>(
503 inner: T,
504 interceptor: F,
505 ) -> InterceptedService<Self, F>
506 where
507 F: tonic::service::Interceptor,
508 {
509 InterceptedService::new(Self::new(inner), interceptor)
510 }
511 #[must_use]
513 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
514 self.accept_compression_encodings.enable(encoding);
515 self
516 }
517 #[must_use]
519 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
520 self.send_compression_encodings.enable(encoding);
521 self
522 }
523 #[must_use]
527 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
528 self.max_decoding_message_size = Some(limit);
529 self
530 }
531 #[must_use]
535 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
536 self.max_encoding_message_size = Some(limit);
537 self
538 }
539 }
540 impl<T, B> tonic::codegen::Service<http::Request<B>> for AppGuardServer<T>
541 where
542 T: AppGuard,
543 B: Body + std::marker::Send + 'static,
544 B::Error: Into<StdError> + std::marker::Send + 'static,
545 {
546 type Response = http::Response<tonic::body::Body>;
547 type Error = std::convert::Infallible;
548 type Future = BoxFuture<Self::Response, Self::Error>;
549 fn poll_ready(
550 &mut self,
551 _cx: &mut Context<'_>,
552 ) -> Poll<std::result::Result<(), Self::Error>> {
553 Poll::Ready(Ok(()))
554 }
555 fn call(&mut self, req: http::Request<B>) -> Self::Future {
556 match req.uri().path() {
557 "/appguard.AppGuard/ControlChannel" => {
558 #[allow(non_camel_case_types)]
559 struct ControlChannelSvc<T: AppGuard>(pub Arc<T>);
560 impl<
561 T: AppGuard,
562 > tonic::server::StreamingService<
563 super::super::appguard_commands::ClientMessage,
564 > for ControlChannelSvc<T> {
565 type Response = super::super::appguard_commands::ServerMessage;
566 type ResponseStream = T::ControlChannelStream;
567 type Future = BoxFuture<
568 tonic::Response<Self::ResponseStream>,
569 tonic::Status,
570 >;
571 fn call(
572 &mut self,
573 request: tonic::Request<
574 tonic::Streaming<
575 super::super::appguard_commands::ClientMessage,
576 >,
577 >,
578 ) -> Self::Future {
579 let inner = Arc::clone(&self.0);
580 let fut = async move {
581 <T as AppGuard>::control_channel(&inner, request).await
582 };
583 Box::pin(fut)
584 }
585 }
586 let accept_compression_encodings = self.accept_compression_encodings;
587 let send_compression_encodings = self.send_compression_encodings;
588 let max_decoding_message_size = self.max_decoding_message_size;
589 let max_encoding_message_size = self.max_encoding_message_size;
590 let inner = self.inner.clone();
591 let fut = async move {
592 let method = ControlChannelSvc(inner);
593 let codec = tonic::codec::ProstCodec::default();
594 let mut grpc = tonic::server::Grpc::new(codec)
595 .apply_compression_config(
596 accept_compression_encodings,
597 send_compression_encodings,
598 )
599 .apply_max_message_size_config(
600 max_decoding_message_size,
601 max_encoding_message_size,
602 );
603 let res = grpc.streaming(method, req).await;
604 Ok(res)
605 };
606 Box::pin(fut)
607 }
608 "/appguard.AppGuard/HandleLogs" => {
609 #[allow(non_camel_case_types)]
610 struct HandleLogsSvc<T: AppGuard>(pub Arc<T>);
611 impl<T: AppGuard> tonic::server::UnaryService<super::Logs>
612 for HandleLogsSvc<T> {
613 type Response = ();
614 type Future = BoxFuture<
615 tonic::Response<Self::Response>,
616 tonic::Status,
617 >;
618 fn call(
619 &mut self,
620 request: tonic::Request<super::Logs>,
621 ) -> Self::Future {
622 let inner = Arc::clone(&self.0);
623 let fut = async move {
624 <T as AppGuard>::handle_logs(&inner, request).await
625 };
626 Box::pin(fut)
627 }
628 }
629 let accept_compression_encodings = self.accept_compression_encodings;
630 let send_compression_encodings = self.send_compression_encodings;
631 let max_decoding_message_size = self.max_decoding_message_size;
632 let max_encoding_message_size = self.max_encoding_message_size;
633 let inner = self.inner.clone();
634 let fut = async move {
635 let method = HandleLogsSvc(inner);
636 let codec = tonic::codec::ProstCodec::default();
637 let mut grpc = tonic::server::Grpc::new(codec)
638 .apply_compression_config(
639 accept_compression_encodings,
640 send_compression_encodings,
641 )
642 .apply_max_message_size_config(
643 max_decoding_message_size,
644 max_encoding_message_size,
645 );
646 let res = grpc.unary(method, req).await;
647 Ok(res)
648 };
649 Box::pin(fut)
650 }
651 "/appguard.AppGuard/HandleTcpConnection" => {
652 #[allow(non_camel_case_types)]
653 struct HandleTcpConnectionSvc<T: AppGuard>(pub Arc<T>);
654 impl<
655 T: AppGuard,
656 > tonic::server::UnaryService<super::AppGuardTcpConnection>
657 for HandleTcpConnectionSvc<T> {
658 type Response = super::AppGuardTcpResponse;
659 type Future = BoxFuture<
660 tonic::Response<Self::Response>,
661 tonic::Status,
662 >;
663 fn call(
664 &mut self,
665 request: tonic::Request<super::AppGuardTcpConnection>,
666 ) -> Self::Future {
667 let inner = Arc::clone(&self.0);
668 let fut = async move {
669 <T as AppGuard>::handle_tcp_connection(&inner, request)
670 .await
671 };
672 Box::pin(fut)
673 }
674 }
675 let accept_compression_encodings = self.accept_compression_encodings;
676 let send_compression_encodings = self.send_compression_encodings;
677 let max_decoding_message_size = self.max_decoding_message_size;
678 let max_encoding_message_size = self.max_encoding_message_size;
679 let inner = self.inner.clone();
680 let fut = async move {
681 let method = HandleTcpConnectionSvc(inner);
682 let codec = tonic::codec::ProstCodec::default();
683 let mut grpc = tonic::server::Grpc::new(codec)
684 .apply_compression_config(
685 accept_compression_encodings,
686 send_compression_encodings,
687 )
688 .apply_max_message_size_config(
689 max_decoding_message_size,
690 max_encoding_message_size,
691 );
692 let res = grpc.unary(method, req).await;
693 Ok(res)
694 };
695 Box::pin(fut)
696 }
697 "/appguard.AppGuard/HandleHttpRequest" => {
698 #[allow(non_camel_case_types)]
699 struct HandleHttpRequestSvc<T: AppGuard>(pub Arc<T>);
700 impl<
701 T: AppGuard,
702 > tonic::server::UnaryService<super::AppGuardHttpRequest>
703 for HandleHttpRequestSvc<T> {
704 type Response = super::AppGuardResponse;
705 type Future = BoxFuture<
706 tonic::Response<Self::Response>,
707 tonic::Status,
708 >;
709 fn call(
710 &mut self,
711 request: tonic::Request<super::AppGuardHttpRequest>,
712 ) -> Self::Future {
713 let inner = Arc::clone(&self.0);
714 let fut = async move {
715 <T as AppGuard>::handle_http_request(&inner, request).await
716 };
717 Box::pin(fut)
718 }
719 }
720 let accept_compression_encodings = self.accept_compression_encodings;
721 let send_compression_encodings = self.send_compression_encodings;
722 let max_decoding_message_size = self.max_decoding_message_size;
723 let max_encoding_message_size = self.max_encoding_message_size;
724 let inner = self.inner.clone();
725 let fut = async move {
726 let method = HandleHttpRequestSvc(inner);
727 let codec = tonic::codec::ProstCodec::default();
728 let mut grpc = tonic::server::Grpc::new(codec)
729 .apply_compression_config(
730 accept_compression_encodings,
731 send_compression_encodings,
732 )
733 .apply_max_message_size_config(
734 max_decoding_message_size,
735 max_encoding_message_size,
736 );
737 let res = grpc.unary(method, req).await;
738 Ok(res)
739 };
740 Box::pin(fut)
741 }
742 "/appguard.AppGuard/HandleHttpResponse" => {
743 #[allow(non_camel_case_types)]
744 struct HandleHttpResponseSvc<T: AppGuard>(pub Arc<T>);
745 impl<
746 T: AppGuard,
747 > tonic::server::UnaryService<super::AppGuardHttpResponse>
748 for HandleHttpResponseSvc<T> {
749 type Response = super::AppGuardResponse;
750 type Future = BoxFuture<
751 tonic::Response<Self::Response>,
752 tonic::Status,
753 >;
754 fn call(
755 &mut self,
756 request: tonic::Request<super::AppGuardHttpResponse>,
757 ) -> Self::Future {
758 let inner = Arc::clone(&self.0);
759 let fut = async move {
760 <T as AppGuard>::handle_http_response(&inner, request).await
761 };
762 Box::pin(fut)
763 }
764 }
765 let accept_compression_encodings = self.accept_compression_encodings;
766 let send_compression_encodings = self.send_compression_encodings;
767 let max_decoding_message_size = self.max_decoding_message_size;
768 let max_encoding_message_size = self.max_encoding_message_size;
769 let inner = self.inner.clone();
770 let fut = async move {
771 let method = HandleHttpResponseSvc(inner);
772 let codec = tonic::codec::ProstCodec::default();
773 let mut grpc = tonic::server::Grpc::new(codec)
774 .apply_compression_config(
775 accept_compression_encodings,
776 send_compression_encodings,
777 )
778 .apply_max_message_size_config(
779 max_decoding_message_size,
780 max_encoding_message_size,
781 );
782 let res = grpc.unary(method, req).await;
783 Ok(res)
784 };
785 Box::pin(fut)
786 }
787 "/appguard.AppGuard/HandleSmtpRequest" => {
788 #[allow(non_camel_case_types)]
789 struct HandleSmtpRequestSvc<T: AppGuard>(pub Arc<T>);
790 impl<
791 T: AppGuard,
792 > tonic::server::UnaryService<super::AppGuardSmtpRequest>
793 for HandleSmtpRequestSvc<T> {
794 type Response = super::AppGuardResponse;
795 type Future = BoxFuture<
796 tonic::Response<Self::Response>,
797 tonic::Status,
798 >;
799 fn call(
800 &mut self,
801 request: tonic::Request<super::AppGuardSmtpRequest>,
802 ) -> Self::Future {
803 let inner = Arc::clone(&self.0);
804 let fut = async move {
805 <T as AppGuard>::handle_smtp_request(&inner, request).await
806 };
807 Box::pin(fut)
808 }
809 }
810 let accept_compression_encodings = self.accept_compression_encodings;
811 let send_compression_encodings = self.send_compression_encodings;
812 let max_decoding_message_size = self.max_decoding_message_size;
813 let max_encoding_message_size = self.max_encoding_message_size;
814 let inner = self.inner.clone();
815 let fut = async move {
816 let method = HandleSmtpRequestSvc(inner);
817 let codec = tonic::codec::ProstCodec::default();
818 let mut grpc = tonic::server::Grpc::new(codec)
819 .apply_compression_config(
820 accept_compression_encodings,
821 send_compression_encodings,
822 )
823 .apply_max_message_size_config(
824 max_decoding_message_size,
825 max_encoding_message_size,
826 );
827 let res = grpc.unary(method, req).await;
828 Ok(res)
829 };
830 Box::pin(fut)
831 }
832 "/appguard.AppGuard/HandleSmtpResponse" => {
833 #[allow(non_camel_case_types)]
834 struct HandleSmtpResponseSvc<T: AppGuard>(pub Arc<T>);
835 impl<
836 T: AppGuard,
837 > tonic::server::UnaryService<super::AppGuardSmtpResponse>
838 for HandleSmtpResponseSvc<T> {
839 type Response = super::AppGuardResponse;
840 type Future = BoxFuture<
841 tonic::Response<Self::Response>,
842 tonic::Status,
843 >;
844 fn call(
845 &mut self,
846 request: tonic::Request<super::AppGuardSmtpResponse>,
847 ) -> Self::Future {
848 let inner = Arc::clone(&self.0);
849 let fut = async move {
850 <T as AppGuard>::handle_smtp_response(&inner, request).await
851 };
852 Box::pin(fut)
853 }
854 }
855 let accept_compression_encodings = self.accept_compression_encodings;
856 let send_compression_encodings = self.send_compression_encodings;
857 let max_decoding_message_size = self.max_decoding_message_size;
858 let max_encoding_message_size = self.max_encoding_message_size;
859 let inner = self.inner.clone();
860 let fut = async move {
861 let method = HandleSmtpResponseSvc(inner);
862 let codec = tonic::codec::ProstCodec::default();
863 let mut grpc = tonic::server::Grpc::new(codec)
864 .apply_compression_config(
865 accept_compression_encodings,
866 send_compression_encodings,
867 )
868 .apply_max_message_size_config(
869 max_decoding_message_size,
870 max_encoding_message_size,
871 );
872 let res = grpc.unary(method, req).await;
873 Ok(res)
874 };
875 Box::pin(fut)
876 }
877 _ => {
878 Box::pin(async move {
879 let mut response = http::Response::new(
880 tonic::body::Body::default(),
881 );
882 let headers = response.headers_mut();
883 headers
884 .insert(
885 tonic::Status::GRPC_STATUS,
886 (tonic::Code::Unimplemented as i32).into(),
887 );
888 headers
889 .insert(
890 http::header::CONTENT_TYPE,
891 tonic::metadata::GRPC_CONTENT_TYPE,
892 );
893 Ok(response)
894 })
895 }
896 }
897 }
898 }
899 impl<T> Clone for AppGuardServer<T> {
900 fn clone(&self) -> Self {
901 let inner = self.inner.clone();
902 Self {
903 inner,
904 accept_compression_encodings: self.accept_compression_encodings,
905 send_compression_encodings: self.send_compression_encodings,
906 max_decoding_message_size: self.max_decoding_message_size,
907 max_encoding_message_size: self.max_encoding_message_size,
908 }
909 }
910 }
911 pub const SERVICE_NAME: &str = "appguard.AppGuard";
913 impl<T> tonic::server::NamedService for AppGuardServer<T> {
914 const NAME: &'static str = SERVICE_NAME;
915 }
916}