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