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}
138#[derive(Clone, PartialEq, ::prost::Message)]
139pub struct Token {
140 #[prost(string, tag = "1")]
141 pub token: ::prost::alloc::string::String,
142}
143pub mod app_guard_client {
145 #![allow(
146 unused_variables,
147 dead_code,
148 missing_docs,
149 clippy::wildcard_imports,
150 clippy::let_unit_value,
151 )]
152 use tonic::codegen::*;
153 use tonic::codegen::http::Uri;
154 #[derive(Debug, Clone)]
155 pub struct AppGuardClient<T> {
156 inner: tonic::client::Grpc<T>,
157 }
158 impl AppGuardClient<tonic::transport::Channel> {
159 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
161 where
162 D: TryInto<tonic::transport::Endpoint>,
163 D::Error: Into<StdError>,
164 {
165 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
166 Ok(Self::new(conn))
167 }
168 }
169 impl<T> AppGuardClient<T>
170 where
171 T: tonic::client::GrpcService<tonic::body::Body>,
172 T::Error: Into<StdError>,
173 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
174 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
175 {
176 pub fn new(inner: T) -> Self {
177 let inner = tonic::client::Grpc::new(inner);
178 Self { inner }
179 }
180 pub fn with_origin(inner: T, origin: Uri) -> Self {
181 let inner = tonic::client::Grpc::with_origin(inner, origin);
182 Self { inner }
183 }
184 pub fn with_interceptor<F>(
185 inner: T,
186 interceptor: F,
187 ) -> AppGuardClient<InterceptedService<T, F>>
188 where
189 F: tonic::service::Interceptor,
190 T::ResponseBody: Default,
191 T: tonic::codegen::Service<
192 http::Request<tonic::body::Body>,
193 Response = http::Response<
194 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
195 >,
196 >,
197 <T as tonic::codegen::Service<
198 http::Request<tonic::body::Body>,
199 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
200 {
201 AppGuardClient::new(InterceptedService::new(inner, interceptor))
202 }
203 #[must_use]
208 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
209 self.inner = self.inner.send_compressed(encoding);
210 self
211 }
212 #[must_use]
214 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
215 self.inner = self.inner.accept_compressed(encoding);
216 self
217 }
218 #[must_use]
222 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
223 self.inner = self.inner.max_decoding_message_size(limit);
224 self
225 }
226 #[must_use]
230 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
231 self.inner = self.inner.max_encoding_message_size(limit);
232 self
233 }
234 pub async fn control_channel(
236 &mut self,
237 request: impl tonic::IntoStreamingRequest<
238 Message = super::super::appguard_commands::ClientMessage,
239 >,
240 ) -> std::result::Result<
241 tonic::Response<
242 tonic::codec::Streaming<super::super::appguard_commands::ServerMessage>,
243 >,
244 tonic::Status,
245 > {
246 self.inner
247 .ready()
248 .await
249 .map_err(|e| {
250 tonic::Status::unknown(
251 format!("Service was not ready: {}", e.into()),
252 )
253 })?;
254 let codec = tonic::codec::ProstCodec::default();
255 let path = http::uri::PathAndQuery::from_static(
256 "/appguard.AppGuard/ControlChannel",
257 );
258 let mut req = request.into_streaming_request();
259 req.extensions_mut()
260 .insert(GrpcMethod::new("appguard.AppGuard", "ControlChannel"));
261 self.inner.streaming(req, path, codec).await
262 }
263 pub async fn handle_logs(
265 &mut self,
266 request: impl tonic::IntoRequest<super::Logs>,
267 ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
268 self.inner
269 .ready()
270 .await
271 .map_err(|e| {
272 tonic::Status::unknown(
273 format!("Service was not ready: {}", e.into()),
274 )
275 })?;
276 let codec = tonic::codec::ProstCodec::default();
277 let path = http::uri::PathAndQuery::from_static(
278 "/appguard.AppGuard/HandleLogs",
279 );
280 let mut req = request.into_request();
281 req.extensions_mut()
282 .insert(GrpcMethod::new("appguard.AppGuard", "HandleLogs"));
283 self.inner.unary(req, path, codec).await
284 }
285 pub async fn handle_tcp_connection(
287 &mut self,
288 request: impl tonic::IntoRequest<super::AppGuardTcpConnection>,
289 ) -> std::result::Result<
290 tonic::Response<super::AppGuardTcpResponse>,
291 tonic::Status,
292 > {
293 self.inner
294 .ready()
295 .await
296 .map_err(|e| {
297 tonic::Status::unknown(
298 format!("Service was not ready: {}", e.into()),
299 )
300 })?;
301 let codec = tonic::codec::ProstCodec::default();
302 let path = http::uri::PathAndQuery::from_static(
303 "/appguard.AppGuard/HandleTcpConnection",
304 );
305 let mut req = request.into_request();
306 req.extensions_mut()
307 .insert(GrpcMethod::new("appguard.AppGuard", "HandleTcpConnection"));
308 self.inner.unary(req, path, codec).await
309 }
310 pub async fn handle_http_request(
312 &mut self,
313 request: impl tonic::IntoRequest<super::AppGuardHttpRequest>,
314 ) -> std::result::Result<
315 tonic::Response<super::AppGuardResponse>,
316 tonic::Status,
317 > {
318 self.inner
319 .ready()
320 .await
321 .map_err(|e| {
322 tonic::Status::unknown(
323 format!("Service was not ready: {}", e.into()),
324 )
325 })?;
326 let codec = tonic::codec::ProstCodec::default();
327 let path = http::uri::PathAndQuery::from_static(
328 "/appguard.AppGuard/HandleHttpRequest",
329 );
330 let mut req = request.into_request();
331 req.extensions_mut()
332 .insert(GrpcMethod::new("appguard.AppGuard", "HandleHttpRequest"));
333 self.inner.unary(req, path, codec).await
334 }
335 pub async fn handle_http_response(
336 &mut self,
337 request: impl tonic::IntoRequest<super::AppGuardHttpResponse>,
338 ) -> std::result::Result<
339 tonic::Response<super::AppGuardResponse>,
340 tonic::Status,
341 > {
342 self.inner
343 .ready()
344 .await
345 .map_err(|e| {
346 tonic::Status::unknown(
347 format!("Service was not ready: {}", e.into()),
348 )
349 })?;
350 let codec = tonic::codec::ProstCodec::default();
351 let path = http::uri::PathAndQuery::from_static(
352 "/appguard.AppGuard/HandleHttpResponse",
353 );
354 let mut req = request.into_request();
355 req.extensions_mut()
356 .insert(GrpcMethod::new("appguard.AppGuard", "HandleHttpResponse"));
357 self.inner.unary(req, path, codec).await
358 }
359 pub async fn handle_smtp_request(
361 &mut self,
362 request: impl tonic::IntoRequest<super::AppGuardSmtpRequest>,
363 ) -> std::result::Result<
364 tonic::Response<super::AppGuardResponse>,
365 tonic::Status,
366 > {
367 self.inner
368 .ready()
369 .await
370 .map_err(|e| {
371 tonic::Status::unknown(
372 format!("Service was not ready: {}", e.into()),
373 )
374 })?;
375 let codec = tonic::codec::ProstCodec::default();
376 let path = http::uri::PathAndQuery::from_static(
377 "/appguard.AppGuard/HandleSmtpRequest",
378 );
379 let mut req = request.into_request();
380 req.extensions_mut()
381 .insert(GrpcMethod::new("appguard.AppGuard", "HandleSmtpRequest"));
382 self.inner.unary(req, path, codec).await
383 }
384 pub async fn handle_smtp_response(
385 &mut self,
386 request: impl tonic::IntoRequest<super::AppGuardSmtpResponse>,
387 ) -> std::result::Result<
388 tonic::Response<super::AppGuardResponse>,
389 tonic::Status,
390 > {
391 self.inner
392 .ready()
393 .await
394 .map_err(|e| {
395 tonic::Status::unknown(
396 format!("Service was not ready: {}", e.into()),
397 )
398 })?;
399 let codec = tonic::codec::ProstCodec::default();
400 let path = http::uri::PathAndQuery::from_static(
401 "/appguard.AppGuard/HandleSmtpResponse",
402 );
403 let mut req = request.into_request();
404 req.extensions_mut()
405 .insert(GrpcMethod::new("appguard.AppGuard", "HandleSmtpResponse"));
406 self.inner.unary(req, path, codec).await
407 }
408 pub async fn firewall_defaults_request(
410 &mut self,
411 request: impl tonic::IntoRequest<super::Token>,
412 ) -> std::result::Result<
413 tonic::Response<super::super::appguard_commands::FirewallDefaults>,
414 tonic::Status,
415 > {
416 self.inner
417 .ready()
418 .await
419 .map_err(|e| {
420 tonic::Status::unknown(
421 format!("Service was not ready: {}", e.into()),
422 )
423 })?;
424 let codec = tonic::codec::ProstCodec::default();
425 let path = http::uri::PathAndQuery::from_static(
426 "/appguard.AppGuard/FirewallDefaultsRequest",
427 );
428 let mut req = request.into_request();
429 req.extensions_mut()
430 .insert(GrpcMethod::new("appguard.AppGuard", "FirewallDefaultsRequest"));
431 self.inner.unary(req, path, codec).await
432 }
433 }
434}
435pub mod app_guard_server {
437 #![allow(
438 unused_variables,
439 dead_code,
440 missing_docs,
441 clippy::wildcard_imports,
442 clippy::let_unit_value,
443 )]
444 use tonic::codegen::*;
445 #[async_trait]
447 pub trait AppGuard: std::marker::Send + std::marker::Sync + 'static {
448 type ControlChannelStream: tonic::codegen::tokio_stream::Stream<
450 Item = std::result::Result<
451 super::super::appguard_commands::ServerMessage,
452 tonic::Status,
453 >,
454 >
455 + std::marker::Send
456 + 'static;
457 async fn control_channel(
459 &self,
460 request: tonic::Request<
461 tonic::Streaming<super::super::appguard_commands::ClientMessage>,
462 >,
463 ) -> std::result::Result<
464 tonic::Response<Self::ControlChannelStream>,
465 tonic::Status,
466 >;
467 async fn handle_logs(
469 &self,
470 request: tonic::Request<super::Logs>,
471 ) -> std::result::Result<tonic::Response<()>, tonic::Status>;
472 async fn handle_tcp_connection(
474 &self,
475 request: tonic::Request<super::AppGuardTcpConnection>,
476 ) -> std::result::Result<
477 tonic::Response<super::AppGuardTcpResponse>,
478 tonic::Status,
479 >;
480 async fn handle_http_request(
482 &self,
483 request: tonic::Request<super::AppGuardHttpRequest>,
484 ) -> std::result::Result<
485 tonic::Response<super::AppGuardResponse>,
486 tonic::Status,
487 >;
488 async fn handle_http_response(
489 &self,
490 request: tonic::Request<super::AppGuardHttpResponse>,
491 ) -> std::result::Result<
492 tonic::Response<super::AppGuardResponse>,
493 tonic::Status,
494 >;
495 async fn handle_smtp_request(
497 &self,
498 request: tonic::Request<super::AppGuardSmtpRequest>,
499 ) -> std::result::Result<
500 tonic::Response<super::AppGuardResponse>,
501 tonic::Status,
502 >;
503 async fn handle_smtp_response(
504 &self,
505 request: tonic::Request<super::AppGuardSmtpResponse>,
506 ) -> std::result::Result<
507 tonic::Response<super::AppGuardResponse>,
508 tonic::Status,
509 >;
510 async fn firewall_defaults_request(
512 &self,
513 request: tonic::Request<super::Token>,
514 ) -> std::result::Result<
515 tonic::Response<super::super::appguard_commands::FirewallDefaults>,
516 tonic::Status,
517 >;
518 }
519 #[derive(Debug)]
520 pub struct AppGuardServer<T> {
521 inner: Arc<T>,
522 accept_compression_encodings: EnabledCompressionEncodings,
523 send_compression_encodings: EnabledCompressionEncodings,
524 max_decoding_message_size: Option<usize>,
525 max_encoding_message_size: Option<usize>,
526 }
527 impl<T> AppGuardServer<T> {
528 pub fn new(inner: T) -> Self {
529 Self::from_arc(Arc::new(inner))
530 }
531 pub fn from_arc(inner: Arc<T>) -> Self {
532 Self {
533 inner,
534 accept_compression_encodings: Default::default(),
535 send_compression_encodings: Default::default(),
536 max_decoding_message_size: None,
537 max_encoding_message_size: None,
538 }
539 }
540 pub fn with_interceptor<F>(
541 inner: T,
542 interceptor: F,
543 ) -> InterceptedService<Self, F>
544 where
545 F: tonic::service::Interceptor,
546 {
547 InterceptedService::new(Self::new(inner), interceptor)
548 }
549 #[must_use]
551 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
552 self.accept_compression_encodings.enable(encoding);
553 self
554 }
555 #[must_use]
557 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
558 self.send_compression_encodings.enable(encoding);
559 self
560 }
561 #[must_use]
565 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
566 self.max_decoding_message_size = Some(limit);
567 self
568 }
569 #[must_use]
573 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
574 self.max_encoding_message_size = Some(limit);
575 self
576 }
577 }
578 impl<T, B> tonic::codegen::Service<http::Request<B>> for AppGuardServer<T>
579 where
580 T: AppGuard,
581 B: Body + std::marker::Send + 'static,
582 B::Error: Into<StdError> + std::marker::Send + 'static,
583 {
584 type Response = http::Response<tonic::body::Body>;
585 type Error = std::convert::Infallible;
586 type Future = BoxFuture<Self::Response, Self::Error>;
587 fn poll_ready(
588 &mut self,
589 _cx: &mut Context<'_>,
590 ) -> Poll<std::result::Result<(), Self::Error>> {
591 Poll::Ready(Ok(()))
592 }
593 fn call(&mut self, req: http::Request<B>) -> Self::Future {
594 match req.uri().path() {
595 "/appguard.AppGuard/ControlChannel" => {
596 #[allow(non_camel_case_types)]
597 struct ControlChannelSvc<T: AppGuard>(pub Arc<T>);
598 impl<
599 T: AppGuard,
600 > tonic::server::StreamingService<
601 super::super::appguard_commands::ClientMessage,
602 > for ControlChannelSvc<T> {
603 type Response = super::super::appguard_commands::ServerMessage;
604 type ResponseStream = T::ControlChannelStream;
605 type Future = BoxFuture<
606 tonic::Response<Self::ResponseStream>,
607 tonic::Status,
608 >;
609 fn call(
610 &mut self,
611 request: tonic::Request<
612 tonic::Streaming<
613 super::super::appguard_commands::ClientMessage,
614 >,
615 >,
616 ) -> Self::Future {
617 let inner = Arc::clone(&self.0);
618 let fut = async move {
619 <T as AppGuard>::control_channel(&inner, request).await
620 };
621 Box::pin(fut)
622 }
623 }
624 let accept_compression_encodings = self.accept_compression_encodings;
625 let send_compression_encodings = self.send_compression_encodings;
626 let max_decoding_message_size = self.max_decoding_message_size;
627 let max_encoding_message_size = self.max_encoding_message_size;
628 let inner = self.inner.clone();
629 let fut = async move {
630 let method = ControlChannelSvc(inner);
631 let codec = tonic::codec::ProstCodec::default();
632 let mut grpc = tonic::server::Grpc::new(codec)
633 .apply_compression_config(
634 accept_compression_encodings,
635 send_compression_encodings,
636 )
637 .apply_max_message_size_config(
638 max_decoding_message_size,
639 max_encoding_message_size,
640 );
641 let res = grpc.streaming(method, req).await;
642 Ok(res)
643 };
644 Box::pin(fut)
645 }
646 "/appguard.AppGuard/HandleLogs" => {
647 #[allow(non_camel_case_types)]
648 struct HandleLogsSvc<T: AppGuard>(pub Arc<T>);
649 impl<T: AppGuard> tonic::server::UnaryService<super::Logs>
650 for HandleLogsSvc<T> {
651 type Response = ();
652 type Future = BoxFuture<
653 tonic::Response<Self::Response>,
654 tonic::Status,
655 >;
656 fn call(
657 &mut self,
658 request: tonic::Request<super::Logs>,
659 ) -> Self::Future {
660 let inner = Arc::clone(&self.0);
661 let fut = async move {
662 <T as AppGuard>::handle_logs(&inner, request).await
663 };
664 Box::pin(fut)
665 }
666 }
667 let accept_compression_encodings = self.accept_compression_encodings;
668 let send_compression_encodings = self.send_compression_encodings;
669 let max_decoding_message_size = self.max_decoding_message_size;
670 let max_encoding_message_size = self.max_encoding_message_size;
671 let inner = self.inner.clone();
672 let fut = async move {
673 let method = HandleLogsSvc(inner);
674 let codec = tonic::codec::ProstCodec::default();
675 let mut grpc = tonic::server::Grpc::new(codec)
676 .apply_compression_config(
677 accept_compression_encodings,
678 send_compression_encodings,
679 )
680 .apply_max_message_size_config(
681 max_decoding_message_size,
682 max_encoding_message_size,
683 );
684 let res = grpc.unary(method, req).await;
685 Ok(res)
686 };
687 Box::pin(fut)
688 }
689 "/appguard.AppGuard/HandleTcpConnection" => {
690 #[allow(non_camel_case_types)]
691 struct HandleTcpConnectionSvc<T: AppGuard>(pub Arc<T>);
692 impl<
693 T: AppGuard,
694 > tonic::server::UnaryService<super::AppGuardTcpConnection>
695 for HandleTcpConnectionSvc<T> {
696 type Response = super::AppGuardTcpResponse;
697 type Future = BoxFuture<
698 tonic::Response<Self::Response>,
699 tonic::Status,
700 >;
701 fn call(
702 &mut self,
703 request: tonic::Request<super::AppGuardTcpConnection>,
704 ) -> Self::Future {
705 let inner = Arc::clone(&self.0);
706 let fut = async move {
707 <T as AppGuard>::handle_tcp_connection(&inner, request)
708 .await
709 };
710 Box::pin(fut)
711 }
712 }
713 let accept_compression_encodings = self.accept_compression_encodings;
714 let send_compression_encodings = self.send_compression_encodings;
715 let max_decoding_message_size = self.max_decoding_message_size;
716 let max_encoding_message_size = self.max_encoding_message_size;
717 let inner = self.inner.clone();
718 let fut = async move {
719 let method = HandleTcpConnectionSvc(inner);
720 let codec = tonic::codec::ProstCodec::default();
721 let mut grpc = tonic::server::Grpc::new(codec)
722 .apply_compression_config(
723 accept_compression_encodings,
724 send_compression_encodings,
725 )
726 .apply_max_message_size_config(
727 max_decoding_message_size,
728 max_encoding_message_size,
729 );
730 let res = grpc.unary(method, req).await;
731 Ok(res)
732 };
733 Box::pin(fut)
734 }
735 "/appguard.AppGuard/HandleHttpRequest" => {
736 #[allow(non_camel_case_types)]
737 struct HandleHttpRequestSvc<T: AppGuard>(pub Arc<T>);
738 impl<
739 T: AppGuard,
740 > tonic::server::UnaryService<super::AppGuardHttpRequest>
741 for HandleHttpRequestSvc<T> {
742 type Response = super::AppGuardResponse;
743 type Future = BoxFuture<
744 tonic::Response<Self::Response>,
745 tonic::Status,
746 >;
747 fn call(
748 &mut self,
749 request: tonic::Request<super::AppGuardHttpRequest>,
750 ) -> Self::Future {
751 let inner = Arc::clone(&self.0);
752 let fut = async move {
753 <T as AppGuard>::handle_http_request(&inner, request).await
754 };
755 Box::pin(fut)
756 }
757 }
758 let accept_compression_encodings = self.accept_compression_encodings;
759 let send_compression_encodings = self.send_compression_encodings;
760 let max_decoding_message_size = self.max_decoding_message_size;
761 let max_encoding_message_size = self.max_encoding_message_size;
762 let inner = self.inner.clone();
763 let fut = async move {
764 let method = HandleHttpRequestSvc(inner);
765 let codec = tonic::codec::ProstCodec::default();
766 let mut grpc = tonic::server::Grpc::new(codec)
767 .apply_compression_config(
768 accept_compression_encodings,
769 send_compression_encodings,
770 )
771 .apply_max_message_size_config(
772 max_decoding_message_size,
773 max_encoding_message_size,
774 );
775 let res = grpc.unary(method, req).await;
776 Ok(res)
777 };
778 Box::pin(fut)
779 }
780 "/appguard.AppGuard/HandleHttpResponse" => {
781 #[allow(non_camel_case_types)]
782 struct HandleHttpResponseSvc<T: AppGuard>(pub Arc<T>);
783 impl<
784 T: AppGuard,
785 > tonic::server::UnaryService<super::AppGuardHttpResponse>
786 for HandleHttpResponseSvc<T> {
787 type Response = super::AppGuardResponse;
788 type Future = BoxFuture<
789 tonic::Response<Self::Response>,
790 tonic::Status,
791 >;
792 fn call(
793 &mut self,
794 request: tonic::Request<super::AppGuardHttpResponse>,
795 ) -> Self::Future {
796 let inner = Arc::clone(&self.0);
797 let fut = async move {
798 <T as AppGuard>::handle_http_response(&inner, request).await
799 };
800 Box::pin(fut)
801 }
802 }
803 let accept_compression_encodings = self.accept_compression_encodings;
804 let send_compression_encodings = self.send_compression_encodings;
805 let max_decoding_message_size = self.max_decoding_message_size;
806 let max_encoding_message_size = self.max_encoding_message_size;
807 let inner = self.inner.clone();
808 let fut = async move {
809 let method = HandleHttpResponseSvc(inner);
810 let codec = tonic::codec::ProstCodec::default();
811 let mut grpc = tonic::server::Grpc::new(codec)
812 .apply_compression_config(
813 accept_compression_encodings,
814 send_compression_encodings,
815 )
816 .apply_max_message_size_config(
817 max_decoding_message_size,
818 max_encoding_message_size,
819 );
820 let res = grpc.unary(method, req).await;
821 Ok(res)
822 };
823 Box::pin(fut)
824 }
825 "/appguard.AppGuard/HandleSmtpRequest" => {
826 #[allow(non_camel_case_types)]
827 struct HandleSmtpRequestSvc<T: AppGuard>(pub Arc<T>);
828 impl<
829 T: AppGuard,
830 > tonic::server::UnaryService<super::AppGuardSmtpRequest>
831 for HandleSmtpRequestSvc<T> {
832 type Response = super::AppGuardResponse;
833 type Future = BoxFuture<
834 tonic::Response<Self::Response>,
835 tonic::Status,
836 >;
837 fn call(
838 &mut self,
839 request: tonic::Request<super::AppGuardSmtpRequest>,
840 ) -> Self::Future {
841 let inner = Arc::clone(&self.0);
842 let fut = async move {
843 <T as AppGuard>::handle_smtp_request(&inner, request).await
844 };
845 Box::pin(fut)
846 }
847 }
848 let accept_compression_encodings = self.accept_compression_encodings;
849 let send_compression_encodings = self.send_compression_encodings;
850 let max_decoding_message_size = self.max_decoding_message_size;
851 let max_encoding_message_size = self.max_encoding_message_size;
852 let inner = self.inner.clone();
853 let fut = async move {
854 let method = HandleSmtpRequestSvc(inner);
855 let codec = tonic::codec::ProstCodec::default();
856 let mut grpc = tonic::server::Grpc::new(codec)
857 .apply_compression_config(
858 accept_compression_encodings,
859 send_compression_encodings,
860 )
861 .apply_max_message_size_config(
862 max_decoding_message_size,
863 max_encoding_message_size,
864 );
865 let res = grpc.unary(method, req).await;
866 Ok(res)
867 };
868 Box::pin(fut)
869 }
870 "/appguard.AppGuard/HandleSmtpResponse" => {
871 #[allow(non_camel_case_types)]
872 struct HandleSmtpResponseSvc<T: AppGuard>(pub Arc<T>);
873 impl<
874 T: AppGuard,
875 > tonic::server::UnaryService<super::AppGuardSmtpResponse>
876 for HandleSmtpResponseSvc<T> {
877 type Response = super::AppGuardResponse;
878 type Future = BoxFuture<
879 tonic::Response<Self::Response>,
880 tonic::Status,
881 >;
882 fn call(
883 &mut self,
884 request: tonic::Request<super::AppGuardSmtpResponse>,
885 ) -> Self::Future {
886 let inner = Arc::clone(&self.0);
887 let fut = async move {
888 <T as AppGuard>::handle_smtp_response(&inner, request).await
889 };
890 Box::pin(fut)
891 }
892 }
893 let accept_compression_encodings = self.accept_compression_encodings;
894 let send_compression_encodings = self.send_compression_encodings;
895 let max_decoding_message_size = self.max_decoding_message_size;
896 let max_encoding_message_size = self.max_encoding_message_size;
897 let inner = self.inner.clone();
898 let fut = async move {
899 let method = HandleSmtpResponseSvc(inner);
900 let codec = tonic::codec::ProstCodec::default();
901 let mut grpc = tonic::server::Grpc::new(codec)
902 .apply_compression_config(
903 accept_compression_encodings,
904 send_compression_encodings,
905 )
906 .apply_max_message_size_config(
907 max_decoding_message_size,
908 max_encoding_message_size,
909 );
910 let res = grpc.unary(method, req).await;
911 Ok(res)
912 };
913 Box::pin(fut)
914 }
915 "/appguard.AppGuard/FirewallDefaultsRequest" => {
916 #[allow(non_camel_case_types)]
917 struct FirewallDefaultsRequestSvc<T: AppGuard>(pub Arc<T>);
918 impl<T: AppGuard> tonic::server::UnaryService<super::Token>
919 for FirewallDefaultsRequestSvc<T> {
920 type Response = super::super::appguard_commands::FirewallDefaults;
921 type Future = BoxFuture<
922 tonic::Response<Self::Response>,
923 tonic::Status,
924 >;
925 fn call(
926 &mut self,
927 request: tonic::Request<super::Token>,
928 ) -> Self::Future {
929 let inner = Arc::clone(&self.0);
930 let fut = async move {
931 <T as AppGuard>::firewall_defaults_request(&inner, request)
932 .await
933 };
934 Box::pin(fut)
935 }
936 }
937 let accept_compression_encodings = self.accept_compression_encodings;
938 let send_compression_encodings = self.send_compression_encodings;
939 let max_decoding_message_size = self.max_decoding_message_size;
940 let max_encoding_message_size = self.max_encoding_message_size;
941 let inner = self.inner.clone();
942 let fut = async move {
943 let method = FirewallDefaultsRequestSvc(inner);
944 let codec = tonic::codec::ProstCodec::default();
945 let mut grpc = tonic::server::Grpc::new(codec)
946 .apply_compression_config(
947 accept_compression_encodings,
948 send_compression_encodings,
949 )
950 .apply_max_message_size_config(
951 max_decoding_message_size,
952 max_encoding_message_size,
953 );
954 let res = grpc.unary(method, req).await;
955 Ok(res)
956 };
957 Box::pin(fut)
958 }
959 _ => {
960 Box::pin(async move {
961 let mut response = http::Response::new(
962 tonic::body::Body::default(),
963 );
964 let headers = response.headers_mut();
965 headers
966 .insert(
967 tonic::Status::GRPC_STATUS,
968 (tonic::Code::Unimplemented as i32).into(),
969 );
970 headers
971 .insert(
972 http::header::CONTENT_TYPE,
973 tonic::metadata::GRPC_CONTENT_TYPE,
974 );
975 Ok(response)
976 })
977 }
978 }
979 }
980 }
981 impl<T> Clone for AppGuardServer<T> {
982 fn clone(&self) -> Self {
983 let inner = self.inner.clone();
984 Self {
985 inner,
986 accept_compression_encodings: self.accept_compression_encodings,
987 send_compression_encodings: self.send_compression_encodings,
988 max_decoding_message_size: self.max_decoding_message_size,
989 max_encoding_message_size: self.max_encoding_message_size,
990 }
991 }
992 }
993 pub const SERVICE_NAME: &str = "appguard.AppGuard";
995 impl<T> tonic::server::NamedService for AppGuardServer<T> {
996 const NAME: &'static str = SERVICE_NAME;
997 }
998}