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