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